LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Bar Graph

I'm having a problem with the bar braph I am plotting. I"m calling PlotY() in the following way:
   
PlotY(history_fault_graph_panel,
      ANALYSIS,
      arrayPtr,
      3,
      VAL_INTEGER,
      VAL_VERTICAL_BAR, 
      1,
      VAL_SOLID,
      1,
      VAL_BLUE);
 
I am trying to vary the width of the bar graph. Currentnly, the graph area is divided into 3 areas with bar graphs that
are very thick. Also, the 3rd point on the X-axis is at the rightmost edge of the graph panel, causing the 3rd bar graph to have half the width than the other two.  
Is there any  way to fix this?
All help is highly appreciated.
Thanks.
0 Kudos
Message 1 of 6
(3,817 Views)

Hello swati505,

When you plot using vertical bars, the center of the vertical bar is going to map to the values in your plot array.  Having said that, the left and rightmost edge of the vertical bar is going to expand to the left and right of the value you passed in the plot array.  If you don't set the range of the X axis to account for this, the full width of the left and rightmost bars are not going to be displayed.

So you should manually set the range of the X axis to be larger than the number of data points to be plotted.  This allows for extra space on the left and right of the graph so that those bars will be completely displayed.  i.e. If there are 4 data points, the range of the X axis should be -1 to 4 instead of 0 to 3.

Hope that helps.

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 6
(3,801 Views)
Hi Wendy,

Thanks for your response. I have added the code to call  SetAxisRange()  so the bar graph does not
get truncated.
I still have one more issue though with the width of the bar graph. It is very large.
As I plot more points on the X-axis, the width decreases but I want to keep the width
of the bar graph constant. I am attaching a screen shot.
Please let me know how I can fix this.

Thanks,
Swati

0 Kudos
Message 3 of 6
(3,786 Views)
Hello Swati,
 
The width of the vertical bar is going to be dependent on the number of data points plotted and the x axis range.  So there isn't a property to directly control the width, short of increasing the x axis range.
 
Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 4 of 6
(3,749 Views)

Hello Swati

If you're only planning on plotting a handful of points (such as 3) you might want to look into plotting individual rectangles (using the PlotRectangle function) instead of using PlotY. This will allow you to control the exact width of the individual bars.

Luis
NI

0 Kudos
Message 5 of 6
(3,743 Views)
Hi Swati.

Here's a _slightly_ messy approach which I think comes close to meeting your requirements, and requires only a single plot:
  • Insert some "dummy" (zero value) elements into your Data array, one or more at index zero, the same number at the end, and a fixed number (0,1,2...) between consecutive "real" data points; this number depends on how many data points you have, and how fat you want your bars.
  • Call PlotY() to display your Data.
See the attached .jpg, showing 3 "real" data points in a total of 9 points.

Regards,
Colin.

Message Edited by cdk52 on 08-17-2005 10:08 AM

Message Edited by cdk52 on 08-17-2005 10:16 AM

0 Kudos
Message 6 of 6
(3,742 Views)