Results 1 to 2 of 2

Thread: qwtPlotHistogram negative index

  1. #1
    Join Date
    Apr 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qwtPlotHistogram negative index

    Hi everyone

    I am attempting to build Histogram using the qwtlotHistogram class.

    However, my source data to generate the histogram contains negative values, therefore I am interested in the bins of the histogram to go from say -100 to +100.

    The code below Works as long as my variable "min" us equal or grater to zero since QVector takes no negative indexes.

    Is there a way to:

    1 - Feed histogram data to qwtPlotHistogram with negative bin index values?
    2 - I attempted to change the qwtPlot X axis either by using "setAxisScale" or generating a QwtScaleDiv and QwtScaleDraw but it only shifts the qwtPlot canvas and my histogram does not correspond to the modified axis.

    Any suggestions are appreciated.

    Thank you,
    Sergio

    QwtPlotHistogram *eHisto = new QwtPlotHistogram(title);
    eHisto->setStyle(QwtPlotHistogram::Columns);

    QVector<QwtIntervalSample> samples(size);// vector of interval samples

    for ( int i = min; i < max; i++ )
    {
    QwtInterval interval(double(i), i + 1.0);
    interval.setBorderFlags(QwtInterval::ExcludeMaximu m);
    samples[i] = QwtIntervalSample(histogram->GetFrequency(i), interval);
    }

    QwtIntervalSeriesData *data = new QwtIntervalSeriesData;
    data->setSamples(samples);
    eHisto->setData(data);

  2. #2
    Join Date
    Apr 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtPlotHistogram negative index

    Hi everyone

    The above obviously is fixed with the correct definitions of QwtInterval in the first line in the FOR statement loop

    QwtInterval interval(double(min+i), double((i+min)+1.0), QwtInterval::ExcludeMaximum); // min yes, max no (e.g. -1024 (OK), -1023(no go))

    Thank you,
    S

Similar Threads

  1. QwtPlotHistogram question
    By fantom in forum Qwt
    Replies: 3
    Last Post: 28th March 2013, 09:43
  2. Cannot find QwtPlotHistogram class
    By gabe.ayers in forum Qwt
    Replies: 3
    Last Post: 8th February 2011, 23:51
  3. Replies: 8
    Last Post: 5th January 2011, 11:51
  4. QwtPlotHistogram
    By yers in forum Qwt
    Replies: 4
    Last Post: 5th January 2011, 07:23
  5. Replies: 4
    Last Post: 4th January 2011, 09:47

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
  •  
Qt is a trademark of The Qt Company.