LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get THIN_STEP to start with a step

When plotting with VAL_THIN_STEP, the first part of the drawing is vertical.
For instance if I have:

Categ={5,2,1}
PlotWaveform (Pnl, PNL_GRAPH, Categ, 3, VAL_UNSIGNED_INTEGER,
1, 0, 0, 1,
VAL_THIN_STEP, VAL_NO_POINT, VAL_SOLID, 1, VAL_BLACK)

The plot starts with a vertical line from (0,5) to (0,2), then a horizontal line from (0,2) to
(1,2)

It doesn't make much sense for histograms where you want the first one to be drawn (0,5) to (1,5),
then (1,5) to (1,2)...

Is there a simple way around that ?
--
Guillaume Dargaud
http://www.gdargaud.net/
"The Earth is the cradle of Humanity. But one doesn't always live in the cradle." -
Konstantin Tsiokolvsky.
0 Kudos
Message 1 of 4
(2,678 Views)
With the example you gave, the only way I can think off would be to shift your data horizontally by one unit. So, for example, if instead of plotting (0,5) and (1,2), you'd plot (1,5) and (2,2). You'd be missing the first horizontal segment, but you can add a point at the beginning of the data -- in this case, (0, 5).

Admitedly, this solution is kind of clunky, and there might problems that I haven't anticipated. Do you really need to use step interpolation to display a histogram, though? Have you considered using a vertical bar plot?

Luis
NI
0 Kudos
Message 2 of 4
(2,678 Views)
Hi Guillaume,

The problem is that the way thin step is drawn, it does the vertical first, and then the horizontal. So, you would expect to get (0,5) (0,2) (1,2) as your drawn points. To get (0,5) (1,5) (1,2), add an extra value to the front of your array that is a copy of the first value and increment your array size by 1:

Categ = {5,5,2,1}
PlotWaveform (Pnl, PNL_GRAPH, Categ, 4, VAL_UNSIGNED_INTEGER,
1, 0, 0, 1,
VAL_THIN_STEP, VAL_NO_POINT, VAL_SOLID, 1, VAL_BLACK)

Then, you should see that it will go in the order of points that you would normally expect in a histogram. The reason is that from point 0 to point 1 (5 to 5), you show that there is no vertical movement, and so it will go across (0,5) to (1,5). Then from point 1 to point
2 (5 to 2), it will go down from (1,5) to (1,2), then across to (2,2), etc. Hope this helps!

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 3 of 4
(2,678 Views)
> [...] add an
> extra value to the front of your array that is a copy of the first
> value and increment your array size by 1:

Thanks that little trick works great.

(in response to LuisG, I can't use the vertical bar plot because there's more than one plot and
they overlap)
--
Guillaume Dargaud
http://www.gdargaud.net/
"What we need is either less corruption or more chance to participate in it."
0 Kudos
Message 4 of 4
(2,678 Views)