Re: [Matplotlib-users] colorbar
Yves Revaz wrote: > Hi all, > > When I use: > > colorbar(orientation='horizontal') > > the color bar is drawn on the bottom of the corresponding graph. > Which option will draw the colorbar on the top of the graph ? I think (correct me if I'm wrong devs) you'll have to use the cax keyword argument to manually specifiy the position of the axes in which to draw the colorbar. You'll also need to adjust the position of the plot using figure.subplots_adjust. Like this maybe: import numpy as np import matplotlib.pyplot as plt data = np.random.randn(30,30) plt.pcolor(data) fig = plt.gcf() fig.subplots_adjust(top=0.85) ax = fig.add_axes([0.12, 0.9, 0.8, 0.05]) plt.colorbar(cax=ax, orientation='horizontal') Hope this helps, Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] tesgdal in examples of basemap
I installed the latest gdal with all the latest basemaps and tried to run the testgdal.py program in examples. I get this error: Traceback (most recent call last): File "C:\Documents and Settings\kpeters\My Documents\basemap-0.99\examples\testgdal.py", line 19, in array = gd.ReadAsArray() AttributeError: 'NoneType' object has no attribute 'ReadAsArray' Anyone know what the problem is? Do I need something else? Kurt - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting speed
Michael Droettboom wrote: > Ok -- well, I'm genuinely sorry for wasting your time. No waste. As I said, I'm investigating Graphics Context for other things anyway. > Paul Kienzle made a change back in February that changed where > wx.Yield() gets called, that by side-effect seems to have fixed the > clipping slowness. cool! > One inherent slowness between Wx and WxAgg is that Wx needs to create a > wx.GraphicsPath using a Python loop over the data. Yes, I suspect that is the biggest problem. > With the Agg > backend, we just pass NumPy arrays (without any copies) to the Agg > backend. Perhaps wxPython needs to grow a similar interface... I think it does, and with the numpy array protocol, it may. There is a Google Summer of Code project that may address this. If it doesn't get done there, it may get done for another SoC project that I"m mentoring, where we need better GraphicsContext performance with numpy arrays. > As for your toy example, I don't see it getting significantly slower as > the number of points increases, but it does crash completely when I plot > more than about 11000 points (this is on RHEL4 with a locally-built > wxPython-2.8.6.1.) I have updated it to emulate what matplotlib does > more closely (use CreatePath etc.) Does is it still crash with your version? 11000 points really isn't that many. > Lastly, be sure to do an SVN update on matplotlib -- there was a > clipping bug in the Wx backend that I have fixed. thanks for the tip, and even more so, all your work on this. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Radar / Spider Chars
Nice. Thanks. I had tried to do something similar, but kept getting a curved line between each data point. Also, I too got errors with a previous versions of matplotlib, but 0.98 works. If someone were willing to add Radar plots to the matplotlib functionality, would this be wanted by the users or maintainers? Thanks, Curtis On Tue, Jun 17, 2008 at 4:18 PM, Tony S Yu <[EMAIL PROTECTED]> wrote: > > On Jun 15, 2008, at 11:54 AM, Curtis Jensen wrote: > >> There was recently a post on Radar/Spider plotting >> >> (http://sourceforge.net/mailarchive/message.php?msg_id=4845303A.9050204%40epcc.ed.ac.uk). >> I too am interested in creating Radar plots with matplot. Is there a >> simple way to do this? > > Here's a hack to get part of what you want: > > = > from matplotlib.projections.polar import PolarAxes > from pylab import * > > # Create 6 points (plus 7th point that matches the first) with coordinates > r, theta > N = 6 > theta = 2 * pi * linspace(0, 1, N+1) > r = rand(N+1) > r[N] = r[0] > > # HACK: force PolarAxes to use 1 line segment to connect specified points > PolarAxes.RESOLUTION = 1 > > ax = subplot(111, polar=True) > c = ax.plot(theta, r, 'r-o') > show() > = > > I think this only works on matplotlib 0.98. I tried using rgrids and > thetagrids to change the labels, but for some reason I was getting a > TypeError when I called either of those functions. > > -Tony > - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Large axis labels/positioning the axes
On 18-Jun-08, at 3:17 PM, John Hunter wrote: > If you are using subplots, you can move them over using > > fig = figure() > fig.subplots_adjust(left=0.2) Works like a charm! Thanks. One more related thing: is there any way to retrieve the size of a textbox in figure coordinates, something like ax.get_ymajorticklabels[0].get_width()? Also, I'm kind of wondering why things like set_text() on that doesn't work. In general I haven't had much success with editing the properties of objects like this. David - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Large axis labels/positioning the axes
On Wed, Jun 18, 2008 at 1:54 PM, David Warde-Farley <[EMAIL PROTECTED]> wrote: > Hi folks, > > I'm using 'yticks' to set labels on the y axis, unfortunately they're > rather long strings occasionally. I was wondering if there's a way to > tweak the position of the axes within the plot, or better yet to have > it automatically push the axes over so that the entire labels fit (I > realize that's a tall order and would be quite happy with a way of > tweaking it manually). If you are using subplots, you can move them over using fig = figure() fig.subplots_adjust(left=0.2) Alternatively, you can manually position your axes using the "axes" command rather than the "subplot" command, but the above will probably work for you. We've done some work on auto-layout but w/o much success. You can however, make 0.2 (or whatever) the default in your matplotlibrc file using the parameter (see http://matplotlib.sf.net/matplotlibrc). For example, you can set the "left" parameter there with:: figure.subplot.left : 0.125 # the left side of the subplots of the figure > Another (small, less important) question: is there a way to disable > the actual 'ticks' and just have labels present? The easiest way is to make them invisible:: ax = subplot(111) for line in ax.get_yticklines(): line.set_visible(False) JDH - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Large axis labels/positioning the axes
Hi folks, I'm using 'yticks' to set labels on the y axis, unfortunately they're rather long strings occasionally. I was wondering if there's a way to tweak the position of the axes within the plot, or better yet to have it automatically push the axes over so that the entire labels fit (I realize that's a tall order and would be quite happy with a way of tweaking it manually). I managed to get the 'axesPatch' to move over but unfortunately that didn't take the axes (or the labels) with it. Another (small, less important) question: is there a way to disable the actual 'ticks' and just have labels present? Thanks! David - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting speed
Michael Droettboom wrote: so are you working on an example? Or should I? I'm happy to do it, but may not get to it for a few days. My own test was to run "simple_plot_fps.py" with "handle_clip_rectangle" (in backend_wx.py) turned on and off. But obviously the wxPython folks will want a more standalone example. I've made a standalone example (enclosed). It simply makes a call to GraphicsContext.DrawLines() with and without clipping. In this case, it's actually a bit faster clipped (on OS-X). Maybe it's different with Paths -- I haven't dug into the MPL code to see how it's being used there. Also, the whole thing almost hangs (134 seconds to draw) if I up the number of points to 5000! Could you alter this to use the drawing calls MPL is actually using, then we can send it on the wxPython list. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] #!/usr/bin/env python """ A simple file for testing GraphicsContext speed -- at least for clipping a polyline """ import wx import time import numpy as np class TestPanel(wx.Panel): def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.Bind(wx.EVT_PAINT, self.OnPaint) N = 1000 self.Data = np.zeros((N,2)) self.Data[:,0] = np.linspace(0, 1.0, N) self.Data[:,1] = np.random.uniform(0, 1.0, (N,)) self._buffer = None self.Clip = False self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint) def OnSize(self, evt): x,y = self.GetSize() self._buffer = wx.EmptyBitmap(x,y) self.Draw() def OnPaint(self, evt): dc = wx.PaintDC(self) dc.DrawBitmap(self._buffer, 0, 0) def Draw(self, evt=None): dc = wx.MemoryDC() dc.SelectObject(self._buffer) X, Y = self._buffer.GetSize() box = (0.1*X, 0.1*Y, 0.8*X, 0.8*Y) # scale the data to fit the Window data = self.Data * (X,Y) ctx = wx.GraphicsContext_Create(dc) # Note: is the only way to clear the bitmap?? ctx.SetBrush(wx.WHITE_BRUSH) ctx.DrawRectangle(0, 0, X, Y) ctx.SetBrush(wx.TRANSPARENT_BRUSH) ctx.SetPen(wx.BLACK_PEN) ctx.DrawRectangle(*box) if self.Clip:# clip the drawing: print "Clipping the Drawing: ", ctx.Clip(*box) else: print "Not clipping the Drawing: ", ctx.SetPen(wx.Pen("red", 2)) start = time.clock() ctx.DrawLines(data) end = time.clock() self.DrawTime = end-start print "Drawing Took: %s seconds"%self.DrawTime self.Refresh() class TestFrame(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.Panel = TestPanel(self) self.button = wx.Button(self, label="Clip") self.button.Bind(wx.EVT_BUTTON, self.OnClick) S = wx.BoxSizer(wx.VERTICAL) S.Add(self.Panel, 1, wx.EXPAND) S.Add(self.button, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) self.SetSizer(S) def OnClick(self, event): label = self.button.GetLabel() if label == "Clip": self.button.Label = "Don't Clip" self.Panel.Clip = True elif label == "Don't Clip": self.button.Label = "Clip" self.Panel.Clip = False self.Panel.Draw() self.Layout() if __name__ == '__main__': app = wx.App(False) f = TestFrame(None) f.Show() app.MainLoop() - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Rotating an axes instance
I have an axes instance that I would like to rotate. I see that there is a rotation keyword for text and would like to do something like that with a plot. - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] colorbar
Hi all, When I use: colorbar(orientation='horizontal') the color bar is drawn on the bottom of the corresponding graph. Which option will draw the colorbar on the top of the graph ? Thanks, yves -- (o o) oOO--(_)--OOo--- Yves Revaz Laboratory of Astrophysics EPFL Observatoire de Sauverny Tel : ++ 41 22 379 24 28 51. Ch. des Maillettes Fax : ++ 41 22 379 22 05 1290 Sauverny e-mail : [EMAIL PROTECTED] SWITZERLAND Web : http://www.lunix.ch/revaz/ - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users