LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

creating a bar graph...

Solved!
Go to solution

...two questions, one presumably simple, and the other a bit tricky:

 

1. The graph is to show 64 points on the X axis. How do I specify the "fatness" of my bars?

2. The boss says he wants every other value colored differently: red-blue-red-blue-red-blue...is there a way to do this?

 

What I'm actually plotting is 32 complex numbers. He wants the real component in one color, and the imaginary in another. So, 32 points of 2 values each is my 64 points total. 

 

Thanks for any assistance.

0 Kudos
Message 1 of 20
(4,051 Views)

1) I think you can't. Few years ago I have submitted a feature request here. You are invited to support it by giving it a kudos

 

2) Not directly. You could use two plots, one in red, one in blue. Or, with more effort, addressing both issues, you could use PlotRectangle....

Message 2 of 20
(4,051 Views)

Well...that's a bit unfortunate. How does this sound:

 

I'm thinking of having an expanded data array, in which each of my points occupies, say, 5 elements in the array. I guess I'd have to throw in a few empties between them, too, to provide some gaps. So, if my data array were:

 

[100, -1234, 1911...]

 

the array I'd pass to PlotX would be like:

[100, 100, 100, 100, 100, 0, 0, -1234,-1234,-1234,-1234,-1234, 0, 0, 1911, 1911, 1911, 1911, 1911...]

 

To get the bi-color effect, I suppose I'll have to change the gap sizes, and just overlay the two plots, right?

 

Any thoughts on this? I don't imagine the performance hit would be too terrible (at least for my purposes).

0 Kudos
Message 3 of 20
(4,047 Views)

Update: for whatever reason, I was totally unable to get any variations on PlotX() to work for me. Here's one form of the call that I tried:

 

	plotHandle = PlotX(PANEL_MAIN, 
						PANEL_MAIN_TAPS_PLOT, 
						plotArray, 
						nbrPoints,
						VAL_INTEGER,
						//VAL_FAT_LINE,
						VAL_VERTICAL_BAR,
						//VAL_BASE_ZERO_VERTICAL_BAR,
						VAL_SOLID_SQUARE, 
						VAL_SOLID,
						1,
						VAL_RED);
	rc = RefreshGraph(PANEL_MAIN, PANEL_MAIN_TAPS_PLOT); 
						

 If anyone sees anything wrong with it, I'd appreciate a heads-up. I implemented a solution with rectangles that is adequate for now, but I'd still like to get the above code fixed.

 

Thanks.

0 Kudos
Message 4 of 20
(4,039 Views)
Solution
Accepted by topic author mzimmers

Shouldn't you call PlotY instead of PlotX?

Alternatively, if your graph is not autoscaling you may simply be missing the bars because they are out of visible range.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 20
(4,032 Views)

Oh, brother...I just love making stupid mistakes like that. Of course you're right, Roberto, and it works fine now. Sheesh...

 

I still don't like the 1-pixel wide "bars" though, and I think I'll use my rectangles instead. But thanks for furthering my CVI education a bit.

0 Kudos
Message 6 of 20
(4,022 Views)

With reference to the bar thickness, it appears that the graph is a "smart control" Smiley Wink : it adapts bar width to actual data plotted.

Specifically, it appears that thickness is related to number-of-bars / axis-width ratio.

 

See this picture: the same CVI example with 100 and 10 data points plotted.

 

VerticalBarGraphs.png

 

(Note: with thick bars you may have to struggle a bit to have the correct X scale shown. In the 10-samples example above, I enabled label strings for the graph X axis, used a scale of -0.5 to 9.5 and created the appropriate labels for integer values)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 20
(4,013 Views)

Thanks, Roberto. I guess the "smartness" in the control is something of a mixed blessing. I allowed enough space for the bars to be considerably wider than they were representing, so it appears that there has to be some threshold (which I didn't get to) of width in the plot area before CVI re-sizes the bars for you.

 

No matter, really, as the rectangles seem to be fine.

0 Kudos
Message 8 of 20
(3,999 Views)

Can you attach a picture of your graph with vertical bars inside so that we can look at how they appear?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 20
(3,983 Views)

Sorry it took me so long to reply -- I've been stuck in TCP purgatory the last couple of days.

 

I guess they're not really too thin; I was just hoping for a little less space between the lines:

 

sin.jpg

0 Kudos
Message 10 of 20
(3,967 Views)