PDA

View Full Version : Axis not fit with the plot



Nicho
20th June 2013, 16:37
As the picture shown, the axes don't fit with the plot well.
Why?And how to fix it?
(The axes are not the ones in QwtPlot.)
9171

Nicho
21st June 2013, 13:47
Uwe,
i have found a thread about the similar prob posted several years ago.
it seems two or three lines of codes work.
but it is on the earlier release of qwt.
can you tell me how to do on 6.1?

Uwe
21st June 2013, 14:19
And what is it what you want to do: maybe "plot->enableAxis( QwtPlot::xTop );" ?

Uwe

Nicho
21st June 2013, 16:00
And what is it what you want to do: maybe "plot->enableAxis( QwtPlot::xTop );" ?

Uwe

Uwe,
i just want to know how to achieve the effect mentioned in the following thread with qwt6.1 :
http://www.qtcentre.org/threads/18360-Put-plot-axis-out-of-the-plot
thanks in advance.

Uwe
21st June 2013, 16:41
This thread is about a scrollview - and the idea posted there the same for Qwt 6.1. Does this answer help: no.
So better answer my question and explain your situation.

Uwe

Nicho
22nd June 2013, 03:52
This thread is about a scrollview - and the idea posted there the same for Qwt 6.1. Does this answer help: no.
So better answer my question and explain your situation.

Uwe

Uwe,
I have the similar situation mentioned in that thread.
In that thread you provided codes like this:

1.void XXX::syncScale(int axis)
2.{
3. ...
4.
5. yourScale->setScaleDiv(
6. plot->axisScaleEngine(axis)->transformation(),
7. plot->axisWidget(axis)->scaleDiv() );
8.
9. int startDist, endDist;
10. yourScale->getBorderDistHint(startDist, endDist);
11. yourScale->setBorderDist(startDist, endDist);
12.
13.}
14.
15.connect(plot->axisWidget(...), SIGNAL(scaleDivChanged(),
16. ..., SLOT(syncScale() );

but I don't find a function which is like the following one in the class QwtScaleWidget

yourScale->setScaleDiv( plot->axisScaleEngine(axis)->transformation(), plot->axisWidget(axis)->scaleDiv() );What I've found is setScaleDiv( const QwtScaleDiv &sd ) and setTransformation( QwtTransform * ).
So I am confused.

What I have tried is like this:
initPlot()
{

myplot = new QwtPlot();
myplot -> enableAxis( QwtPlot::yLeft, false );
myplot -> enableAxis( QwtPlot::xBottom, false );
myplot -> setAxisAutoScale( QwtPlot::yLeft, false );
myplot -> setAxisAutoScale( QwtPlot::xBottom, false );
//some plot items initialization
...
updateAxes();}

updateAxes()
{

//for each axis of the four, I try to set the same transformation and scalediv for left and right axes or top and bottom axes
scaleWidget[Left] -> setTransformation( myplot -> axisScaleEngine( QwtPlot::yLeft ) -> transformation() );
scaleWidget[Right] -> setTransformation( myplot -> axisScaleEngine( QwtPlot::yLeft ) -> transformation() );
scaleWidget[Left] -> setScaleDiv( myplot -> axisScaleDiv( QwtPlot::yLeft ) );
scaleWidget[Right] -> setScaleDiv( myplot -> axisScaleDiv( QwtPlot::yLeft ) );
int startDist, endDist;
scaleWidget[Left] -> getBorderDistHint( startDist, endDist );
scaleWidget[Left] -> setBorderDist( startDist, endDist );
scaleWidget[Right] -> setBorderDist( startDist, endDist );
//the similar codes for scaleWidget[Top] and scaleWidget[Bottom]
//...}

but when the plot is shown, it looks like the picture I've attached in this thread before.
and the ticks are not aligned with the contents of the plot.

Your fan,
Nicho

Nicho
23rd June 2013, 06:26
Uwe,help,please

Uwe
24th June 2013, 07:05
What do you want to do ( not how ) ?

Uwe

Nicho
24th June 2013, 10:14
What do you want to do ( not how ) ?

Uwe

Uwe,
In my application, I want to create several scatter plots which are placed in grid.
The plots in the same row have the same Y axis and the ones in the same column have the same X axis.
The plots need to be placed one by one without axes between them.
Maybe I could choose this way: enable the plots in the first row to show their X-Top axis, the ones in the last row to show their X-Bottom axis, and the ones in the far left column to show their Y-Left axis, and so on.
But in my application, all the plots better to be displayed as the same size.
Because of this, I disabled the axes included in QwtPlot.

Now my application is running like this ( the ticks are not aligned with the plot contents ):
9180

Uwe,
How to align the ticks to the plot contents?
Could you provide me sth. in details?
I think my prob is similar with that thread, because it's also about how to align the ticks of the axis outside of the plot to the contents of the plot.
But I tried many many times including that, and failed.
Looking forward to your advice eagerly.

Thanks in advance.

Nicho

Uwe
24th June 2013, 20:53
In my application, I want to create several scatter plots which are placed in grid.
The plots in the same row have the same Y axis and the ones in the same column have the same X axis.
The plots need to be placed one by one without axes between them.
This is shown in the plotmatrix example - well at least it should, but the example seems to be broken for the x axis. I will fix it.

But nevertheless - it shows the idea how it could be done.

Uwe

Nicho
25th June 2013, 01:07
This is shown in the plotmatrix example - well at least it should, but the example seems to be broken for the x axis. I will fix it.

But nevertheless - it shows the idea how it could be done.

Uwe

Uwe,
In the Qwt6.1 package I've dowloaded, there is no such an example about plotmatrix.
Can you tell me where to get it?
Or, if it is not very difficult, can you tell me how to achieve what I want based on my current plan?

Nicho

Uwe
25th June 2013, 05:25
See below qwt-6.1/playground/plotmatrix/

Uwe

Nicho
25th June 2013, 09:33
See below qwt-6.1/playground/plotmatrix/

Uwe

Uwe,
Thank you soooooo much.
I have read all the examples to seek sth. helpful to my prob time and time again and failed to find one.
Unblievable, I missed the playground.
It is what I need, and I'll try to show X axes based on the idea of plotmatrix.
At the same time, I wish with my heart that Uwe could fix the example for x axis soon if you can share me some time.
For I am not sure I will succeed in doing that, but I'll try.
Thanks again.

Nicho
28th June 2013, 09:00
Uwe,
I have played around with the example plotmatrix.
And for example here:

52 int main( int argc, char **argv )
53 {
54 QApplication a( argc, argv );
55
56 MainWindow mainWindow;
57
58 mainWindow.resize( 800, 600 );
59 mainWindow.show();
60//I added the following codes
61 QwtPlot *p = (mainWindow.plot( 3, 0 ));
62 QwtScaleWidget *sc = p -> axisWidget( QwtPlot::yLeft );
63 sc -> setLabelRotation( 45 );
64
65 return a.exec();
66 }

When I rotated the yLeft axis label of the plot[3][0] , only the left axis is aligned with the plot[3][0].
The other plots in Row 3 are not right.

And the matrix shows like this :
9199

How to fix this?
Thank you in advance.

Nicho
28th June 2013, 12:28
Uwe,
Can you help me?
I could not make the axes align with the plots well based on the plotmatrix.
I followed to add the control on x axis as what you have done on the y axis.
But the top axis is synchronized as the bottom one, but the top axis is not aligned with the plot.
It seems the top plots' grid are not synchronized with the axis.
How could I do? Need your help.
Many many thanks.


Seeing this pic below:
9200