Ask Your Question
1

Fill area under list_plot

asked 2011-12-24 01:32:33 -0600

v_2e gravatar image

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 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.

edit retag flag offensive close merge delete

Comments

what happened to @DSM's answer?

niles gravatar imageniles ( 2011-12-26 02:41:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2011-12-25 04:48:43 -0600

achrzesz gravatar image

Maybe 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()

edit flag offensive delete link more

Comments

Thanks! Not bad workaround.

v_2e gravatar imagev_2e ( 2012-01-04 08:57:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-12-24 01:32:33 -0600

Seen: 214 times

Last updated: Dec 25 '11