ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 04 Jan 2012 15:57:54 +0100Fill area under list_plothttps://ask.sagemath.org/question/8593/fill-area-under-list_plot/ Hello!
Is there a way to fill the area between the two curves plotted using the list_plot() function?
My particular application is this: I have a list of points of the format *(x, y, y_max, y_min)*, where *y_max* and *y_min* denote the maximum and minimum values of *y* for the given *x* value because of the measurements uncertainty. I need to plot this curve and fill the uncertainty corridor with some other color.
I use my own function that retrieves the data from this list and use *plot()* to obtain an abovementioned result at the moment. But in this case my function is evaluated in some kind of [random points](http://groups.google.com/group/sage-support/browse_thread/thread/45803c04598182ee) which do not correspond the exact experimental *x* values from the initial data list, that is why this solution is not very good too.
Thank you.Sat, 24 Dec 2011 08:32:33 +0100https://ask.sagemath.org/question/8593/fill-area-under-list_plot/Comment by niles for <p>Hello!</p>
<p>Is there a way to fill the area between the two curves plotted using the list_plot() function?</p>
<p>My particular application is this: I have a list of points of the format <em>(x, y, y_max, y_min)</em>, where <em>y_max</em> and <em>y_min</em> denote the maximum and minimum values of <em>y</em> for the given <em>x</em> value because of the measurements uncertainty. I need to plot this curve and fill the uncertainty corridor with some other color.</p>
<p>I use my own function that retrieves the data from this list and use <em>plot()</em> to obtain an abovementioned result at the moment. But in this case my function is evaluated in some kind of <a href="http://groups.google.com/group/sage-support/browse_thread/thread/45803c04598182ee">random points</a> which do not correspond the exact experimental <em>x</em> values from the initial data list, that is why this solution is not very good too.</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?comment=20631#post-id-20631what happened to @DSM's answer?Mon, 26 Dec 2011 09:41:01 +0100https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?comment=20631#post-id-20631Answer by achrzesz for <p>Hello!</p>
<p>Is there a way to fill the area between the two curves plotted using the list_plot() function?</p>
<p>My particular application is this: I have a list of points of the format <em>(x, y, y_max, y_min)</em>, where <em>y_max</em> and <em>y_min</em> denote the maximum and minimum values of <em>y</em> for the given <em>x</em> value because of the measurements uncertainty. I need to plot this curve and fill the uncertainty corridor with some other color.</p>
<p>I use my own function that retrieves the data from this list and use <em>plot()</em> to obtain an abovementioned result at the moment. But in this case my function is evaluated in some kind of <a href="http://groups.google.com/group/sage-support/browse_thread/thread/45803c04598182ee">random points</a> which do not correspond the exact experimental <em>x</em> values from the initial data list, that is why this solution is not very good too.</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?answer=13052#post-id-13052Maybe you should try without list_plot?
(no random points)
Replace li by your list of [x,y(x),ymax(x),ymin(x)]
li=[[x,sin(x),sin(x)+0.2,sin(x)-0.2] for x in srange(0,2*pi,0.3)]
a=[[x[0],x[2]] for x in li]
b=[[x[0],x[3]] for x in li]
c=[[x[0],x[1]] for x in li]
b.reverse()
p1=polygon2d(a+b,color='lightgrey',alpha=0.7)
p2=line(c,thickness=3)
p3=line(a,color='black')
p4=line(b,color='black')
(p1+p2+p3+p4).show()
Sun, 25 Dec 2011 11:48:43 +0100https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?answer=13052#post-id-13052Comment by v_2e for <p>Maybe you should try without list_plot?</p>
<p>(no random points)</p>
<p>Replace li by your list of [x,y(x),ymax(x),ymin(x)]</p>
<p>li=[[x,sin(x),sin(x)+0.2,sin(x)-0.2] for x in srange(0,2*pi,0.3)]</p>
<p>a=[[x[0],x[2]] for x in li]</p>
<p>b=[[x[0],x[3]] for x in li]</p>
<p>c=[[x[0],x[1]] for x in li]</p>
<p>b.reverse()</p>
<p>p1=polygon2d(a+b,color='lightgrey',alpha=0.7)</p>
<p>p2=line(c,thickness=3)</p>
<p>p3=line(a,color='black')</p>
<p>p4=line(b,color='black')</p>
<p>(p1+p2+p3+p4).show()</p>
https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?comment=20590#post-id-20590Thanks! Not bad workaround.Wed, 04 Jan 2012 15:57:54 +0100https://ask.sagemath.org/question/8593/fill-area-under-list_plot/?comment=20590#post-id-20590