Double Line Series Plot with 2 Y axes

Feb 18, 2013 at 5:47 PM
I was looking to make a graph with two line series. The series have drastically different Y ranges so I was wondering whether it would be possible to make two Y axes, one on the left and one on the right. Thanks.
Feb 19, 2013 at 10:16 AM
Edited Feb 19, 2013 at 10:17 AM
Yes, this is possible:
var pm = new PlotModel();
var secondaryAxis = new LinearAxis(AxisPosition.Left, "Secondary"); // And add other axes as well
pm.Axes.Add(secondaryAxis); // Add them all
var ls = new LineSeries("Secondary Line");
// Do stuff to add datapoints here
secondaryAxis.Key = "Secondary";
ls.YAxisKey = "Secondary";
Edit: Typo
Feb 19, 2013 at 10:43 AM
I notice, however, that when you zoom or pan, the secondary axis won't update. I haven't figured out how to fix this yet.
Feb 19, 2013 at 8:46 PM
Thanks that is what I needed. It would be nice if they panned and zoomed proportionately to each other but I guess I can deal with that. Is there a way of associating the line series with either axis (color-coding perhaps)?
Feb 19, 2013 at 9:14 PM
Edited Feb 19, 2013 at 9:15 PM
The line series can be associated with the axis by color:
secondaryAxis.TicklineColor = OxyColors.Red;
secondaryAxis.TitleColor = OxyColors.Red;
secondaryAxis.TextColor = OxyColors.Red;
ls.Color = OxyColors.Red;
Still working on the zoom/pan issue.
Feb 19, 2013 at 9:28 PM
Both axes are independent so each one has to be zoomed independently. By default (I don't know if this can be changed), the left axis is the one that has control when the mouse is over the graph. To control the right axis, you have to hover over it and scroll to zoom or right-click drag to pan.
Feb 19, 2013 at 9:39 PM
I noticed the same thing. It can be useful (sometimes) to control them independently. I believe that most people would want the (ctrl+RMB)-zoom to function as if they were dependent/connected, and that they could be independently controlled if the mouse was over the axis. (But this is another discussion, I guess)
Apr 3, 2013 at 10:59 PM
Not sure if you still need an answer to the proportional zooming but maybe someone else will.

You can work around the issue of the independent axes with following the example of the coupled axes, But instead of using the actualMaximum of the other axis you are computing a proportion factor with the two maxima of your plots. Then you can scale the actualMaximum with that factor.

Its a little trickier to do that for the mimima as well but it should work.