LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lining up zero position on graphs with multiple scales & auto scale

Solved!
Go to solution

Hello!

 

I'm hoping this is a quick one - but google searches and browse of the forums turned up nothing.

 

I have a graph with two scales - one for position and one for velocity (which can obviously differ significantly from each other). What I want to be able to do is to have the graph/scales auto-scale - but for the 0 position to remain in the centre of the graph. With the 0 point of the scales in different places it makes the graph very difficult to understand at a quick glance.

 

If you see the attached screenshot - the two 0 positions are in different places.

 

Is it possible to have auto-scale, but for the zero to stay in the centre of the graph for both scales?

 

Many thanks in advance,

Sam


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 1 of 6
(2,691 Views)

No. I'd be freeking if I ws the devloper that had to code that.

 

Work-around....

 

Shut-off auto-scale.

 

Before each update, defer FP updates.

 

after each update do a "Autoscale once now" and then get the max and min an whichever is large set it for the max in the other direction.

 

underfer updates.

 

lather rinse repeat.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 6
(2,679 Views)
Solution
Accepted by topic author Sam_Sharp

(As far as I know) you can't do it with Auto-Scale.

 

Turn off autoscale, then manually set the range to be symmetrical about zero for each scale.

 

Find the maximum of the absolute value of each plotted array.  Then set the range to + and - this value.  (in the example below, I made it a loose fit by multiplying by 1.1).  Since you have more than one Y-axis scale, you have to loop through to address each one at a time.  First you have to tell it which Y scale you're setting, then, set the values.

 

autoscale.jpg

Another option would be to have the zeros line up, but not have the scale be symmetrical around them.  You can do that too, it just takes a bit more math.  Let me know if that's what you'd like.

0 Kudos
Message 3 of 6
(2,675 Views)

Oops, hold on a second.  Now that I look at this, it doesn't quite look right.  I got one scale to go from -23 to +23, and the other to go from -1 to 1... and the zeros line up, just like you wanted....

 

But the graphs themselves don't look right.  The white line should look flatter than the red line because it's got the same amount of randomness, but is plotted on a larger scale.

autoscale.jpg

Give me a couple of minutes to get that sorted out.

0 Kudos
Message 4 of 6
(2,669 Views)
Spoiler
Right-click the plot and associate it with the proper scale. Can also be done with property nodes if you wnat.

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 6
(2,667 Views)

That does make a bit of a difference, doesn't it? :manwink:

 

Here we have two plots.  Each is the same random signal from 0 to 4.  One of them has been shifted by +20.   The scales line up at zero, and the red one appears wider because it's plotted on a smaller scale.

autoscale.jpg

0 Kudos
Message 6 of 6
(2,665 Views)