Showing results for 
Search instead for 
Did you mean: 

How to programmatically align Y axis labels in a plot stack?

Go to solution

Hello all!

I have a vertical stack of XY plots, and I am struggling to get the Y Axis labels to align vertically down the stack. I know this is a nit pick, but I know a user or two will complain if I can't align the labels. Here is the very worst of it, I once solved this problem on a project a few years ago, but my old brain can't remember how, and I don't have access to that source code.


Here is my plot stack:
Plot StackPlot Stack



Notice how the Y-axis name labels move left and right depending on the width of the y-axis scale number widths.


I tried making the Y axis scale font monospaced with spaces padding on the left, but the width of the spaces is narrower than the width of the numbers so that didn't work. (it does work when padding zeros, or using scientific notation, but that detracts from readability, and it is all about readability for this project)


I tried using the YScale.NameLbl.Position property, but oddly, setting the top position works, but setting the left position does not. (Example of the property not working is attached)


Any help would be appreciated!!

0 Kudos
Message 1 of 3
Accepted by topic author ChrisLudwig

Hi Chris,


Have you tried with the font named "Consolas" ?

Then by setting the markers' format to e.g. "%4.0f", you can easily control their width.




Message 2 of 3

I had tried Consolas, but I made the mistake of not also switching from auto format to manual so it really did nothing to help me. I got it applied correctly based on your post and I'm quite happy with the result now.


I added a bit of logic on graph rescale events to keep walking the format string down as the zoom gets tighter. I'm quite happy with the result:


Aircraft State Plot Stack_2023-07-17_18h_07m_53.314s.png



Here is the block diagram of the VI that modifes the format as scale is changed: 

Format Y Axis.JPG


Obviously the scaling thing is a matter of taste, but I was pretty happy with this level of effort for my application. I attached the VI that formats the string based on the current scale range.




Message 3 of 3