success displaying y axis on right side

18 views
Skip to first unread message

John Grant

unread,
Apr 17, 2014, 4:05:06 PM4/17/14
to mat...@googlegroups.com
I just want to post my success in case someone else needs to do the same thing.

I needed to display the y Axis values on the right side of the figure, instead of on the left as is common for many plots. The documentation here lead me to the right solution.

Some of the documentation made me think that mglGraph::Aspect(-1,1) would achieve what I wanted. The Aspect(-1,1) function did move the axis label to the right side, but there seems to be a bug that makes it return to the left side the next time I draw, and then back to the right on the following draw. This resulted in a disorienting animation. Aspect(-1,1) also reversed the x axis label, which is not what I wanted.

Instead of using Aspect(-1,1), the solution that worked for me is SetOrigin(xmax, ymin). Notice that xmax is used instead of 'xmin' which is probably what a typical plot would use. xmin, xmax, ymin, and ymax are my desired scale for my data.

My code is:

_graph->Clf();
_graph->SetRanges(xmin, xmax, ymin, ymax);
_graph->SetOrigin(xmax, ymin);
_graph->Box();
_graph->Axis();
_graph->Plot( yValues );


Good luck in your plotting!
John

Reply all
Reply to author
Forward
0 new messages