# Re: how to make a multi-panel bar plot?

From: Gary Bates <gary.bates_at_nyahnyahspammersnyahnyah>
Date: Mon, 24 Nov 2008 12:20:05 -0700

Mary,
Hmmm... I'm still not clear on how to append the polyline and polygon
into 'plot'. The code below gives me a 3 panel plot, but each panel
only contains the last bar:

plot = []
npanels=3
for n in range(npanels):

# Loop through each Y point, and create and draw a bar for it.
for i in xrange(len(y)):
xbar,ybar = get_bar(x[i],y[i],dx,ymin)
print xbar
print ybar
plot1=Ngl.xy(wks,xbar,ybar,res)

gsres.gsFillColor = colors[5] # Set color for bar.

plot.append(plot1)

-Gary

Mary Haley wrote:
> Hi Gary,
>
> and Ngl.add_polyline. This causes the lines and polygons to be attached
> to the plot, so that when you draw or resize the plot, the lines and
> polygons will get drawn and/or resized too.
>
> These functions behave exactly the same, except you need
> to make sure they return some kind of unique variable
>
> dum1 = Ngl.add_polygon(wks,plot,xbar,ybar,gsres) # Fill the bar.
> dum2 = Ngl.add_polyline(wks,plot,xbar,ybar) # Outline the bar.
>
>
> --Mary
>
> On Mon, 24 Nov 2008, Gary Bates wrote:
>
>> hi,
>>
>> I have a working pyngl code which makes a bar plot. Now I want to
>> make a 3-panel bar plot. The panel examples use plot.append to do
>> this, but I can't work out how to use this approach with Ngl.polygon
>> and Ngl.polyline below:
>>
>> # Loop through each Y point, and create and draw a bar for it.
>> for i in xrange(len(y)):
>> xbar,ybar = get_bar(x[i],y[i],dx,ymin)
>> print xbar
>> print ybar
>> plot=Ngl.xy(wks,xbar,ybar,res)
>>
>> gsres.gsFillColor = colors[5] # Set color for bar.
>> Ngl.polygon(wks,plot,xbar,ybar,gsres) # Fill the bar.
>> Ngl.polyline(wks,plot,xbar,ybar) # Outline the bar.
>>
>> Anyone know the solution to this problem?
>> -Gary
>> _______________________________________________
>> pyngl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>
Received on Mon Nov 24 2008 - 12:20:05 MST

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 09:25:48 MST