Results 1 to 15 of 15

Thread: Axis not fit with the plot

  1. #1
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Axis not fit with the plot

    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.)
    why.jpg

  2. #2
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    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?

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Axis not fit with the plot

    And what is it what you want to do: maybe "plot->enableAxis( QwtPlot::xTop );" ?

    Uwe

  4. #4
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Uwe View Post
    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/1836...ut-of-the-plot
    thanks in advance.

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Axis not fit with the plot

    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

  6. #6
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Uwe View Post
    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
    Last edited by Nicho; 22nd June 2013 at 04:47. Reason: updated contents

  7. #7
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Uwe,help,please

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Axis not fit with the plot

    What do you want to do ( not how ) ?

    Uwe

  9. #9
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Uwe View Post
    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 ):
    prob.jpg

    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
    Last edited by Nicho; 24th June 2013 at 10:25. Reason: updated contents

  10. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Nicho View Post
    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
    Last edited by Uwe; 24th June 2013 at 21:03.

  11. #11
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Uwe View Post
    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

  12. #12
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Axis not fit with the plot

    See below qwt-6.1/playground/plotmatrix/

    Uwe

  13. #13
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    Quote Originally Posted by Uwe View Post
    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.

  14. #14
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    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 :
    prob-1.jpg

    How to fix this?
    Thank you in advance.

  15. #15
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not fit with the plot

    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:
    prob-2.jpg

Similar Threads

  1. Need help formatting plot axis
    By Jayl in forum Qwt
    Replies: 2
    Last Post: 8th April 2013, 18:20
  2. Replies: 9
    Last Post: 3rd May 2011, 21:21
  3. Is it possible to draw axis in Plot?
    By beni46 in forum Qwt
    Replies: 2
    Last Post: 26th January 2010, 12:54
  4. qwp plot axis scale
    By Cal in forum Qwt
    Replies: 1
    Last Post: 11th May 2009, 17:10
  5. Detecting changes in the qwt plot axis
    By mrcolin in forum Qwt
    Replies: 2
    Last Post: 27th January 2009, 12:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.