Results 1 to 4 of 4

Thread: Changing the scale of axis in a plot

  1. #1
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing the scale of axis in a plot

    Hello,

    I have a Qwt plot that displays the X-Axis in units of digital samples. My data series is 10 samples for example, data = [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]. My x-axis actually corresponds to a length in mm, where 10 Samples = 3 mm. How can I draw the axis so the same data is plotted, but I display a different scale? See the example graph I've drawn below. In reality, I have 512 Samples that correspond to ~3 mm, but I believe this is effectively the same.

    Thank you in advance!
    Ryan


    Qt Code:
    1. plotting data that consists of 10 samples
    2. data = [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]
    3.  
    4. 110 + : : : : : : : : : :
    5. 100 + : : : : : : : : x :
    6. 90 + : : : : : : : x : :
    7. 80 + : : : : : : x : : :
    8. 70 + : : : : : x : : : :
    9. 60 + : : : : x : : : : :
    10. 50 + : : : x : : : : : :
    11. 40 + : : x : : : : : : :
    12. 30 + : x : : : : : : : :
    13. 10 + x : : : : : : : : :
    14. 10 x : : : : : : : : : :
    15. 0 --+--+--+--+--+--+--+--+--+--+--+
    16. | | | | | | | | | | |
    17. 0 2 4 6 8
    18. (Samples)
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. Draw X Axis to a new scale where 10 Samples = 3 mm
    2.  
    3. 0 S => 0 mm
    4. 1 S => 0.3 mm
    5. 2 S => 0.6 mm
    6. 3 S => 0.9 mm
    7. .
    8. .
    9. .
    10. 9 S => 2.7 mm
    11. 110 + : : : : : : : : : :
    12. 100 + : : : : : : : : x :
    13. 90 + : : : : : : : x : :
    14. 80 + : : : : : : x : : :
    15. 70 + : : : : : x : : : :
    16. 60 + : : : : x : : : : :
    17. 50 + : : : x : : : : : :
    18. 40 + : : x : : : : : : :
    19. 30 + : x : : : : : : : :
    20. 10 + x : : : : : : : : :
    21. 10 x : : : : : : : : : :
    22. 0 --+--+--+--+--+--+--+--+--+--+--+
    23. | | | | | | | | | | |
    24. | | | | |
    25. 0 0.6 1.2 1.8 2.4
    26. (mm)
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Changing the scale of axis in a plot

    Well, a curve displays a series of points - not values - so I guess your code adds the index as x coordinate. And now you want to use index * 0.3 as x coordinates ?

    Uwe

  3. #3
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing the scale of axis in a plot

    Hi Uwe,

    I think my answer to your question is yes. Let me clarify. I do not want to change the data in the plot, I just want to change the label of the X-axis. I also want to continue to plot the same number of samples.

    Ryan

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

    Default Re: Changing the scale of axis in a plot

    Derive from QwtScaleDraw, overload the label() method and pass it with QwtPlot::setAxisScaleDraw().

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 11th February 2014, 22:31
  2. Scale Breaks in the QWT plot axis
    By OzQTNoob in forum Qwt
    Replies: 1
    Last Post: 10th May 2012, 10:38
  3. Replies: 0
    Last Post: 18th January 2012, 08:41
  4. Replies: 8
    Last Post: 25th April 2010, 22:19
  5. qwp plot axis scale
    By Cal in forum Qwt
    Replies: 1
    Last Post: 11th May 2009, 18:10

Tags for this Thread

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.