LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to highlight a part of a graph?

Hi,
I want to highlight a part of a graph. How can I do it programmatically just by giving the sample numbers of the signal ( the x coordinates of the graph) ?
Thanks,
--
Burcu
Message 1 of 5
(3,568 Views)

Hello Burcu,

what exactly do you mean by 'highlight a part of the graph' ?

If you would like to highlight a part of the plot, you could do this by plotting a part of this plot on top of the plot in another color. Suppose you plotted an array "y_data" of floating point members:

PlotY (pnlHandle, PNL_GRAPH, y_data, y_array_size, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_RED);

Then you could replot a part of this y_array in another color:
PlotY (pnlHandle, PNL_GRAPH, y_data + start_point, end_point - start_point , VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_YELLOW);

Is this what you are looking for? If not, don't hesitate to reply Smiley Happy

 

--- just corrected a type-o---

Message Edited by Wim S on 05-16-2007 03:10 PM

0 Kudos
Message 2 of 5
(3,566 Views)
Hello Wim S,
Actually, I was looking for a method for changing the background color of the given part of the graph. But it doesn't matter, also it can be like this as you've given which changes the color of the plot.
But there is a problem; when we call the second PlotY function, it is plotting the given subset of the graph from the beginning ((0,0) point) of the previous graph. But the part of the graph which we wish to change the color can be in the middle of the whole graph. How can we solve this problem?
Thanks,
--
Burcu
0 Kudos
Message 3 of 5
(3,558 Views)

Hello Burcu,

Sorry, I didn't think of that problem Smiley Sad

I see two solutions:

 1 - Use the PlotXY function instead of the PlotY function. Therefore you will have to create an x_data array, containing values from 0 up to the size of the y_data array. When plotting the highlight plot, also use PlotXY and specify the same offset:

x_data = malloc (y_array_size * sizeof(int));
for (counter = 0; counter < y_array_size; counter++)
          x_data[counter] = counter;
PlotXY (pnlHandle, PNL_GRAPH, x_data, y_data, y_array_size, VAL_INTEGER, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_RED);
PlotXY (pnlHandle, PNL_GRAPH, x_data + start_point, y_data + start_point, end_point - start_point, VAL_INTEGER, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_YELLOW);
free (x_data); 

 2 - Use the top X axis for the highlight plot, setting the start_point value as the top X axis offset. Make sure that this axis is not visible in the User Interface.

Hope this helps...

Message Edited by Wim S on 05-16-2007 03:47 PM

0 Kudos
Message 4 of 5
(3,558 Views)
Hello Wim S,
Thanks for the solutions. Using the PlotXY function is reasonable, also the top x axis can be used for this purpose. .:)
And also I have thought of a solution: A new array can be created and only the parts which will be highlighted can be assigned from the previous array, and the other values can be made zero. 🙂
I will try all of these methods, and I will choose the one which reveals the trick less..:)
Thanks so much for your help,
--
Burcu
0 Kudos
Message 5 of 5
(3,547 Views)