Can I setup the same values on both axes of a graph?

Definitions of graphs you want to share with us

Moderator: Mattk

Post Reply
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Can I setup the same values on both axes of a graph?

Post by wfpost »

Hi,

is there a switch that allows to have same values on the left and right axis of a graph.

e.g. the graph attached showing the wind.
I´d like to have the same values for both axes
I want the right axis using the same values as the left one for the first sensor .

The manual setting of minmum/maximum in the settings menu is not suitable as long I have to use fixed numbers there.

Only helpful if I could enter there some variable like (max. value of sensor x + 1) and not a fixed value which leaves the graph to small or too large:(

Thanks,
Wolfgang Image
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re:Can I setup the same values on both axes of a graph?

Post by admin »

You can do that by making use of the gnuplot format command feature

Image

set y2tics mirror
copies the tics and numbers from the left y-axis to the right.

set format y2 "%.1f °C"
sets the format string for the numbers on the right y-axis.
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re:Can I setup the same values on both axes of a graph?

Post by admin »

This is the result

Image
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Re:Can I setup the same values on both axes of a graph? ** s

Post by wfpost »

Thanks, but because I want two different display types that won´t do it for me.

Can I set the maximum value of both y-axes dependant on the sensor value in a given period?
Let´s say my maximum current temp. is 24°C.

Is there a format command allowing me to set the maximum value of the y-axis to like 24+2, where 24 is a variable and not fix, because it depends on the current numbers the sensor is sending?

In other words, is there a possibility to set the maximum value of the y-axis depending on the variable maximums as a function from x?
That would be great.
Cheers,
Wolfgang Image
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Re:Can I setup the same values on both axes of a graph? ** s

Post by wfpost »

maybe the attached graph explains why I want that.
Sometimes the two graphs are out of synch, because the two y-axes have different maximums. I want them to be the same.

Image
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re:Can I setup the same values on both axes of a graph? ** s

Post by admin »

From my point of view the mirror thing just makes sense when both curves are defined for the same axis (both on the left as in my example). Normally the right y-axis is just making sense when you have another measurement unit to draw a graph for.

I don't know of a gnuplot command that can set y ranges dependent from maximum values in the graph.
sevenless
Gold Boarder
Gold Boarder
Posts: 160
Joined: Wed Jul 02, 2008 7:35 pm
Location: Seattle WA, USA

Re:Can I setup the same values on both axes of a graph? ** s

Post by sevenless »

While creating some graphs for my station, I stumbled upon a "cheat" for fixing this graph problem.

For multi-line graphs, imagine that GNUplot draws a series of single-line graphs and then stacks them atop each other to produce the final result. Before the drawing begins, meteohub provides information to the program telling it where to set the minimum and maximum for that axis, and the plotting program uses that information to set the axis for ALL graphs drawn on that side.

Because GNUplot draws lines in sequential order on each graph, this means for certain graph types (bars and impulses), "higher" information often ends up covering up "lower" information. Normally this is a problem, but in this case it provides the solution.

On the left Y-axis, first select th0-max, and give that bar a white color (#ffffff). Then in the second row select the data you are interested in (th0) and give it the red color (see image.)

Image

When you generate the graph, the white data (th0-max) disappears into the background and is unseen, but it provides the needed information to make the values of the left y-axis match the right y-axis and your graph will display correctly!

This trick should work for most graph types. The important thing to remember is that graph lines are drawn sequentially -- first the left y-axis graphs from top to bottom, and then the right y-axis graphs from top to bottom.
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Re:Can I setup the same values on both axes of a graph?

Post by wfpost »

Nice find, sevenless. Thanks for posting that trick. Already applied it on my website!
zitterbacke
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: Wed Nov 04, 2009 9:58 pm

Re:Can I setup the same values on both axes of a graph?

Post by zitterbacke »

Hi,

can anybody help me with the correct syntax, if the values are %-values? Temperature values are no problem, here the command works fine. But to get %-values to the second y-axis I have a serious problem...

Thanks in advance.

Jens.
Post Reply