[Scilab-users] How to produce a filled staircase plot

Rafael Guera jrafaelbguerra at hotmail.com
Wed Oct 7 00:17:28 CEST 2015


Hello Antoine,
 
An attempt below, not particularly clean but I hope not too dirty either:
 
//INPUT
t = [ 0  2  5 10 12 17 20 30 35 45 60]'*0.1;
N = [20 18 15 14 12  9  6  4  3  2  1]';
 
t2=[];N2=[];
ns= length(t);
t2(1:2:2*ns) = t;  
t2(2:2:2*ns) = [t(2:$)-%eps; t($)];
N2(1:2:2*ns-1) = N;
N2(2:2:2*ns) = N;
clf;
xfpoly([t2(1)-%eps;t2;t2($)+%eps],[0;N2;0]);
h = gce();
h.line_mode = "off";
h.background = color('gray');
plot(t2,N2,'black', t2,21*exp(-t2/2),'red');
 
 
Regards,
 
Rafael
 
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Antoine Monmayrant
Sent: Tuesday, October 06, 2015 10:57 AM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] How to produce a filled staircase plot
 
Thank you Serge for this solution, but it does not work for me: the "bars" in my case are not regular.
I am simulating an exponential random decay: starting from a number N0, my population decreases by jumps of N0->N0-1 that occur at random times, following an exponential law (see the attached plot).
For the moment, I just build my polygon by hand, but it adds quite a lot of "noise" on top of the code that I intent to show to my students.
I was hoping for a cleaner solution.
 
Thanks anyway,
 
Cheers,
 
Antoine
 
Le Mardi 6 Octobre 2015 11:42 CEST, Serge Steer < <mailto:Serge.Steer at inria.fr> Serge.Steer at inria.fr> a écrit: 
 
> Le 06/10/2015 00:01, Antoine Monmayrant a écrit :
> > Hi everyone,
> >
> > I'm trying to do a filled staircase plot (ie a staircase where the area between the staircase and the x axis is filled with a solid color).
> > Is there a given combination of polyline_style and fill_mode, etc ... that can do this?
> > Or should I resort to building a polygon by hand?
> >
> > Thanks in advance,
> >
> > Antoine
> >
> > _______________________________________________
> > users mailing list
> >  <mailto:users at lists.scilab.org> users at lists.scilab.org
> >  <http://lists.scilab.org/mailman/listinfo/users> http://lists.scilab.org/mailman/listinfo/users
> >
> May be the bar mode can help you
> x=linspace(0,%pi,10);y=sin(x);
> clf;plot(x,y);e=gce();e=e.children;
> e.polyline_style=6;e.bar_width=0.5;
> e.background=2;
> e.line_mode="off";
> _______________________________________________
> users mailing list
>  <mailto:users at lists.scilab.org> users at lists.scilab.org
>  <http://lists.scilab.org/mailman/listinfo/users> http://lists.scilab.org/mailman/listinfo/users
> 
 
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20151006/a4975509/attachment.htm>


More information about the users mailing list