[Scilab-users] Interactive zoom on plot with multiple axes
DominicErnst
dominic.ernst at bystronic.com
Wed Jun 17 12:25:50 CEST 2015
Dear all,
I have successfully created a plot with two y-axes (left / right), including
some customization on axis labeling as well as legends. Now, if I try to
interactively zoom the plot, only the last active axis is zoom-able. I tried
to activate the other axis by issuing the gca(handle) command, but it did
not change anything.
Source:
t = linspace(0,10,1000);
P = 0.5*t;
alpha = 2.5*sin(0.2*t);
// Processed raw data figure
f_proc = scf(2);
f_proc.figure_name = "Processed raw Values";
f_proc.color_map = [get(sdf(),"color_map");[0,0.5,0]]; // add dark-green at
end of default color table
clf(f_proc);
plot(t,alpha,'b'); //first plot alpha blue
plot(t,P); //dummy plot -> only for working legend
ax_Ang = gca();
ax_Ang.axes_visible = ['off','on','off']; // hide 2nd x-axis
ax_Ang.y_location = 'left'; // alpha axis left
ax_Ang.children.children(1).foreground = 33; // assign green to dummy
plot -> correct display in legend
ax_Ang.children.children(1).visible = 'off'; // hide dummy plot
ax_Ang.filled = 'off'; // no background for this
plot
ax_Ang.tight_limits = 'on';
ax_Ang.auto_scale = 'off';
ax_Ang.data_bounds = [min(t),min(alpha);max(t),max(alpha)]; // i dont quite
get why this line is necessary, since tight_limits is on
ax_Ang.font_size = 2;
ticks = ax_Ang.y_ticks; // change y-axis
ticks to readable display
ticks.locations = [0;%pi/4;%pi/2;3*%pi/4;%pi;5*%pi/4];
ticks.labels =
['$0$';'$\frac{\pi}{4}$';'$\frac{\pi}{2}$';'$\frac{3\pi}{4}$';'$\pi$';'$\frac{5\pi}{4}$'];
ax_Ang.y_ticks = ticks;
ax_Y = newaxes(); // create secondary axis
plot(t,P); // plot second plot
ax_Y.axes_visible = ['on','on','off']; // show x and y-axis
ax_Y.y_location = 'right'; // y-axis right
ax_Y.children.children.foreground = ax_Ang.children.children(1).foreground;
// apply previously defined colors
ax_Y.filled = ax_Ang.filled;
// apply previously defined background
ax_Y.tight_limits = ax_Ang.tight_limits;
ax_Y.font_size = ax_Ang.font_size;
title('Angle and Position vs Time','font_size',3);
xlabel(ax_Y,'Time [ms]','font_size',2);
ylabel(ax_Y,'Position [mm]','font_size',2);
ylabel(ax_Ang,'Angle [-]','font_size',2);
legend(ax_Ang,['Angle','Position']);
Has anyone some experience with that. Would be a great help to explore my
data a little easier.
Any help is greatly appreciated
Regards
Dominic
-----
--
Dominic Ernst
CNC-PLC Software Developer @ Bystronic Laser AG
--
View this message in context: http://mailinglists.scilab.org/Interactive-zoom-on-plot-with-multiple-axes-tp4032460.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list