LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Axes Scaling for XY-Graph with two x-axes

I have some wavelength data [which comes in units of nanometres] and want to plot it in units of electronvolts.

Specifically, I want two x-axes on my XY-Graph, the bottom one in units of eV (increasing from left to right) and the top one in units of nm (therefor decreasing from left to right).

 

I can not for the life of me get the top axes to show the correct scaling. Whatever I make the bottom axis is displayed correctly, but then I have to calculate what exactly the top axis scale looks like. I do this and set it with the Offset and Multiplier property, but it doesn't work.

 

Please see the attached picture and vi.

The picture shows some mock data with a correct bottom x-axis (in eV) but wrong top x-axis (in nm; should be about 730 to 520 from left to right).

 

wrong top axes scalingwrong top axes scaling

 

Please note that here I use the (very good) approximation to convert nm to eV : [eV] = 1240/[nm]

0 Kudos
Message 1 of 5
(1,160 Views)

sorry i can not edit my above post. here's a block diagram snippet of the attached vi...image.png

0 Kudos
Message 2 of 5
(1,122 Views)

Hi doug,

 


@dougbock wrote:

sorry i can not edit my above post. here's a block diagram snippet of the attached vi..image.png


Please don't call it a "snippet" when you attach a simple image! Snippets are some special kind of image with respect to LabVIEW…

 

On your problem: have you tried to set the XAxis.Range property? It allows to set the increment between the min/max of the range: you also need to change it according to your scaling factor!

(For a quick improvement it might help to hide the grid lines for that 2nd X axis…)

 

Btw. this LinSpace VI can be replaced a simple Ramp function call. (It comes with LabVIEW and is [more] bug-free than your VI: when I request N points "including the endpoint" then I don't want to get N+1 points…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(1,104 Views)

FYI to create an actual snippet, highlight the code you want to copy (in your case, all of it) then click Edit -> Create VI Snippet from selection. Upload that, and it'll actually contain the code within it and we can just drop it into LabVIEW on our end. Using that trick gives it some voodoo magic to contain actual LV code within an image.

0 Kudos
Message 4 of 5
(1,096 Views)

Thank you for your feedback, @GerdW and @BertMcMahan, I have incorporated your suggestions. Ultimately what helped was first plotting the data on the bottom x-axis, then grabbing the scale bounds from that, convert these bounds back to nm, and finally apply them to the top axes (in reverse order, i.e. eV_min becomes nm_max etc.)

snippet.png

0 Kudos
Message 5 of 5
(1,073 Views)