There are situations where you need to show custom value labels on the X-Axis of an XY-graph. Such labels may be those for the orthogonal line projection to X-axis for discrete points of a line plot that are not uniformly spaced along the X-axis. The custom labels will need to be shown outside the plot area such that the plot's LabVIEW annotations feature may not be used on the same plot.
Forthwith, there will be a need to hide the built-in LabVIEW-generated axis labels and tick markers so that only the custom labels will show. An example of this scenario, as resolved, is shown in the front panel below:
Custom X-Axis Label Features of Note:
- LabVIEW built-in tick marks are not showing.
- LabVIEW generated axis labels, uniformly-spaced along the x-Axis and corresponding to vertical plot grid lines are not showing.
- Custom labels provided are staggered using alternating vertical offsets to allow label words to fit without overlapping with adjacent labels.
- Custom labels have tick marks of a vertical line of length corresponding to the staggered label offsets.
How to Achieve Staggered Custom Axis Labels:
This is done via the following steps:
STEP 1:Hide LabVIEW Built-in Tick Marks and Labels
For main plot, hide built-in tick marks and labels. Do this form plot’s graph properties by setting the axis style as one that does not show X-Axis tick marks and does not show labels. This will leave the X axis clean.
STEP 2.Add another XY plot object aligned with the X-Axis
Add another XY plot object below the X-axis of the main plot. Hide all XY grid lines by assigning them the color 'T' for transparent. Also, for this same plot object, clear both the vertical and horizontal ticks and labels by selecting the axis style as done in STEP 1.
This means that the added plot object must appear with a clear plot area where the custom labels will be added using LabVIEW’s plot annotation feature.
STEP 3.Be sure that Added Plot Object XMin and XMax coordinates match those of the main plot
Position and re-size the added plot object so that the X-Axis min and max limits spans along the same range as the one for the main plot object. This means that an X-position of an annotation on the added plot area will correspond to the same position on the main plot.
In this example the added XY-Plot object vertical scale spans from 0 to 100.
STEP 4.Add the Sample code provided here that contains the following functionality
The attached sample codes implements the custom labels as annotations and has following attributes:
- The X-Coordinate of the main plot defines the X-position of a corresponding label on added plot
- Labels (annotations) are staggered in the vertical position to allow space so that custom label words do not overlap with adjacent words
- Custom tick marks are added in the form of single vertical segmented plot line which show at each label position
- ‘NaN’ values are used to separate vertical line segments. So that these lines appear separate from each other while still remaining as part of the one line plot.
- The custom vertical line segment tick marks are of staggered vertical length, so that the lines conform to the staggered position of custom labels.