[Scilab-users] Plots on second Y axis

bjarne12 bjne at inmano.com
Thu Aug 25 18:53:03 CEST 2016


This is one way which is based on the description in
https://commons.wikimedia.org/wiki/File:Trace_ln_sqrt_1_2_deux_echelles_scilab.svg,
but with some changes. Draw the second graph first (the one for the right
y-axis). Then in the second plot, draw the first graph for the left axis and
the same graph again in the same plot, but with the visual characteristics
of the second graph. So if the first graph is a blue line and the second is
made of red dots, first draw the first graph as a blue line and then again
as red dots. Then set the red graph as invisible. This way the legend
command will add both graphs. I reckon it will work for more graphs as well,
but I haven't tested it. 

Here is some example code: 

a1 = newaxes(); //make right y-axis
a1.filled = 'off';
a1.axes_visible(1) = 'off';
a1.tight_limits = 'on';
a1.y_location = 'right';
a1.auto_ticks = ['off', 'on', 'on']; //remove ticks on first x-axis
a1.x_ticks.locations = [];
plot(x, y2, lin2); //plot graph 2
ylabel('add label', 'fontsize', 3); //add label to right y-axis

a2 = newaxes(); //make left y-axis
a2.filled = 'off';
a2.tight_limits = 'on';
plot(x, y1, lin1); //plot graph 1
plot(x, y1, lin2); //plot invisible graph 1 with colours of graph 2 (so a
legend can be added)
y = gca();
LinE = y.children.children(1);
LinE.visible = 'off';
xlabel('add label', 'fontsize', 3); //add label to x-axis
ylabel('add label, 'fontsize', 3); //add label to left y-axis




--
View this message in context: http://mailinglists.scilab.org/Scilab-users-Plots-on-second-Y-axis-tp4025895p4034490.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list