09-25-2026 12:09 AM
Dear colleagues,
I have a simple (maybe stupid) question about graphs in NI CVI.
My graph is “symmetrical” (it’s a simple PlotY graph where the X-axis is shifted by an offset), and I would prefer to have zero displayed in the middle.
Which attribute can I use to adjust this:
I tried adding a cursor at the zero position and played around with the attributes all morning, but that didn’t help.
Any idea how I can fix this and make it look perfect (in generic way, the range could be differ from run to run)?
Thank you in advance.
Solved! Go to Solution.
09-25-2026 07:05 AM
It appears as if your graph is in autoscale mode in the X-Axis. If this is true, then you could try setting it to manual mode, calculate the appropriate range and set it to the axis before plotting the values.
09-28-2026 04:00 AM
Looking at your first picture, I suppose the value of 2 in the middle depends on some rounding on actual values. You could probably fix it with this code:
// Calculate actual range
MaxMin1D (array, nElements, &maxVal, &maxIdx, &minVal, &minIdx);
// Round to the next group of ten
max = Max (ABS_VAL (minVal), maxVal);
max = (ceil (max / 10.0)) * 10.0;
// Apply the range to the graph X-axis
SetAxisScalingMode (panelHandle, PANEL_GRAPH, VAL_BOTTOM_XAXIS, VAL_MANUAL, -max, max);
Max and ABS_VAL macros are part of the Programmer's Toolbox, defined in toolbox.h.
09-28-2026 04:51 AM
@RobertoBozzolo wrote:
Looking at your first picture, I suppose the value of 2 in the middle depends on some rounding on actual values. You could probably fix it with this code:
// Calculate actual range MaxMin1D (array, nElements, &maxVal, &maxIdx, &minVal, &minIdx); // Round to the next group of ten max = Max (ABS_VAL (minVal), maxVal); max = (ceil (max / 10.0)) * 10.0; // Apply the range to the graph X-axis SetAxisScalingMode (panelHandle, PANEL_GRAPH, VAL_BOTTOM_XAXIS, VAL_MANUAL, -max, max);
Max and ABS_VAL macros are part of the Programmer's Toolbox, defined in toolbox.h.
09-29-2026 02:07 AM
I asked google AI how to set the x markers
void InitializeSymmetricGraph(int panel, int control, double n) {
SetAxisScalingMode (panel, control, VAL_BOTTOM_XAXIS, VAL_MANUAL, -n, n);
// 10 Intervals create 11 ticks, 6th tick is at 0.0
SetCtrlAttribute (panel, control, ATTR_XDIVISIONS, 10);
}
Disclaimer: I have no LabWindwos/CVI installation, so I can not verifiy if this will work or if these parameters are real. I had to ask AI if ATTR_XNUM_DIVISIONS is correct, which obviously is not.
At least there is a help entry for ATTR_XDIVISIONS: https://www.ni.com/docs/de-DE/bundle/labwindows-cvi/page/cvi/uiref/cviattrxdivisions.htm
09-30-2026 01:29 AM
@UliB wrote:
I asked google AI how to set the x markers
void InitializeSymmetricGraph(int panel, int control, double n) { SetAxisScalingMode (panel, control, VAL_BOTTOM_XAXIS, VAL_MANUAL, -n, n); // 10 Intervals create 11 ticks, 6th tick is at 0.0 SetCtrlAttribute (panel, control, ATTR_XDIVISIONS, 10); }Disclaimer: I have no LabWindwos/CVI installation, so I can not verifiy if this will work or if these parameters are real. I had to ask AI if ATTR_XNUM_DIVISIONS is correct, which obviously is not.
At least there is a help entry for ATTR_XDIVISIONS: https://www.ni.com/docs/de-DE/bundle/labwindows-cvi/page/cvi/uiref/cviattrxdivisions.htm
Yes, thank you, that does the job. It is exactly the attribute I was looking for. I was sure something like it existed for the scale, but I overlooked the Divisions setting. Sometimes I can't see the forest for the trees: