Results 1 to 3 of 3

Thread: How to replace number scale with text scale in qwtplot?

  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to replace number scale with text scale in qwtplot?

    Hello,

    I have draw simple graph using QwtPlot() and QwtPlotGrid().

    Now I want to replace numbers on Y-axis with some text.

    Please check the below attachment shows, I have achived right side of graph now I want graph looks like left side.
    graph.jpg

    Thanking in advanced!

  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: How to replace number scale with text scale in qwtplot?

    Overload QwtScaleDraw::label.

    Uwe

  3. #3
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to replace number scale with text scale in qwtplot?

    Thanks Uwe, it will work, but I have some issues while working on.
    I have tried to overload like below,
    Qt Code:
    1. class QwtMyScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. QwtMyScaleDraw(){
    5.  
    6. }
    7.  
    8. virtual QwtText label(double v) const
    9. {
    10. qDebug()<<"Input to Label"<<v;
    11. }
    To copy to clipboard, switch view to plain text mode 

    And I use this above class as,
    Qt Code:
    1. plot->setAxisScaleDraw(QwtPlot::yLeft, new QwtMyScaleDraw());
    To copy to clipboard, switch view to plain text mode 

    Actual Output ==>
    unknown(0)[11756]: Input to Label 0
    unknown(0)[11756]: Input to Label 100
    unknown(0)[11756]: Input to Label 10
    unknown(0)[11756]: Input to Label 20
    unknown(0)[11756]: Input to Label 30
    unknown(0)[11756]: Input to Label 40
    unknown(0)[11756]: Input to Label 50
    unknown(0)[11756]: Input to Label 60
    unknown(0)[11756]: Input to Label 70
    unknown(0)[11756]: Input to Label 80
    unknown(0)[11756]: Input to Label 90
    unknown(0)[11756]: Input to Label 1000
    unknown(0)[11756]: Input to Label 0
    unknown(0)[11756]: Input to Label 200
    unknown(0)[11756]: Input to Label 400
    unknown(0)[11756]: Input to Label 600
    unknown(0)[11756]: Input to Label 800
    Why this first 12 lines of output in above? and from where that 100 comes in betwen 0 and 10 every time?
    Expected Output ==>
    unknown(0)[11756]: Input to Label 0
    unknown(0)[11756]: Input to Label 200
    unknown(0)[11756]: Input to Label 400
    unknown(0)[11756]: Input to Label 600
    unknown(0)[11756]: Input to Label 800
    unknown(0)[11756]: Input to Label 1000
    These creates an issue because I want to add text labels to a line that is visible in the graph, and from the above outputs, I didn't able to understand which is visible line and which is not.
    I have a list of text labels that I want to assing to each line which is visible in the graph (This I can manage to do).


    Added after 44 minutes:


    By using below code, now its resolve, I'm getting expected output.
    Qt Code:
    1. plot->setAxisAutoScale(Qt::Axis::YAxis, false);
    To copy to clipboard, switch view to plain text mode 
    But their is little change in the output,
    Actual Output ==>
    unknown(0)[11756]: Input to Label 0
    unknown(0)[11756]: Input to Label 1000
    unknown(0)[11756]: Input to Label 200
    unknown(0)[11756]: Input to Label 400
    unknown(0)[11756]: Input to Label 600
    unknown(0)[11756]: Input to Label 800
    Here above 1000 is comming between 0 and 200. Which causing my string list little disturb.

    Expected Output==>
    unknown(0)[11756]: Input to Label 0
    unknown(0)[11756]: Input to Label 200
    unknown(0)[11756]: Input to Label 400
    unknown(0)[11756]: Input to Label 600
    unknown(0)[11756]: Input to Label 800
    unknown(0)[11756]: Input to Label 1000
    Last edited by npatil15; 29th November 2019 at 10:13.

Similar Threads

  1. change 'scale map' of QwtPolarGrid number!
    By sampad1370 in forum Qwt
    Replies: 2
    Last Post: 5th April 2016, 14:38
  2. scale in QwtSlider and QwtPlot
    By mastupristi in forum Qwt
    Replies: 3
    Last Post: 20th October 2014, 08:37
  3. How to hide part of a QwtPlot scale?
    By Momergil in forum Qwt
    Replies: 2
    Last Post: 6th February 2013, 20:41
  4. QwtPlot offset between Canvas and Scale
    By revellix in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2011, 14:31
  5. QwtPlotItem inverting qwtPlot scale
    By jmsbc in forum Qwt
    Replies: 1
    Last Post: 25th August 2009, 15:09

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.