Results 1 to 9 of 9

Thread: how to set width of the bars in QwtPlotHistogram?

  1. #1
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default how to set width of the bars in QwtPlotHistogram?

    I'm using QwtPlotHistogram to plot data. I want to have a fixed size for the bars.
    What happens is, that the bars use the entire QwtPlot area, so if i have less bars they expand and fit to the whole area, and if i have lots of bars, they shrink and squeeze in the area.
    I want to keep constant width for the bars
    How do i do that?

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

    Default Re: how to set width of the bars in QwtPlotHistogram?

    A histogram displays ( x1-x2, y ) samples - this is not a bar chart. Maybe using a QwtPlotCurve in Sticks style is more what you are looking for.

    Uwe

  3. #3
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set width of the bars in QwtPlotHistogram?

    I want to plot a histogram, but want to be able to define the width of the rectangles...

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

    Default Re: how to set width of the bars in QwtPlotHistogram?

    Quote Originally Posted by penny View Post
    I want to plot a histogram, but want to be able to define the width of the rectangles...
    No you don't want to plot a histogram ( in the meaning of QwtPlotHistogram ) because in a histogram the width of the bars always corresponds to the x1-x2 interval on the x-axis !

    If you want to control the width of the bars independent of the x axis scale you want to display a bar chart.

    Uwe

  5. #5
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set width of the bars in QwtPlotHistogram?

    I think i'm not being able to write what i exactly want..
    on my x axis, i have 0,1,2,3,4,....10 and on y axis i have 0,10,20,30..100
    i want to plot
    Interval Value
    0-1 15
    1-2 30
    etc....
    the width of all rectangles should and will indeed remain constant...
    so my data is an array { 15,30,7,10,26,78,7 }
    The problem is this:
    If i give very few (say 5) values in the array, i get 5 rectanglesof a large width,
    If i give lots of (say 50) values in the array, i get 50 rectangles of tiny width
    The width of the rectangles increases or decreases according to the size of the data.

    I have attached 2 plots showing the difference, (my x axis is vertical left, and y axis is horizontal top)
    No matter what the size of my array, i want width of rectangles to remain same
    Attached Images Attached Images

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

    Default Re: how to set width of the bars in QwtPlotHistogram?

    Quote Originally Posted by penny View Post
    No matter what the size of my array, i want width of rectangles to remain same
    When both plots have the same y axis scales ( not visible on your screenshots ), then your data class returns different intervals depending on whatever.

    Uwe

  7. #7
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set width of the bars in QwtPlotHistogram?

    I'm sorry, but i don't understand what you mean..

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

    Default Re: how to set width of the bars in QwtPlotHistogram?

    QwtPlotHistogram draws the bars according to the axis scales. When you have different columns widths for 2 plots with comparable canvas sizes then there are only 2 possible reasons:

    - The axis scales are different
    - The intervals of the samples are different

    Uwe

  9. The following user says thank you to Uwe for this useful post:

    penny (5th January 2011)

  10. #9
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set width of the bars in QwtPlotHistogram?

    Thank You! I can manipulate it now using setAxisScale()
    Thank you for hearing me out patiently!!

Similar Threads

  1. QwtPlotHistogram
    By yers in forum Qwt
    Replies: 4
    Last Post: 5th January 2011, 07:23
  2. Replies: 4
    Last Post: 4th January 2011, 09:47
  3. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 09:58
  4. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  5. QtItemDelegate for progress bars
    By maxpayne in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 13:26

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.