[Matplotlib-users] Extending a plot outside of axes

2009-01-19 Thread Einar M. Einarsson
Hi all.

is it not possible to extend plot outside of a plot area? To  
illustrate what I want
to do take for example the wind barbs example from the matplotlib  
gallery.
(see below)

I only changed line 23 from ax.barbs(X, Y, U, V) to ax.barbs(X, Y, - 
U, -V)

But now we don't see the tail of the barbs in the first subplot.

So Is it possible to let matplotlib plot the tail, without extending  
the axes?

Best Regards
Einar M. Einarsson

'''
Demonstration of wind barb plots
'''
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-5, 5, 5)
X,Y = np.meshgrid(x, x)
U, V = 12*X, 12*Y

data = [(-1.5, .5, -6, -6),
 (1, -1, -46, 46),
 (-3, -1, 11, -11),
 (1, 1.5, 80, 80),
 (0.5, 0.25, 25, 15),
 (-1.5, -0.5, -5, 40)]

data = np.array(data, dtype=[('x', np.float32), ('y', np.float32),
 ('u', np.float32), ('v', np.float32)])

#Default parameters, uniform grid
ax = plt.subplot(2,2,1)
ax.barbs(X, Y, -U, -V)

#Arbitrary set of vectors, make them longer and change the pivot point
#(point around which they're rotated) to be the middle
ax = plt.subplot(2,2,2)
ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8,  
pivot='middle')

#Showing colormapping with uniform grid.  Fill the circle for an  
empty barb,
#don't round the values, and change some of the size parameters
ax = plt.subplot(2,2,3)
ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True,  
rounding=False,
 sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3))

#Change colors as well as the increments for parts of the barbs
ax = plt.subplot(2,2,4)
ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r',
 barbcolor=['b','g'], barb_increments=dict(half=10, full=20,  
flag=100),
 flip_barb=True)

plt.show()


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Extending a plot outside of axes

2009-01-19 Thread Jeff Whitaker
Einar M. Einarsson wrote:
> Hi all.
>
> is it not possible to extend plot outside of a plot area? To  
> illustrate what I want
> to do take for example the wind barbs example from the matplotlib  
> gallery.
> (see below)
>
> I only changed line 23 from ax.barbs(X, Y, U, V) to ax.barbs(X, Y, - 
> U, -V)
>
> But now we don't see the tail of the barbs in the first subplot.
>
> So Is it possible to let matplotlib plot the tail, without extending  
> the axes?
>   

Einar:  You can use the set_clip_box method of the barbs instance to 
turn clipping off:

bb = ax.barbs(X, Y, -U, -V)
bb.set_clip_box(None)

-Jeff
> Best Regards
> Einar M. Einarsson
>
> '''
> Demonstration of wind barb plots
> '''
> import matplotlib.pyplot as plt
> import numpy as np
>
> x = np.linspace(-5, 5, 5)
> X,Y = np.meshgrid(x, x)
> U, V = 12*X, 12*Y
>
> data = [(-1.5, .5, -6, -6),
>  (1, -1, -46, 46),
>  (-3, -1, 11, -11),
>  (1, 1.5, 80, 80),
>  (0.5, 0.25, 25, 15),
>  (-1.5, -0.5, -5, 40)]
>
> data = np.array(data, dtype=[('x', np.float32), ('y', np.float32),
>  ('u', np.float32), ('v', np.float32)])
>
> #Default parameters, uniform grid
> ax = plt.subplot(2,2,1)
> ax.barbs(X, Y, -U, -V)
>
> #Arbitrary set of vectors, make them longer and change the pivot point
> #(point around which they're rotated) to be the middle
> ax = plt.subplot(2,2,2)
> ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8,  
> pivot='middle')
>
> #Showing colormapping with uniform grid.  Fill the circle for an  
> empty barb,
> #don't round the values, and change some of the size parameters
> ax = plt.subplot(2,2,3)
> ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True,  
> rounding=False,
>  sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3))
>
> #Change colors as well as the increments for parts of the barbs
> ax = plt.subplot(2,2,4)
> ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r',
>  barbcolor=['b','g'], barb_increments=dict(half=10, full=20,  
> flag=100),
>  flip_barb=True)
>
> plt.show()
>
>
>   



--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users