LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labelling graph

Hi Roberto,

Sorry to bother you again. I am still having trouble labelling the lower and upper bounds of the graph. I looked at the attachment...did the same but my lower value doesnt seem to b showing. I step through it and found out that the line where i calculate PixelsPerUnit /= (max - min); is zero...i dont knw why....but the max and min values are 18667 and 0 respectively......so when i am labelling the lower value i use...

 PlotText (edge_handle, Graph[head_sel_index], hot_1_avg - 0.25 - (double)len / PixelsPerUnit, 1.0, msg, VAL_APP_META_FONT, VAL_BLACK, VAL_TRANSPARENT);

if i get rid of  "(double)len / PixelsPerUnit" i get the value bt its inside the inner bar(red bar in ur plot from the left)... i would like it to b outside the red bar jus like its done for the upper bound.

hope to hear from you soon.

Thanks

k1_ke

0 Kudos
Message 11 of 25
(2,771 Views)
This may happen if (max - min) > (plot area width): in this case, since PixelsPerUnit is an integer, dividing it by a number greater than itself always returns zero.
 
In this case you may define PixelsPerUnit as a double and calculate it accordingly so that the result of the division can be 0,xxxx:
 
 int  len, width;
 double min, max, x1 = 1750.25, x2 = 3417.0, PixelsPerUnit = -1.0;
 //....
 // Characteristics of the graph
 GetAxisScalingMode (panelHandle, PANEL_GRAPH, VAL_BOTTOM_XAXIS, NULL, &min, &max);
 GetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_PLOT_AREA_WIDTH, &width);
 
// How much pixels per unit on the X axis?
 PixelsPerUnit = (double) width / (max - min);


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 12 of 25
(2,767 Views)

Hi Roberto,

Thanks a lot! it worked out great!

k1_ke 

0 Kudos
Message 13 of 25
(2,762 Views)

Hi Roberto,

I yet again hv another question for you. Now i was wondering if u can help with labelling the max n min values in this graph on the left y axis....refer to the jgep file attached....below is what i do...

MaxMin1D (&array[0], (loop+len_index)/2, &cold_thres, &cold_index,&hot_thres, &hot_index);

SetAxisScalingMode (video_handle, VIDEO_GRAPH, VAL_BOTTOM_XAXIS,VAL_MANUAL, 0, (loop+len_index)/2);

PlotXY (video_handle, VIDEO_GRAPH,X , RxData.IVals, (loop+len_index)/2,VAL_UNSIGNED_INTEGER, VAL_UNSIGNED_SHORT_INTEGER,

VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

i jus want to display the range from 0 to 17000 and then the max n min on the left y axis....Also can u let me knw hw i can set the zoom feature on this graph....

thanks alot..

k1_ke

0 Kudos
Message 14 of 25
(2,724 Views)
If you want to display ONLY 0, full-scale, min and max labels on the Y axis you must use label string on the Y axis. Label strings permits you co create your own custom scale, that is a lista of lable-value pairs to display along the axis. The label string can be eanbled in the UIR editor while defining the aspect of the axis, the same as zooming and panning on the graph ("Enable zooming" check mark in the Edit graph panel).
 
For an example on how to use label strings on a graph I suggest you take a look at timeaxis.prj example in your CVI directory. For zooming look at graphcursors.prj example.


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 15 of 25
(2,723 Views)

Thanks yet again Roberto

It worked out great.

k1_ke

0 Kudos
Message 16 of 25
(2,717 Views)

Hi guys,

I was wondering if someone can help me out with labeling the graph....i use PlotY() to plot a graph....the x axis has a label as i know the max n use autoscale but i want to change the lable say previous if x was from 0-100 i want the label to show 0-1000 but without changin the graph....i tried using SetAxisScalingMode() and InsertAxisItem() they both change the scale thus the change is altered.

Is there a way i can go round this.

thanks

k1_ke

0 Kudos
Message 17 of 25
(2,658 Views)
If I understand you correctly, you want to change the range of the x-axis without affecting the plots that you have already plotted.

You can do one of two things:

1. You can change the units in the graph, by factors of 10. For example, let's say you wanted to plot Hz instead of KHz. In that case, let's say you would want the range to change from 0-10 to 0-10,000. The way you would do that would be to use the following code:

    SetCtrlAttribute (panel, control, ATTR_XENG_UNITS, -3);

2. You can change the offset and gain of an axis. That allows you to plot raw unscaled data, but display it as if it were scaled. For example, let's say your plot data ranges from 0 to 100, but the data really represents values that range from 1000 to 5000. The way you would display it would be by shifting the axis by 1000 units, and scaling it by a factor of 40, using the following code:

    SetCtrlAttribute (panel, control, ATTR_XAXIS_OFFSET, 1000);
    SetCtrlAttribute (panel, control, ATTR_XAXIS_GAIN, 40);

Hope this helps.

Luis
NI


0 Kudos
Message 18 of 25
(2,650 Views)

Hi Luis,

Thanks for the reply. Yeah it worked out great.

thanks

k1_ke

0 Kudos
Message 19 of 25
(2,640 Views)
Hi Luis,
 
I have a quick question, i use  SetCtrlAttribute (panel, control, ATTR_XAXIS_GAIN, 40); to solve my problem.....i was wondering if i can do some rounding off here....say eg instead of displaying 27996 to display 28000...round it to the nearest 1000's.....is there any way?
 
looking forward to hear from you.
 
Thanks
 
k1_ke
0 Kudos
Message 20 of 25
(2,607 Views)