From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Axis Graph

Question:

How can I create a graph (x-y, chart, etc) that has
multiple Y-Axis' on the same graph.

Ie, Temperature on the left Axis' and Voltage on the Right Axis,
each axis has it's own scaling.

Thanks.

Miriam
0 Kudos
Message 1 of 6
(3,974 Views)
Glasscock wrote in message
news:8rn1bb$nd7$1@slb6.atl.mindspring.net...
> Question:
>
> How can I create a graph (x-y, chart, etc) that has
> multiple Y-Axis' on the same graph.
>
> Ie, Temperature on the left Axis' and Voltage on the Right Axis,
> each axis has it's own scaling.

With difficulty.

You can put a second transparent XY plot over the first, which allows you
(if you use attribute nodes to lock the X scales together) to have a
"multilayer" plot with independent Y axes. However I've found no way of
moving the axis scale from the left side to the right, though you can of
course hide the Y axis scale.

Someone a while back posted a rather nice set of VIs that allows you to
create a Y axis scale with great flexibility within a picture indicator,
which could then manually be positioned on either side. I guess you'd have
to kill the Y labels of both graphs and replace both sides with one of these
picture indicators, to keep a consistent appearance. You'd then have to make
sure the bounds of the generated Y scale match the values used in the two XY
plots. Messy, but doable- though it would be best to set the bounds of the
XY plots and the labels yourself so they don't change every time you update
the graph.

Another option, perhaps more involved, is to modify the version of the XY
plot that comes with the picture toolkit. This generates the whole of an XY
plot, including axes and data, within a single picture indicator. In
principle you could start with these and create a version that has multiple
layers with different axes for each layer- you could even add the option to
have, say, 4 or more different Y axes, two on each side with colour coding
to indicate which data is associated with which axis. And you could have
user definable datapoints. Once you start this low down the possibilities
are pretty interesting. This would take a lot more time than the overlaid XY
plots though and the elegance of the finished function probably won't
warrant the time spent.

It would be cool though 😉

Actually, a pretty simple option I've just tried that seems to work well is
to use three stacked plots.

Create the first XY plot and set it to the size you want. Make sure you pull
the plot in a bit from the right hand side of the indicator and it helps to
have a visible grid. Name this something to indicate it's the bottom plot,
tied to the left axis. Then make two copies of this indicator. On the first,
disable X autoscaling, hide both axes, name it something representative then
hide the label, hide the legend and make the plot area and the control
background transparent. All you can now see are the gridlines. Position the
second plot over the first such that the gridlines exactly overlie each
other. You can hide the gridlines later through attribute nodes, if need be-
they're just useful at the moment for making sure both graphs are exactly
aligned.

On the second copy, hide the X axis but keep the Y axis. Change the
formatting of the Y axis so only the numbers are visible- no tick lines.
Reduce the width of the indicator as far as you can without losing the
numbers, make it transparent again and position it as the right Y axis of
your composite chart.

To use it, write data into the first two plots, and every time you write,
use attribute nodes to read the X scale of the bottom layer and write this
to the X scale of the top layer, and read the (invisible) Y scale of the top
layer and write this to the visible Y scale of the third, dataless layer.

There's two limitations to this approach;

1) No little tick lines on the right Y axis- since they can't be set to lie
on the left of the numbers
2) Legends are slightly challenging.
0 Kudos
Message 2 of 6
(3,974 Views)
I have done this by using two graphs on top of each other the top one has to
be transparent and it pays to position them using attributes although I dont
remember getting the axis on the right, might have to use a third graph in
which only the axis is visible.

Jim


"Glasscock" wrote in message
news:8rn1bb$nd7$1@slb6.atl.mindspring.net...
> Question:
>
> How can I create a graph (x-y, chart, etc) that has
> multiple Y-Axis' on the same graph.
>
> Ie, Temperature on the left Axis' and Voltage on the Right Axis,
> each axis has it's own scaling.
>
> Thanks.
>
> Miriam
>
>
>
0 Kudos
Message 3 of 6
(3,974 Views)
I heard rumours ages ago that this was one of the things being addressed in
version six. Presumably it wasn't then?!

"penguin" wrote in message
news:39dfc256$1@news.actrix.gen.nz...
> I have done this by using two graphs on top of each other the top one has
to
> be transparent and it pays to position them using attributes although I
dont
> remember getting the axis on the right, might have to use a third graph in
> which only the axis is visible.
>
> Jim
>
>
> "Glasscock" wrote in message
> news:8rn1bb$nd7$1@slb6.atl.mindspring.net...
> > Question:
> >
> > How can I create a graph (x-y, chart, etc) that has
> > multiple Y-Axis' on the same graph.
> >
> > Ie, Temperature on the left Axis' and Voltage on the Right A
xis,
> > each axis has it's own scaling.
> >
> > Thanks.
> >
> > Miriam
> >
> >
> >
>
>
0 Kudos
Message 4 of 6
(3,974 Views)
Oh yes. The graph in LabVIEW 6i allows you to create as many X and Y
scales as you like.

Kyle
Kyle Gupton
LabVIEW R&D
National Instruments
0 Kudos
Message 5 of 6
(3,974 Views)
[posted and mailed]

nyko320@yahoo.com (Glasscock) wrote in
<8rn1bb$nd7$1@slb6.atl.mindspring.net>:

>Question:
>
>How can I create a graph (x-y, chart, etc) that has
>multiple Y-Axis' on the same graph.
>
>Ie, Temperature on the left Axis' and Voltage on the Right Axis,
>each axis has it's own scaling.
>


This is addressed in the LabVIEW FAQ at

http://www.icon-tech.com.au

--

Alexander C. Le Dain, PhD
ICON Technologies Pty Ltd
http://www.icon-tech.com.au
0 Kudos
Message 6 of 6
(3,974 Views)