SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S



1
(19)
2
(30)
3
(14)
4
(1)
5
(16)
6
(7)
7
(12)
8
(14)
9
(35)
10
(16)
11
(31)
12
(6)
13
(14)
14
(13)
15
(20)
16
(15)
17
(27)
18
(5)
19
(10)
20
(22)
21
(20)
22
(30)
23
(25)
24
(11)
25
(2)
26
(2)
27
(23)
28
(20)
29
(26)
30
(25)
31
(7)

Showing 7 results of 7

From: Demaeyer J. <jon...@ho...> - 2009年07月06日 23:30:10
Hi everyone,
I use matplotlib to render a figure in a tkinter (the Tix library more precisely) canvas.
It works very well but I can't turn off the autoscale (and I would like to), even by setting
ax.set_autoscale_on(False). When I test with ax.get_autoscale_on(), the result is False, but the
axes continues to autoscale.
I didn't had this problem in the past with ubuntu 8.04. I have it since I made the update to the
8.10 distribution so I guess that it's because the version of matplotlib I use have changed also
(but I don't remember the number of this previous version). Now I use python 2.5.2, Tix 8.4.0, mpl
0.98.3, numpy 1.2.1 ppa release, scipy 0.7.0 ppa release.
Here is the graphic part of my app :
class GraphFrame(Tix.Frame):
 def __init__(self,master):
 Tix.Frame.__init__(self,master,bd=10)
 self.gen = Tix.Frame(self)
 self.fps = Figure(figsize=(5,4),dpi=100,facecolor='w')
 self.tlps = 'Phase Space'
 self.xlps = {'xlabel' : r'$x$','fontsize' : 16}
 self.ylps = {'ylabel' : r'$p$','rotation' : 'horizontal','fontsize' : 16}
 self.aps = self.fps.add_subplot(111)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 self.canvasps = FigureCanvasTkAgg(self.fps,master=self.gen)
 self.canvasps.get_tk_widget().pack(side=Tix.TOP,fill=Tix.BOTH,expand=1)
 self.toolbar = NavigationToolbar2TkAgg(self.canvasps, self.gen)
 self.toolbar.update()
 self.canvasps._tkcanvas.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
 self.gen.grid(row=0, columnspan=14, sticky='NWSE')
 self.aps.set_autoscale_on(False) #doesn't work !!!
# self.aps.autoscale_view(scalex=False,scaley=False)
 self.psLin = []
 self.cl = ('r','g','b','c','y','m','k')
 self.coch = self.canvasps.mpl_connect('button_press_event', self.onpsclick)
 self.crh = self.canvasps.mpl_connect('button_release_event', self.onpsrelease)
 self.cmh = self.canvasps.mpl_connect('motion_notify_event', self.onpsmotion)
 self.cFrame = None
 self.press = False
 def ocps_connect(self):
 self.coch = self.canvasps.mpl_connect('button_press_event', self.onpsclick)
 self.crh = self.canvasps.mpl_connect('button_release_event', self.onpsrelease)
 self.cmh = self.canvasps.mpl_connect('motion_notify_event', self.onpsmotion)
 def ocps_disconnect(self):
 self.canvasps.mpl_disconnect(self.coch)
 self.canvasps.mpl_disconnect(self.crh)
 self.canvasps.mpl_disconnect(self.cmh)
#some method I use to update the graph
 def psaddData_m(self,u,xmin,xmax,pmin,pmax,m=','):
 line = lines.Line2D(u[:,0],u[:,1],
 linestyle='None',
 marker=m,
 color=self.cl[np.mod(len(self.psLin)-1,6)])
 self.psLin.append(line)
 self.psDraw(xmin,xmax,pmin,pmax)
 def psaddData_l(self,u,xmin,xmax,pmin,pmax,l='-'):
 line = lines.Line2D(u[:,0],u[:,1],
 linestyle=l,
 color=self.cl[np.mod(len(self.psLin)-1,6)])
 self.psLin.append(line)
 self.psDraw(xmin,xmax,pmin,pmax)
 def psdelData(self,n):
 del self.psLin[n]
 self.aps.clear()
# self.aps.cla()
 for l in self.psLin:
 self.aps.add_line(l)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 self.aps.redraw_in_frame()
 self.canvasps.blit()
 def psDraw(self,xmin,xmax,pmin,pmax):
# self.aps.clear()
 self.aps.cla()
 self.aps.set_xlim(xmin,xmax)
 self.aps.set_ylim(pmin,pmax)
 for l in self.psLin:
 self.aps.add_line(l)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 self.aps.draw()
 self.canvasps.blit()
# self.aps.set_autoscale_on(False)
# self.aps.autoscale_view(scalex=False,scaley=False)
# a = self.aps.get_autoscale_on()
# print a
 def psifRedraw(self):
 self.aps.clear()
# self.aps.cla()
 for l in self.psLin:
 self.aps.add_line(l)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 self.aps.redraw_in_frame()
 self.canvasps.blit()
 def psRedraw(self):
 self.aps.redraw_in_frame()
 self.canvasps.blit()
# click event handling
 def onpsclick(self,event):
 Bhv=self.cFrame.stDico['psMode'].get()
 if event.inaxes!=self.aps: return
 if Bhv == 'Nothing': return
 self.press = True
 if Bhv == 'Traj':
 niter=int(self.cFrame.stDico['n iter'].get())
 jb = self.cFrame.TrajJacob.get()
 if jb:
 lj = float(self.cFrame.TJDirlStr.get())
 hj = float(self.cFrame.TJDirhderStr.get())
 jnb = self.cFrame.nTrajJacob.get()
 if jnb:
 ljn = float(self.cFrame.nTJDirlStr.get())
 hjn = float(self.cFrame.nTJDirhderStr.get())
 v = np.array([event.xdata,event.ydata])
 s = [v]
 if jb: sj = [Jacob(v,hj,utils.dfridr)]
 if jnb: sjn = [Jacob(v,hjn,utils.dfridr)]
 for i in xrange(0,niter):
 u = pm.Map(v)
 s.append(u)
 v = u
 if jb: sj.append(Jacob(v,hj,utils.dfridr))
 if jnb: sjn.append(np.dot(sjn[-1],Jacob(v,hjn,utils.dfridr)))
 w = np.vstack(s)
 line = lines.Line2D(w[:,0],w[:,1],color='b')
 if jb:
 for i in xrange(len(sj)):
 J = sj[i]
 v = s[i]
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The point '+str(i+1)+' is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 else:
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-lj*u1,v+lj*u1])
 ul2 = np.vstack([v-lj*u2,v+lj*u2])
 line1 = lines.Line2D(ul1[:,0],ul1[:,1],color='b')
 line2 = lines.Line2D(ul2[:,0],ul2[:,1],color='r')
 self.aps.add_line(line1)
 self.aps.add_line(line2)
 if jnb:
 for i in xrange(len(sjn)):
 J = sjn[i]
 v = s[i]
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The traj '+str(i+1)+' is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 else:
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-ljn*u1,v+ljn*u1])
 ul2 = np.vstack([v-ljn*u2,v+ljn*u2])
 line1 = lines.Line2D(ul1[:,0],ul1[:,1],color='g')
 line2 = lines.Line2D(ul2[:,0],ul2[:,1],color='m')
 self.aps.add_line(line1)
 self.aps.add_line(line2)
 elif Bhv == '1it':
 v = np.array([event.xdata,event.ydata])
 u = pm.Map(v)
 w = np.vstack([v,u])
 line = lines.Line2D(w[:,0],w[:,1],
 linestyle='None',
 marker='+',
 markersize=10.,
 color='k')
 elif Bhv == 'Preim':
 xmin=float(self.cFrame.stDico['pixmin'].get())
 xmax=float(self.cFrame.stDico['pixmax'].get())
 pmin=float(self.cFrame.stDico['pipmin'].get())
 pmax=float(self.cFrame.stDico['pipmax'].get())
 nx=int(self.cFrame.stDico['pinx'].get())
 ny=int(self.cFrame.stDico['pinp'].get())
 tol=float(self.cFrame.stDico['pitol'].get())
 it=int(self.cFrame.stDico['piter'].get())
 al=float(self.cFrame.stDico['pialpha'].get())
 npim = self.cFrame.preimmVar.get()
 v = np.array([event.xdata,event.ydata])
 u = preMap(npim,v,xmin,xmax,pmin,pmax,nx,ny,tol,it,al)
 if u != None:
 w = np.vstack([v,u])
 else:
 w = v
 w.shape = 1,2
 line = lines.Line2D(w[:,0],w[:,1],
 linestyle='None',
 marker='+',
 markersize=10.,
 color='k')
 elif Bhv == 'Jacob':
 l = float(self.cFrame.DirlStr.get())
 h = float(self.cFrame.DirhderStr.get())
 v = np.array([event.xdata,event.ydata])
 J = Jacob(v,h,utils.dfridr)
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The point is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 return
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-l*u1,v+l*u1])
 ul2 = np.vstack([v-l*u2,v+l*u2])
 line = lines.Line2D(ul1[:,0],ul1[:,1],color='b')
 line1 = lines.Line2D(ul2[:,0],ul2[:,1],color='r')
 self.aps.add_line(line1)
 self.aps.add_line(line)
# self.aps.set_title(self.tlps)
# self.aps.set_xlabel(**self.xlps)
# self.aps.set_ylabel(**self.ylps)
 self.aps.redraw_in_frame()
 self.canvasps.blit()
 def onpsmotion(self,event):
 Bhv=self.cFrame.stDico['psMode'].get()
 if event.inaxes!=self.aps: return
 if self.press == False: return
 if Bhv == 'Nothing': return
 self.aps.clear()
# self.aps.cla()
 for l in self.psLin:
 self.aps.add_line(l)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 if Bhv == 'Traj':
 niter=int(self.cFrame.stDico['n iter'].get())
 jb = self.cFrame.TrajJacob.get()
 if jb:
 lj = float(self.cFrame.TJDirlStr.get())
 hj = float(self.cFrame.TJDirhderStr.get())
 jnb = self.cFrame.nTrajJacob.get()
 if jnb:
 ljn = float(self.cFrame.nTJDirlStr.get())
 hjn = float(self.cFrame.nTJDirhderStr.get())
 v = np.array([event.xdata,event.ydata])
 s = [v]
 if jb: sj = [Jacob(v,hj,utils.dfridr)]
 if jnb: sjn = [Jacob(v,hjn,utils.dfridr)]
 for i in xrange(0,niter):
 u = pm.Map(v)
 s.append(u)
 v = u
 if jb: sj.append(Jacob(v,hj,utils.dfridr))
 if jnb: sjn.append(np.dot(sjn[-1],Jacob(v,hjn,utils.dfridr)))
 w = np.vstack(s)
 line = lines.Line2D(w[:,0],w[:,1],color='b')
 if jb:
 for i in xrange(len(sj)):
 J = sj[i]
 v = s[i]
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The point '+str(i+1)+' is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 else:
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-lj*u1,v+lj*u1])
 ul2 = np.vstack([v-lj*u2,v+lj*u2])
 line1 = lines.Line2D(ul1[:,0],ul1[:,1],color='b')
 line2 = lines.Line2D(ul2[:,0],ul2[:,1],color='r')
 self.aps.add_line(line1)
 self.aps.add_line(line2)
 if jnb:
 for i in xrange(len(sjn)):
 J = sjn[i]
 v = s[i]
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The traj '+str(i+1)+' is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 else:
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-ljn*u1,v+ljn*u1])
 ul2 = np.vstack([v-ljn*u2,v+ljn*u2])
 line1 = lines.Line2D(ul1[:,0],ul1[:,1],color='g')
 line2 = lines.Line2D(ul2[:,0],ul2[:,1],color='m')
 self.aps.add_line(line1)
 self.aps.add_line(line2)
 elif Bhv == '1it':
 v = np.array([event.xdata,event.ydata])
 u = pm.Map(v)
 w = np.vstack([v,u])
 line = lines.Line2D(w[:,0],w[:,1],
 linestyle='None',
 marker='+',
 markersize=10.,
 color='k')
 elif Bhv == 'Preim':
 xmin=float(self.cFrame.stDico['pixmin'].get())
 xmax=float(self.cFrame.stDico['pixmax'].get())
 pmin=float(self.cFrame.stDico['pipmin'].get())
 pmax=float(self.cFrame.stDico['pipmax'].get())
 nx=int(self.cFrame.stDico['pinx'].get())
 ny=int(self.cFrame.stDico['pinp'].get())
 tol=float(self.cFrame.stDico['pitol'].get())
 it=int(self.cFrame.stDico['piter'].get())
 al=float(self.cFrame.stDico['pialpha'].get())
 npim = self.cFrame.preimmVar.get()
 v = np.array([event.xdata,event.ydata])
 u = preMap(npim,v,xmin,xmax,pmin,pmax,nx,ny,tol,it,al)
 if u != None:
 w = np.vstack([v,u])
 else:
 w = v
 w.shape = 1,2
 line = lines.Line2D(w[:,0],w[:,1],
 linestyle='None',
 marker='+',
 markersize=10.,
 color='k')
 elif Bhv == 'Jacob':
 l = float(self.cFrame.DirlStr.get())
 h = float(self.cFrame.DirhderStr.get())
 v = np.array([event.xdata,event.ydata])
 J = Jacob(v,h,utils.dfridr)
 (lr,vr) = eig(J,right=True)
 if reduce(lambda x,y : (np.abs(x)-1.)*(np.abs(y)-1.),lr) >= 0:
 print 'Problem : The point is not hyperbolic'
 print 'J=',J
 print 'l=',lr
 return
 if abs(lr[0]) < 1.:
 u1 = vr[:,0]
 u2 = vr[:,1]
 else:
 u1 = vr[:,1]
 u2 = vr[:,0]
 ul1 = np.vstack([v-l*u1,v+l*u1])
 ul2 = np.vstack([v-l*u2,v+l*u2])
 line = lines.Line2D(ul1[:,0],ul1[:,1],color='b')
 line1 = lines.Line2D(ul2[:,0],ul2[:,1],color='r')
 self.aps.add_line(line1)
 self.aps.add_line(line)
# self.aps.set_title(self.tlps)
# self.aps.set_xlabel(**self.xlps)
# self.aps.set_ylabel(**self.ylps)
 self.aps.redraw_in_frame()
 self.canvasps.blit()
 def onpsrelease(self,event):
 self.press = False
 self.aps.clear()
# self.aps.cla()
 for l in self.psLin:
 self.aps.add_line(l)
 self.aps.set_title(self.tlps)
 self.aps.set_xlabel(**self.xlps)
 self.aps.set_ylabel(**self.ylps)
 self.aps.redraw_in_frame()
 self.canvasps.blit()
# end
I don't know if it is a bug or something else but thank you in advance if you can help me.
Jonathan
From: Michael C. <mc...@ca...> - 2009年07月06日 22:46:11
Hi all,
I am trying to produce a weighted histogram.
The help text for "hist" here:
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.hist
has a mention of adding weights, but it is not noted in the command line 
section where this should appear.
Calling:
hist(data,20,data_weights)
gives the error:
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/matplotlib/pyplot.py", 
line 1868, in hist
 ret = gca().hist(*args, **kwargs)
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/matplotlib/axes.py", 
line 6236, in hist
 normed=bool(normed), new=True)
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/numpy/lib/function_base.py", 
line 353, in histogram
 mn, mx = range
ValueError: too many values to unpack
Calling:
hist(data,20,weights=data_weights)
gives the error:
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/matplotlib/pyplot.py", 
line 1868, in hist
 ret = gca().hist(*args, **kwargs)
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/matplotlib/axes.py", 
line 6371, in hist
 p.update(kwargs)
 File 
"/usr/local/python-2.5.2/lib/python2.5/site-packages/matplotlib/artist.py", 
line 453, in update
 raise AttributeError('Unknown property %s'%k)
AttributeError: Unknown property weights
There's no indication in the help text of where or how to insert the 
weights array.
Thanks in advance,
Michael
From: jcm52 <joe...@gm...> - 2009年07月06日 15:53:48
Perhaps this is a new feature since you sent this request, but I just came
across 
pylab.suptitle('my super title')
Seems to work fairly well, but the font sizes don't appear to behave as well
as I'd like.
Tommy Grav wrote:
> 
> I have a plot that is divided into four subplots.
> 
> pylab.figure()
> pylab.subplot(221)
> pylab.plot(a,b,"k-")
> pylab.subplot(222)
> pylab.plot(a,b,"k-")
> pylab.subplot(223)
> pylab.plot(a,b,"k-")
> pylab.subplot(224)
> pylab.plot(a,b,"k-")
> 
> I would like to add a title to the entire plot, but pylab.title() only
> applies to the most recent subplot. I have tried
> 
> pylab.figure()
> pylab.subplot(111)
> pylab.title("Title Here")
> pylab.subplot(221)
> pylab.plot(a,b,"k-")
> pylab.subplot(222)
> pylab.plot(a,b,"k-")
> pylab.subplot(223)
> pylab.plot(a,b,"k-")
> pylab.subplot(224)
> pylab.plot(a,b,"k-")
> 
> but this does not work as I do not create a plot for
> the subplot(111) instance. Is there some way of getting
> the type of title I want easily?
> 
> Cheers
> Tommy
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/title-when-using-subplot-tp15066004p24357703.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Oliver T. <oli...@no...> - 2009年07月06日 11:27:01
Hi,
Windows XP
Python 2.5.2
matplotlib 0.98.5.2
I try to use numpoints for a legend my plot, but without luck. I always 
end up having three points in the legend despite setting numpoints=1 (see 
below towards the end of the code).
Things work nicely though in a much simpler script.
Help is greatly appreciated. 
Cheers 
Oliver
[CODE START]
# Import necessary modules
import numpy as np
import matplotlib.pyplot as plt
# Import data for correlation plot
assC = np.loadtxt('Apples_flowerFlavour_assC_corrPlot.txt')
all = np.loadtxt('Apples_flowerFlavour_allAssessors_corrPlot.txt')
x_assC = assC[:,1].copy()
y_assC = assC[:,0].copy()
x_all = all[:,1].copy()
y_all = all[:,0].copy()
# Plot values 
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(x_all, y_all, s=10, c='w', marker='o', edgecolor='grey', 
label='_')
# NOTE: label='_' excludes the lable from legend
ax.scatter([x_assC[0]], [y_assC[0]], s=50, c='r', marker='s', label='Apple 
Golden')
ax.scatter([x_assC[1]], [y_assC[1]], s=50, c='r', marker='v', 
label='Granny Smith')
ax.scatter([x_assC[2]], [y_assC[2]], s=50, c='r', marker='d', label='Green 
Star')
ax.scatter([x_assC[3]], [y_assC[3]], s=50, c='r', marker='^', 
label='Kanzi')
ax.scatter([x_assC[4]], [y_assC[4]], s=50, c='r', marker='>', label='Pink 
Lady')
ax.scatter([x_assC[5]], [y_assC[5]], s=50, c='r', marker='<', label='Royal 
Gala')
ax.scatter([x_assC[6]], [y_assC[6]], s=35, c='r', marker='o', 
label='Ecological')
ax.plot([0,10], [0,10], 'b--')
ax.set_xlim(0,10)
ax.set_ylim(0,10)
# Fix legend settings
plt.legend(loc='lower right', shadow=True, numpoints=1)
ltext = plt.gca().get_legend().get_texts()
plt.setp(ltext[0], fontsize = 10, color = 'k')
ax.set_xlabel('panel average')
ax.set_ylabel('assessor C')
plt.show()
[CODE END]
 
From: guillaume r. <gra...@wy...> - 2009年07月06日 08:59:38
Jae-Joon Lee wrote:
> Well, if you think something is wrong, I guess you may have chosen a
> wrong tool.
> MPL is mainly for 2d plotting, and not very strong for animation
> although it supports some.
I just think that I have a nice hammer, a nice nail ... and not a clue
on how to use a hammer (I'm a python noob, and high level language noob
in general, the highest level language I used before starting python was
C ... for embedded devices)
I just though that I was thinking in the wrong way.
> One possible option in your case is to save your plot as an image in
> each round. And at the next round, you plot the newly available data
> upon the shifted image.
> 
> http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html
thanks, this looks great :)
----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you. 
Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----
From: Ondrej C. <on...@ce...> - 2009年07月06日 06:13:42
On Tue, Jun 30, 2009 at 12:09 PM, Ondrej Certik<on...@ce...> wrote:
> Hi,
>
> this must have been answered many times already, but I searched the
> archives, online docs, but couldn't find anything.
>
> If I do:
>
> $ python
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import pylab
>>>> pylab.plot([1, 3, 3])
> [<matplotlib.lines.Line2D object at 0x2154350>]
>>>> pylab.show()
>>>> pylab.show()
>>>>
>
> the first pylab.show() shows the plot and stays hanging (this is ok)
> and then if I close it, to get back to the shell, the second call to
> show() does nothing.
>
> One fix is to use:
>
> ipython --pylab
>
> but if I just want to call regular python, or from my own script ---
> how do I plot for the second time?
I still haven't figured out how to fix it, so any feedback would be appreciated.
Thanks,
Ondrej
From: Rick M. <rpm...@gm...> - 2009年07月06日 01:08:59
Meant to copy this to the list as well for completeness.
---------- Forwarded message ----------
From: Rick Muller <rpm...@gm...>
Date: Sun, Jul 5, 2009 at 2:03 PM
Subject: Re: [Matplotlib-users] Empty squares at end of data after
interpolation with griddata?
To: Jeff Whitaker <js...@fa...>
The link should work now. What you say about extrapolation makes perfect
sense. I wonder why those points aren't being computed. In any case, thanks
for the help!
Rick
On Sun, Jul 5, 2009 at 7:27 AM, Jeff Whitaker <js...@fa...> wrote:
>
> http://files.getdropbox.com/u/533499/griddata-example-text.png
>>
>
>
> Rick: That URL doesn't work.
>
> griddata won't do extrapolation, that is it won't interpolate outside the
> convex hull of the data. That's probably why you see those empty squares at
> the edges.
>
> --
Rick Muller
rpm...@gm...
-- 
Rick Muller
rpm...@gm...

Showing 7 results of 7

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /