[Matplotlib-users] Printing Graphs and Image Processing Operations
I've used MPL a bit, and am wondering if there's a facility for sending graphic images to a printer, or putting them in some format like png? I don't necessarily want the graphics to appear in a window, but would like to print them directly once they are ready. Can one put in a page feed, so that images don't all fall on the same page or cut across pages? Is there any image processing operation available to do simple operations like dark subtract or stack different images on one other to produce composites of several images? Maybe Python has such a facility that's already available as a library? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet "I was thinking about how people seem to read the Bible a whole lot more as they get older; then it dawned on me . . they're cramming for their final exam." -- George Carlin Web Page: -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colorbar with date-time formatting
Colorbar axes is a rather special and things need to be set during the initialization. Here is a slightly modified version of your script. While it does not produces error, I'm not sure if the result is correct. -JJ import numpy as np import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter,DayLocator from matplotlib import cm data = np.arange(24.)+70. x = np.random.rand(24) y = np.random.rand(24) fig = plt.figure() ax = fig.add_subplot(111) smap = ax.scatter(x,y,s=10,c=data,edgecolors='none',marker='o',cmap=cm.jet) cb = fig.colorbar(smap,orientation='horizontal',shrink=0.7, ticks=DayLocator(interval=5), format=DateFormatter('%b %d')) plt.show() On Thu, Jan 14, 2010 at 3:04 PM, George Nurser wrote: > Hi, > I've got data in terms of day numbers, and wish to plot it as a 2D > scatter plot, with the color denoting the day. > > I'd like the colorbar to be annotated in Apr 7 type format... > > I've tried the following code without success. > > import numpy as np > import matplotlib.pyplot as plt > from matplotlib.dates import DateFormatter,DayLocator > from matplotlib import cm > > data = np.arange(24.)+70. > x = np.random.rand(24) > y = np.random.rand(24) > fig = plt.figure() > ax = fig.add_subplot(111) > smap = ax.scatter(x,y,s=10,c=data,edgecolors='none',marker='o',cmap=cm.jet) > cb = fig.colorbar(smap,orientation='horizontal',shrink=0.7) > cax=cb.ax > cax.xaxis_date() > cax.xaxis.set_major_locator(DayLocator()) > cax.xaxis.set_major_formatter(DateFormatter('%b %d')) > plt.show() > > Any ideas on how to do this would be appreciated. > > George Nurser. > > The code fails with the trace > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_wx.pyc > in _onPaint(self, evt) > 1154 drawDC = wx.PaintDC(self) > 1155 if not self._isDrawn: > -> 1156 self.draw(drawDC=drawDC) > 1157 else: > 1158 self.gui_repaint(drawDC=drawDC) > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_wxagg.pyc > in draw(self, drawDC) > 57 """ > 58 DEBUG_MSG("draw()", 1, self) > ---> 59 FigureCanvasAgg.draw(self) > 60 > 61 self.bitmap = > _convert_agg_to_wx_bitmap(self.get_renderer(), None) > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc > in draw(self) > 386 > 387 self.renderer = self.get_renderer() > --> 388 self.figure.draw(self.renderer) > 389 > 390 def get_renderer(self): > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.pyc > in draw(self, renderer) > 770 > 771 # render the axes > --> 772 for a in self.axes: a.draw(renderer) > 773 > 774 # render the figure text > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.pyc > in draw(self, renderer, inframe) > 1759 > 1760 for zorder, i, a in dsu: > -> 1761 a.draw(renderer) > 1762 > 1763 renderer.close_group('axes') > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc > in draw_wrapper(artist, renderer, *kl) > 53 def draw_wrapper(artist, renderer, *kl): > 54 before(artist, renderer) > ---> 55 draw(artist, renderer, *kl) > 56 after(artist, renderer) > 57 > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axis.pyc > in draw(self, renderer, *args, **kwargs) > 747 renderer.open_group(__name__) > 748 interval = self.get_view_interval() > --> 749 for tick, loc, label in self.iter_ticks(): > 750 if tick is None: continue > 751 if not mtransforms.interval_contains(interval, > loc): continue > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axis.pyc > in iter_ticks(self) > 688 Iterate through all of the major and minor ticks. > 689 """ > --> 690 majorLocs = self.major.locator() > 691 majorTicks = self.get_major_ticks(len
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
On Fri, Jan 15, 2010 at 12:19 PM, Paweł Rumian wrote: > 2010/1/15 Michael Droettboom : >> Can you try building matplotlib 0.99.1.1 from the tarball, rather than the >> gentoo package? That would help to rule out any of the gentoo-specific >> changes. Nothing in the portage leaps out at me as problematic, but we >> should rule that out. > > I was trying to avoid this, because I didn't want to mess up with my > python install, and using system and non-system packages > simultaneously... > > But I've just finished building from the tarball available at SF and > now it works flawlessly. So it is certainly a Gentoo bug. I can't replicate here on either of my AMD64 Gentoo system (with Gentoo's 0.99.1.1 matplotlib package). I should note that one is up to date with Portage (synced Monday) and the other is about 6 weeks out of date. With both, I see all 3 lines, correctly masked, unless I'm supposed to be looking for something else? While it might be a Gentoo bug, I don't think it's necessarily in the matplotlib package, but rather in the underlying dependencies. Anybody have any clue what to look at from here? Have you tried blowing away the Gentoo install of matplotlib completely and trying a new one? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma Sent from Norman, Oklahoma, United States -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
2010/1/15 Michael Droettboom : > Can you try building matplotlib 0.99.1.1 from the tarball, rather than the > gentoo package? That would help to rule out any of the gentoo-specific > changes. Nothing in the portage leaps out at me as problematic, but we > should rule that out. I was trying to avoid this, because I didn't want to mess up with my python install, and using system and non-system packages simultaneously... But I've just finished building from the tarball available at SF and now it works flawlessly. So it is certainly a Gentoo bug. Thanks! Paweł -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
I just tested 0.99.1.2 (no 0.99.1.1 tarball seems available on SF) and svn trunk and found no trouble with either on Ubuntu Karmic amd64. -Andrew -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] white area around plots
The svn version has a new keyword "bbox_extra_artists", which could be used. But, there is no easy way for the released version of matplotlib. Below is a workaround you may use, but it's a bit complicated. Regards, -JJ fig = figure(1) ax = fig.add_subplot(111) l1, = ax.plot([1,2,3]) leg = figlegend([l1], ["test"], 1) def get_tightbbox(renderer): from matplotlib.transforms import Bbox, TransformedBbox, Affine2D bb = [] # add fig legend bb.append(leg.legendPatch.get_window_extent()) for ax in fig.axes: if ax.get_visible(): bb.append(ax.get_tightbbox(renderer)) _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) bbox_inches = TransformedBbox(_bbox, Affine2D().scale(1./fig.dpi)) return bbox_inches fig.get_tightbbox = get_tightbbox -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
Can you try building matplotlib 0.99.1.1 from the tarball, rather than the gentoo package? That would help to rule out any of the gentoo-specific changes. Nothing in the portage leaps out at me as problematic, but we should rule that out. Mike Paweł Rumian wrote: > 2010/1/15 Michael Droettboom : > >>> Hi Paweł, to repeat a point that may have been lost in Michael's first >>> email, some code that produces the problem will be greatly useful in >>> tracking down what's going on. >>> >> If I gather correctly, the masked_demo.py example in the matplotlib source >> is sufficient to reproduce the bug. >> > > Yes, exactly. > > >> Unfortunately, I can't reproduce it >> here with 0.99.1.1 or SVN HEAD, so there's some environmental difference >> about Pawel's system -- of course I'm at a loss as to what it might be. >> > > I suppose it may be somehow Gentoo-related problem - unfortunately I > only have Gentoo boxes here, so I cannot check another OS, but the > same problem occurs on a second machine. > Furthermore I asked a friend with a Gentoo system and he confirmed > this behaviour, so in the meantime I filed a Gentoo bug: > http://bugs.gentoo.org/show_bug.cgi?id=301062 > > Maybe anyone here is also using Gentoo and can check it? > > >> Are you sure you're running 0.99.1.1? >> > > Yes, 0.99.1.1 with Python 2.6.4 > > ~ $ python > Python 2.6.4 (r264:75706, Dec 9 2009, 12:06:21) > [GCC 4.3.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > import matplotlib matplotlib.__version__ > '0.99.1.1' > > greetings, > Paweł > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
2010/1/15 Michael Droettboom : >> Hi Paweł, to repeat a point that may have been lost in Michael's first >> email, some code that produces the problem will be greatly useful in >> tracking down what's going on. > If I gather correctly, the masked_demo.py example in the matplotlib source > is sufficient to reproduce the bug. Yes, exactly. > Unfortunately, I can't reproduce it > here with 0.99.1.1 or SVN HEAD, so there's some environmental difference > about Pawel's system -- of course I'm at a loss as to what it might be. I suppose it may be somehow Gentoo-related problem - unfortunately I only have Gentoo boxes here, so I cannot check another OS, but the same problem occurs on a second machine. Furthermore I asked a friend with a Gentoo system and he confirmed this behaviour, so in the meantime I filed a Gentoo bug: http://bugs.gentoo.org/show_bug.cgi?id=301062 Maybe anyone here is also using Gentoo and can check it? > Are you sure you're running 0.99.1.1? Yes, 0.99.1.1 with Python 2.6.4 ~ $ python Python 2.6.4 (r264:75706, Dec 9 2009, 12:06:21) [GCC 4.3.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> matplotlib.__version__ '0.99.1.1' greetings, Paweł -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] white area around plots
Hi all, how can I reduce the white area around the plots (several subplots) with legends outside to the right of the axes when saving it to a png-file? pyplot.savefig('test2.png',bbox_inches='tight') shrinks the paper to axes size but cuts the legend. Thanks in advance Mario Mech -- Dr. Mario Mech Institute for Geophysics and Meteorology University of Cologne Zuelpicher Str. 49a 50674 Cologne Germany t: +49 (0)221 - 470 - 1776 f: +49 (0)221 - 470 - 5198 e: m...@meteo.uni-koeln.de w: http://www.meteo.uni-koeln.de/~mmech/ -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
Andrew Straw wrote: > Paweł Rumian wrote: > >> 2010/1/14 Michael Droettboom : >> >> >>> What backend are you using? Agg, Cairo and Wx all check out for me. The >>> examples you point to don't look like Agg output to me... >>> >>> >> The examples were produced using savefig and PNG, but I've tried GTK >> and Qt with Agg and Cairo - neither of them works. >> >> >> >>> Do you have anything in your matplotlibrc? >>> >>> >> Nothing but the backend... >> >> I've just noticed that the green line shows sometimes when moving the plot. >> Quick examples: >> no move: http://img524.imageshack.us/img524/5696/61571712.png >> slightly right (no change): >> http://img94.imageshack.us/img94/6722/44916983.png >> more (green line appears): http://img27.imageshack.us/img27/522/91772530.png >> even more (disappears behind the edge): >> http://img246.imageshack.us/img246/9726/24229795.png >> to the right (another part suddenly appears): >> http://img190.imageshack.us/img190/5697/69412483.png >> >> still no idea... >> >> > Hi Paweł, to repeat a point that may have been lost in Michael's first > email, some code that produces the problem will be greatly useful in > tracking down what's going on. > If I gather correctly, the masked_demo.py example in the matplotlib source is sufficient to reproduce the bug. Unfortunately, I can't reproduce it here with 0.99.1.1 or SVN HEAD, so there's some environmental difference about Pawel's system -- of course I'm at a loss as to what it might be. Are you sure you're running 0.99.1.1? Earlier versions have exhibited this class of bug, but I thought they were all squashed by now. What does the following give for you? > python Python 2.5.2 (r252:60911, May 7 2008, 12:40:32) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> matplotlib.__version__ '0.99.1.1' Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
Paweł Rumian wrote: > 2010/1/14 Michael Droettboom : > >> What backend are you using? Agg, Cairo and Wx all check out for me. The >> examples you point to don't look like Agg output to me... >> > > The examples were produced using savefig and PNG, but I've tried GTK > and Qt with Agg and Cairo - neither of them works. > > >> Do you have anything in your matplotlibrc? >> > > Nothing but the backend... > > I've just noticed that the green line shows sometimes when moving the plot. > Quick examples: > no move: http://img524.imageshack.us/img524/5696/61571712.png > slightly right (no change): http://img94.imageshack.us/img94/6722/44916983.png > more (green line appears): http://img27.imageshack.us/img27/522/91772530.png > even more (disappears behind the edge): > http://img246.imageshack.us/img246/9726/24229795.png > to the right (another part suddenly appears): > http://img190.imageshack.us/img190/5697/69412483.png > > still no idea... > Hi Paweł, to repeat a point that may have been lost in Michael's first email, some code that produces the problem will be greatly useful in tracking down what's going on. -Andrew -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] line drawing bug or it's me doing something wrong?
2010/1/14 Michael Droettboom : > What backend are you using? Agg, Cairo and Wx all check out for me. The > examples you point to don't look like Agg output to me... The examples were produced using savefig and PNG, but I've tried GTK and Qt with Agg and Cairo - neither of them works. > Do you have anything in your matplotlibrc? Nothing but the backend... I've just noticed that the green line shows sometimes when moving the plot. Quick examples: no move: http://img524.imageshack.us/img524/5696/61571712.png slightly right (no change): http://img94.imageshack.us/img94/6722/44916983.png more (green line appears): http://img27.imageshack.us/img27/522/91772530.png even more (disappears behind the edge): http://img246.imageshack.us/img246/9726/24229795.png to the right (another part suddenly appears): http://img190.imageshack.us/img190/5697/69412483.png still no idea... -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users