[Scilab-users] Zoom in plot

classic Classic list List threaded Threaded
3 messages Options
torpedo torpedo
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Zoom in plot

Hi,
I was looking for a way to have a zoom inside a plot. I didn't find any
example, so I tried to do myself.
Let me know if there is a better way to do it (for instance, if is it
possible to avoid to repeat the *plot* command)

clf()

// main axes
x = 0:0.1:20;
plot(x, acosh(x),"r", x, asinh(x), "g")
a = gca()
a.axes_bounds = [0, 0, 1, 1];
legend(["acosh", "asinh"], pos = "in_upper_left")
xpoly([0, 0, 2, 2], [0, 1, 1, 0])
xarrows([2, 12], [.5, 1.5], 8)

// zoom axes
z = newaxes();
z.axes_bounds = [.6, .3, .2, .5];
plot(x, acosh(x),'r', x, asinh(x), "g")
zoom_rect(z, [0, 0, 2, 1])

<http://mailinglists.scilab.org/file/t498101/zoom-in-plot.png>



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Zoom in plot

Hello,

Le 24/07/2020 à 10:43, torpedo a écrit :
Hi,
I was looking for a way to have a zoom inside a plot. I didn't find any
example, so I tried to do myself. 
Let me know if there is a better way to do it (for instance, if is it
possible to avoid to repeat the *plot* command)

Yes, you may use copy(), as it follows.
The legend must be delayed, otherwise it is copied as well, as a member of the initial axes:

clf()

// main axes
x = 0:0.1:20;
plot(x, acosh(x),"r", x, asinh(x), "g")
a = gca();
a.axes_bounds = [0, 0, 1, 1];
xpoly([0, 0, 2, 2], [0, 1, 1, 0])
xarrows([2, 12], [.5, 1.5], 8)

// zoom axes
z = copy(a);
z.axes_bounds = [.6, .3, .2, .5];
zoom_rect(z, [0, 0, 2, 1])

legend(a, ["acosh", "asinh"], pos = "in_upper_left")


Regards
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
torpedo torpedo
Reply | Threaded
Open this post in threaded view
|

Re: Zoom in plot

*copy()* is just what I was looking for, but, then, also *xpoly()* and
*xarrows()* have to be delayed (otherwise they are printed in the zoom axes)

clf()

// main axes
x = 0:0.1:20
plot(x, acosh(x),"r", x, asinh(x), "g")
a = gca()
a.axes_bounds = [0, 0, 1, 1]

// zoom axes
z = copy(a)
z.axes_bounds = [.6, .3, .2, .5]
zoom_rect(z, [0, 0, 2, 1])

sca(a)  // make main axes current
legend(["acosh", "asinh"], pos = "in_upper_left")
xpoly([0, 0, 2, 2], [0, 1, 1, 0])
xarrows([2, 12], [.5, 1.5], 8)



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users