I need to plot bar graphs, such that not all of them begin from the axis.
If i use QwtPlotHistogram, i can plot all data but starting from the axis.
I have attached an image showing how i want my plot to look.
Any suggestions?
Printable View
I need to plot bar graphs, such that not all of them begin from the axis.
If i use QwtPlotHistogram, i can plot all data but starting from the axis.
I have attached an image showing how i want my plot to look.
Any suggestions?
try overlapping the existing plot with another plot (disable its color)
Not sure if its a correct method But I got similar plot by doing this....
I have just an ordered array [y1,y2], unrelated to any x value
Then better implement your own type of plot item.
Derive from QwtPlotSeriesItem and use samples like this:
Code:
class YourSample { public: YourSample(); YourSample( const QwtInterval &, const QwtInterval & ); bool operator==( const YourSample & ) const; bool operator!=( const YourSample & ) const; //! Interval QwtInterval interval[2]; };
Then your series data object can return [ index - 0.5 , index + 0.5 [ as one interval and the other interval from your array.
Code:
class YourSeriesData: public QwtSeriesData<YourSample> { public: YourSeriesData( const QVector<QwtInterval> &intervals): m_intervals( intervals ) { } virtual size_t size() const { return m_intervals.size(); } virtual YourSample sample( size_t i ) const { QwtInterval interval( i - 0.5, i + 0.5, QwtInterval:: ExcludeMaximum); return YourSample( interval, m_intervals[i] ); } { double xMin = -0.5; double xMax = size() + 0.5; double yMin = ...; double yMax = ...; } };
Of course the code above is for vertical bars ( v.v. to your screenshot ).
Implementing the virtual methods for your plot item should be straight forward ( or copy and adopt your code from QwtPlotHistogram ).
Uwe