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
(20) |
2
(16) |
3
(9) |
4
(12) |
5
(14) |
6
(22) |
7
(17) |
8
(33) |
9
(26) |
10
(32) |
11
(47) |
12
(26) |
13
(7) |
14
(24) |
15
(44) |
16
(42) |
17
(22) |
18
(31) |
19
(8) |
20
(4) |
21
(15) |
22
(27) |
23
(41) |
24
(33) |
25
(31) |
26
(24) |
27
(10) |
28
(20) |
|
|
|
|
|
|
Thanks so much John! That does the trick. I'm just a new user of mpl, so your question about whether the default behavior of draw should be changed is probably "above my pay grade." I just don't know the API well enough to comment intelligently about it. That said, I would suggest that this behavior be documented (either in the tutorial page I originally accessed, the documentation for "canvas.draw()", both locations, or some other appropriate place). Thanks again from a very satisfied mpl user, Brian John Hunter-4 wrote: > > On Fri, Feb 26, 2010 at 5:14 PM, brianjpetersen > <bri...@gm...> wrote: >> >> Hi All, >> >> I'm a new matplotlib user on a Windows XP machine running mpl0.99.0 under >> Python 2.5. I'm using the default rc file. >> >> While reading through the excellent matplotlib "how-to" tutorial >> (http://matplotlib.sourceforge.net/faq/howto_faq.html), I came across two >> useful scripts: one to save a figure with a transparent background, and >> one >> to resize axes automatically so that labels aren't cut off. I was able >> to >> run both these examples given on the "how-to" successfully. >> >> However, I ran into trouble when trying to combine them as follows: >> >> ===== >> >> import matplotlib.pyplot as plt >> import matplotlib.transforms as mtransforms >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> ax.plot(range(10)) >> ax.set_yticks((2,5,7)) >> labels = ax.set_yticklabels(('really, really, really', 'long', 'labels')) >> >> def on_draw(event): >> bboxes = [] >> for label in labels: >> bbox = label.get_window_extent() >> # the figure transform goes from relative coords->pixels and we >> # want the inverse of that >> bboxi = bbox.inverse_transformed(fig.transFigure) >> bboxes.append(bboxi) >> >> # this is the bbox that bounds all the bboxes, again in relative >> # figure coords >> bbox = mtransforms.Bbox.union(bboxes) >> if fig.subplotpars.left < bbox.width: >> # we need to move it over >> fig.subplots_adjust(left=1.1*bbox.width) # pad a little >> fig.canvas.draw() >> >> return False >> >> fig.canvas.mpl_connect('draw_event', on_draw) >> >> plt.savefig('test.png', transparent=True) >> >> ===== >> >> In this case, the saved png file is transparent, but the original set of >> axes, labels, and plot are visible as well (basically, I have two >> identical >> plots shifted over one another on a transparent background). >> >> Is there a way to suppress the original output (something akin to >> "fig.canvas.erase()" or "fig.canvas.clear()", but I can't seem to figure >> it >> out) so that the output png only shows the shifted axes and not both >> sets? > > Interesting! That one really surprised me. It turns out mpl is not > clearing the pixel buffer from the previous draw command. Normally > you don't see this because the call to draw the figure.patch blanks > out the pixel buffer with the background color, but since your figure > patch is transparent you can see the legacy. A call to > renderer.clear() before drawing again will erase the old image > (perhaps we should be doing this by default?) > > import matplotlib > matplotlib.use('Agg') > import matplotlib.pyplot as plt > import matplotlib.transforms as mtransforms > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(range(10)) > ax.set_yticks((2,5,7)) > labels = ax.set_yticklabels(('really, really, really', 'long', 'labels')) > > def on_draw(event): > bboxes = [] > for label in labels: > bbox = label.get_window_extent() > # the figure transform goes from relative coords->pixels and we > # want the inverse of that > bboxi = bbox.inverse_transformed(fig.transFigure) > bboxes.append(bboxi) > > # this is the bbox that bounds all the bboxes, again in relative > # figure coords > bbox = mtransforms.Bbox.union(bboxes) > if fig.subplotpars.left < bbox.width: > # we need to move it over > fig.subplots_adjust(left=1.1*bbox.width) # pad a little > fig.canvas.get_renderer().clear() > fig.canvas.draw() > > return False > > fig.canvas.mpl_connect('draw_event', on_draw) > > plt.savefig('test.png', transparent=True) > > > JDH > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Transparency-with-fig.canvas.mpl_connect-tp27724532p27738002.html Sent from the matplotlib - users mailing list archive at Nabble.com.
xiliu@master:/tmp/matplotlib-0.99.1.1$ python Python 2.6 (r26:66714, Nov 3 2009, 17:33:38) [GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib.pyplot as plt Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module> from matplotlib.figure import Figure, figaspect File "/usr/lib/python2.6/site-packages/matplotlib/figure.py", line 18, in <module> from axes import Axes, SubplotBase, subplot_class_factory File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 24, in <module> import matplotlib.spines as mspines File "/usr/lib/python2.6/site-packages/matplotlib/spines.py", line 17, in <module> class Spine(mpatches.Patch): File "/usr/lib/python2.6/site-packages/matplotlib/spines.py", line 39, in Spine @docstring.dedent_interpd File "/usr/lib/python2.6/site-packages/matplotlib/docstring.py", line 103, in dedent_interpd return interpd(dedent(func)) File "/usr/lib/python2.6/site-packages/matplotlib/docstring.py", line 36, in __call__ func.__doc__ = func.__doc__ and func.__doc__ % self.params KeyError: 'Patch' >>>
--- On Sun, 2/28/10, Ryan May <rm...@gm...> wrote: > David Goldsmith > <d_l...@ya...> > wrote: > > --- On Sat, 2/27/10, Ryan May <rm...@gm...> > wrote: > >> David Goldsmith > >> <d_l...@ya...> > >> wrote: > >> > Question 2) is there some way I can add > pieces of the > >> array incrementally to > >> > the image into their proper place, i.e., > modify the > >> following code: > >> > > >> > ax.imshow(image[0:ny/2+1, 0:nx/2+1]) # > upper > >> left corner of image > >> > ax.hold(True) > >> > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1]) # > lower > >> left corner of image > >> > ax.imshow(argW[0:ny/2+1, nx/2+1:-1]) # > upper > >> right corner of image > >> > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1]) > # lower > >> right corner of image > >> > >> Try the extents keyword argument. It let's you > specify the > >> corners of > >> the image in data coordinates. > >> > >> Ryan > > > > Hi, Ryan, thanks! Can you be a little more specific > as to how I should try that? I tried: > > > > ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name, > extent=(0,nx/2,ny/2,0)) > > ax.hold(True) > > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1], cmap_name, > extent=(0,nx/2,ny,ny/2)) > > ax.imshow(argW[0:ny/2+1, nx/2+1:-1], cmap_name, > extent=(nx/2,nx,ny/2,0)) > > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1], cmap_name, > extent=(nx/2,nx,ny,ny/2)) > > > > which didn't work (I only got one "corner" - the last > one, I think - i.e., I think it's still just putting > subsequent images on top of prior ones). > > (Putting back on list) Sorry, my (unintentioned) bad. :-( > Based on just a quick look, I'd make sure: > > 1) To set the x and y limits appropriately: > > ax.set_xlim(0, nx) > ax.set_ylim(ny, 0) OK, thanks! > 2) Make sure to use the same colormapping limits, by using > an instance > of normalize: > > # Can also import Normalize from matplotlib.colors > norm = plt.Normalize(datamin, datamax) > ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name, > extent=(0,nx/2,ny/2,0), > norm=norm) > > I'm pretty sure #1 is your problem in seeing, but #2 would > potentially > cause a funky looking image. Right, thanks, I was worried about that, but I thought "one problem at a time." ;-) I'll try it out and report back. DG
On Sun, Feb 28, 2010 at 12:24 PM, David Goldsmith <d_l...@ya...> wrote: > --- On Sat, 2/27/10, Ryan May <rm...@gm...> wrote: > >> From: Ryan May <rm...@gm...> >> Subject: Re: [Matplotlib-users] imshow size limitations? >> To: "David Goldsmith" <d_l...@ya...> >> Cc: "matplotlib-users" <mat...@li...> >> Date: Saturday, February 27, 2010, 7:58 PM >> On Sat, Feb 27, 2010 at 2:23 PM, >> David Goldsmith >> <d_l...@ya...> >> wrote: >> > Question 2) is there some way I can add pieces of the >> array incrementally to >> > the image into their proper place, i.e., modify the >> following code: >> > >> > ax.imshow(image[0:ny/2+1, 0:nx/2+1]) # upper >> left corner of image >> > ax.hold(True) >> > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1]) # lower >> left corner of image >> > ax.imshow(argW[0:ny/2+1, nx/2+1:-1]) # upper >> right corner of image >> > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1]) # lower >> right corner of image >> >> Try the extents keyword argument. It let's you specify the >> corners of >> the image in data coordinates. >> >> Ryan > > Hi, Ryan, thanks! Can you be a little more specific as to how I should try that? I tried: > > ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name, extent=(0,nx/2,ny/2,0)) > ax.hold(True) > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1], cmap_name, extent=(0,nx/2,ny,ny/2)) > ax.imshow(argW[0:ny/2+1, nx/2+1:-1], cmap_name, extent=(nx/2,nx,ny/2,0)) > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1], cmap_name, extent=(nx/2,nx,ny,ny/2)) > > which didn't work (I only got one "corner" - the last one, I think - i.e., I think it's still just putting subsequent images on top of prior ones). (Putting back on list) Based on just a quick look, I'd make sure: 1) To set the x and y limits appropriately: ax.set_xlim(0, nx) ax.set_ylim(ny, 0) 2) Make sure to use the same colormapping limits, by using an instance of normalize: # Can also import Normalize from matplotlib.colors norm = plt.Normalize(datamin, datamax) ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name, extent=(0,nx/2,ny/2,0), norm=norm) I'm pretty sure #1 is your problem in seeing, but #2 would potentially cause a funky looking image. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
xiliu@master:/tmp/matplotlib-0.99.1.1$ python setup.py build ============================================================================ BUILDING MATPLOTLIB matplotlib: 0.99.1.1 python: 2.6 (r26:66714, Nov 3 2009, 17:33:38) [GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] platform: linux2 REQUIRED DEPENDENCIES numpy: 1.3.0 freetype2: 9.20.3 OPTIONAL BACKEND DEPENDENCIES libpng: 1.2.37 Tkinter: Tkinter: 65971, Tk: 8.5, Tcl: 8.5 wxPython: 2.8.10.1 * WxAgg extension not required for wxPython >= 2.8 Gtk+: gtk+: 2.16.6, glib: 2.20.5, pygtk: 2.14.1, pygobject: 2.16.1 Mac OS X native: no Qt: no Qt4: no Cairo: 1.8.2 OPTIONAL DATE/TIMEZONE DEPENDENCIES datetime: present, version unknown dateutil: 1.4.1 pytz: 2008i OPTIONAL USETEX DEPENDENCIES dvipng: no ghostscript: 8.70 latex: 3.141592 pdftops: 0.10.7 [Edit setup.cfg to suppress the above messages] ============================================================================ pymods ['pylab'] packages ['matplotlib', 'matplotlib.backends', 'matplotlib.projections', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', ' matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra', 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.delaunay'] running build running build_py copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.6/matplotlib/mpl-data copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.linux-i686-2.6/matplotlib/mpl-data running build_ext xiliu@master:/tmp/matplotlib-0.99.1.1$ sudo python setup.py install ============================================================================ BUILDING MATPLOTLIB matplotlib: 0.99.1.1 python: 2.6 (r26:66714, Nov 3 2009, 17:33:38) [GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] platform: linux2 REQUIRED DEPENDENCIES numpy: 1.3.0 freetype2: 9.20.3 OPTIONAL BACKEND DEPENDENCIES libpng: 1.2.37 Tkinter: Tkinter: 65971, Tk: 8.5, Tcl: 8.5 wxPython: 2.8.10.1 * WxAgg extension not required for wxPython >= 2.8 Gtk+: gtk+: 2.16.6, glib: 2.20.5, pygtk: 2.14.1, pygobject: 2.16.1 Mac OS X native: no Qt: no Qt4: no Cairo: 1.8.2 OPTIONAL DATE/TIMEZONE DEPENDENCIES datetime: present, version unknown dateutil: 1.4.1 pytz: 2008i OPTIONAL USETEX DEPENDENCIES dvipng: no ghostscript: 8.70 latex: 3.141592 pdftops: 0.10.7 [Edit setup.cfg to suppress the above messages] ============================================================================ pymods ['pylab'] packages ['matplotlib', 'matplotlib.backends', 'matplotlib.projections', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', ' matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra', 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.delaunay'] running install running build running build_py copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.6/matplotlib/mpl-data copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.linux-i686-2.6/matplotlib/mpl-data running build_ext running install_lib copying build/lib.linux-i686-2.6/matplotlib/mpl-data/matplotlibrc -> /usr/lib/python2.6/site-packages/matplotlib/mpl-data copying build/lib.linux-i686-2.6/matplotlib/mpl-data/matplotlib.conf -> /usr/lib/python2.6/site-packages/matplotlib/mpl-data running install_egg_info Removing /usr/lib/python2.6/site-packages/matplotlib-0.99.1.1-py2.6.egg-info Writing /usr/lib/python2.6/site-packages/matplotlib-0.99.1.1-py2.6.egg-info xiliu@master:/tmp/matplotlib-0.99.1.1$ ipython -pylab /usr/lib/python2.6/site-packages/IPython/Magic.py:38: DeprecationWarning: the sets module is deprecated from sets import Set Traceback (most recent call last): File "/usr/bin/ipython", line 28, in <module> IPython.Shell.start().mainloop() File "/usr/lib/python2.6/site-packages/IPython/Shell.py", line 1233, in start return shell(user_ns = user_ns) File "/usr/lib/python2.6/site-packages/IPython/Shell.py", line 1108, in __init__ shell_class=MatplotlibMTShell) File "/usr/lib/python2.6/site-packages/IPython/Shell.py", line 793, in __init__ on_kill=[mainquit]) File "/usr/lib/python2.6/site-packages/IPython/ipmaker.py", line 103, in make_IPython embedded=embedded,**kw) File "/usr/lib/python2.6/site-packages/IPython/Shell.py", line 639, in __init__ user_ns,user_global_ns,b2 = self._matplotlib_config(name,user_ns,user_global_ns) File "/usr/lib/python2.6/site-packages/IPython/Shell.py", line 559, in _matplotlib_config import matplotlib.pylab as pylab File "/usr/lib/python2.6/site-packages/matplotlib/pylab.py", line 206, in <module> from matplotlib import mpl # pulls in most modules File "/usr/lib/python2.6/site-packages/matplotlib/mpl.py", line 3, in <module> from matplotlib import axes File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 24, in <module> import matplotlib.spines as mspines File "/usr/lib/python2.6/site-packages/matplotlib/spines.py", line 17, in <module> class Spine(mpatches.Patch): File "/usr/lib/python2.6/site-packages/matplotlib/spines.py", line 39, in Spine @docstring.dedent_interpd File "/usr/lib/python2.6/site-packages/matplotlib/docstring.py", line 103, in dedent_interpd return interpd(dedent(func)) File "/usr/lib/python2.6/site-packages/matplotlib/docstring.py", line 36, in __call__ func.__doc__ = func.__doc__ and func.__doc__ % self.params KeyError: 'Patch' xiliu@master:/tmp/matplotlib-0.99.1.1$
Would it be possible to have a different alpha (transparency) value for the marker face color and edge color for a single line? (Either currently or as a new feature of mpl). It seems like by default alpha applies to them both. I ask because I am experimenting with getting a different look for the markers by plotting the same points twice, once with a transparent marker face color and then again with a fully opaque thin marker edge and it is a nice effect (see attached image). The problem is, I am doing point picking, and the two-points-at-one-location seems to be making the popup I create slower and occasionally mis-positioned. Although I may be able to work that out, I thought it would be "cleaner" to just have one set of points. Thanks, Che
This is a bug report. I am using matplotlib 0.99.1 on Windows. When using contour with the keyword argument locator=ticker.FixedLocator(levels), the plot is always dropping the first and last contour level. If there are less than 3 levels, contour.py throws an exception. My workaround is to duplicate the first and last levels when using the fixed locator: e.g. my argument becomes locator=FixedLocator( [levels[0]] + levels + [levels[-1]] ) I have traced the problem to the last line in contour.py, method _autolev() which strips the first and last levels if the contours are not filled: return lev[1:-1] This line occurs at line 682 in my version of contour.py which came with the 0.991 installation. I realize that I could specify the levels in the argument V and this does work. However this code is embedded in GUI-ness which allows the user to choose how the contours are selected. Passing the locator seems to be the best option code-wise. Thank you, Dave Smith
2010年2月26日 jamgood96 <jam...@gm...>: > > Each time I try to run a script, it just keeps printing, "The time is: The > time is: Fri Feb 26 13:27:08 2010". over and over. I believe I installed all > the packages correctly, but honesty was a bit overwhelmed. I've tried > attaching a screen shot of what is happening. I wonder why in your py2.6 lib/.../calendar.py on line 6 there is a statement: if prev_time != the_time: In my calendar.py the file starts: """Calendar printing functions Note when comparing these calendars to the ones printed by cal(1): By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European convention). Use setfirstweekday() to set the first day of the week (0=Monday, 6=Sunday).""" import sys import datetime import locale as _locale __all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday", "firstweekday", "isleap", "leapdays", "weekday", "monthrange", "monthcalendar", "prmonth", "month", "prcal", "calendar", "timegm", "month_name", "month_abbr", "day_name", "day_abbr"] ? The thing happens when you import matplotlib.pyplot, which imports matplotlib's cores, which imports calendar from lib/.../site-packages. I can only guess that this calendar.py has been placed there for some reason, overwriting Python's original calendar.py? Friedrich
Things become more and more complicated with time. I come up with four things to consider: First the ring I already mentioned is visualised in attachment Ring.png. A > C > B > A, no z sorting possible, because no linear order anymore. Second, the intersecting line may not always separate a tringle in front as in your example, see "Fourangle".png. Though either the front or the back part of the intersected tringle is always a triangle. Furthemore, I suggest to cut both tringles along the intersection line. This makes things easier to implement, I'm quite convinced. Third, z sorting. How does the current algorithm I didn't understand work? One may consider pict z-sorting.png. For a simple-minded algorithm comparing the center of mass, the triangle in front seems to be at higher z. Fourth, detection of intersection. With the algorithm I proposed, I assume non-intersecting triangles. The problem is how to detect intersection at all. One might think that it's sufficient to check in the corners for inconsistencies with non-intersection. But unfortunataly, it isn't like that. In pict Tricking.png is an example. An algorithm checking the corners will find out that [red] is in front of [green], and nothing more, and hence cannot conclude towards intersection. I have no straightforward idea? One idea more: Not leaving B in your example triangles.png intact, but creating two new planar convex 4-polygons, filling those with triangles is very easy and straightforward. Thus it works out for A and B as pointed out in triangles2.png. Thus 1. detect intersecting triangles and cut them into pieces, second apply z sorting or equivalents? I had implemented z sorting for pairs of triangles already, and would like to compare with the mplot3d algorithmic idea. Using this, one could simply let a sort algorithm of any kind do the job. Apart from that results may look strange when there are rings :-) 2010年2月28日 Ben Axelrod <BAx...@co...>: > Interesting, but I think subdividing triangles like this is unnecessary. For most cases, when one triangle completely covers the other, all that is required it to Z order the triangles. This is what mplot3d does already. The only case we have yet to handle is when one triangle "pierces" the other. As seen in the attached image. Triangle B is mostly behind triangle A, except for a small piece labeled C. All we would have to do is determine the line of intersection, then create a new triangle C. Then we just draw B first, then A, then C. > > I think the hardest part is probably doing this for general polygons and handling the edges properly. But that should not be super hard. Hmm. First I thought: One should create pathes of lines and patches of surfaces. The lines do not need to be z ordered at all, they just have to be z ordered against the surfaces. But that's not sufficient, because lines /on/ surface may be drawn before the surface or not, at random, spoiling the thing. Maybe have for each triangle outline attributes? I guess that's what you had in mind from the beginning. Friedrich
On Fri, Feb 26, 2010 at 5:14 PM, brianjpetersen <bri...@gm...> wrote: > > Hi All, > > I'm a new matplotlib user on a Windows XP machine running mpl0.99.0 under > Python 2.5. I'm using the default rc file. > > While reading through the excellent matplotlib "how-to" tutorial > (http://matplotlib.sourceforge.net/faq/howto_faq.html), I came across two > useful scripts: one to save a figure with a transparent background, and one > to resize axes automatically so that labels aren't cut off. I was able to > run both these examples given on the "how-to" successfully. > > However, I ran into trouble when trying to combine them as follows: > > ===== > > import matplotlib.pyplot as plt > import matplotlib.transforms as mtransforms > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(range(10)) > ax.set_yticks((2,5,7)) > labels = ax.set_yticklabels(('really, really, really', 'long', 'labels')) > > def on_draw(event): > bboxes = [] > for label in labels: > bbox = label.get_window_extent() > # the figure transform goes from relative coords->pixels and we > # want the inverse of that > bboxi = bbox.inverse_transformed(fig.transFigure) > bboxes.append(bboxi) > > # this is the bbox that bounds all the bboxes, again in relative > # figure coords > bbox = mtransforms.Bbox.union(bboxes) > if fig.subplotpars.left < bbox.width: > # we need to move it over > fig.subplots_adjust(left=1.1*bbox.width) # pad a little > fig.canvas.draw() > > return False > > fig.canvas.mpl_connect('draw_event', on_draw) > > plt.savefig('test.png', transparent=True) > > ===== > > In this case, the saved png file is transparent, but the original set of > axes, labels, and plot are visible as well (basically, I have two identical > plots shifted over one another on a transparent background). > > Is there a way to suppress the original output (something akin to > "fig.canvas.erase()" or "fig.canvas.clear()", but I can't seem to figure it > out) so that the output png only shows the shifted axes and not both sets? Interesting! That one really surprised me. It turns out mpl is not clearing the pixel buffer from the previous draw command. Normally you don't see this because the call to draw the figure.patch blanks out the pixel buffer with the background color, but since your figure patch is transparent you can see the legacy. A call to renderer.clear() before drawing again will erase the old image (perhaps we should be doing this by default?) import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.transforms as mtransforms fig = plt.figure() ax = fig.add_subplot(111) ax.plot(range(10)) ax.set_yticks((2,5,7)) labels = ax.set_yticklabels(('really, really, really', 'long', 'labels')) def on_draw(event): bboxes = [] for label in labels: bbox = label.get_window_extent() # the figure transform goes from relative coords->pixels and we # want the inverse of that bboxi = bbox.inverse_transformed(fig.transFigure) bboxes.append(bboxi) # this is the bbox that bounds all the bboxes, again in relative # figure coords bbox = mtransforms.Bbox.union(bboxes) if fig.subplotpars.left < bbox.width: # we need to move it over fig.subplots_adjust(left=1.1*bbox.width) # pad a little fig.canvas.get_renderer().clear() fig.canvas.draw() return False fig.canvas.mpl_connect('draw_event', on_draw) plt.savefig('test.png', transparent=True) JDH
On Sat, Feb 27, 2010 at 11:04 PM, Massimo Di Stefano <mas...@ya...> wrote: > Hi All, > > i've data store in a multydimension numpy.array, > it is composed by 3 MxN normalized (0 - 1) array > but tring to display it using "imshow" i get an error, > " TypeError: Invalid dimensions for image data " > please can you help me to fix this problem ? > my data is : > In [120]: len(dd[0]) > Out[120]: 3 > > In [121]: dd[0].shape > Out[121]: (3, 2058, 2607) > > In [122]: matplotlib.pyplot.imshow(dd[0]) > ------------------------------------------------------------ > Traceback (most recent call last): > File "<ipython console>", line 1, in <module> > File "/Library/Python/2.6/site-packages/matplotlib/pyplot.py", line 2035, > in imshow > ret = ax.imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, > origin, extent, shape, filternorm, filterrad, imlim, resample, url, > **kwargs) > File "/Library/Python/2.6/site-packages/matplotlib/axes.py", line 6272, in > imshow > im.set_data(X) > File "/Library/Python/2.6/site-packages/matplotlib/image.py", line 372, in > set_data > raise TypeError("Invalid dimensions for image data") > TypeError: Invalid dimensions for image data Your image data is 3xMxN, but according to the imshow docstring: " MxNx3 -- RGB (float or uint8 array)" So a quick way is to use the transpose do: matplotlib.pyplot.imshow(dd[0].transpose()) However, this will rotate the image (result will have N rows and M columns), if you're expecting it to have M rows and N columns. In that case, you need to "roll" the axis to the end, which will end up with a 3xMxN array: >>>dd[0].shape (3, 2058, 2607) >>>data2 = np.rollaxis(dd[0], 0, 3) >>>data2.shape (2058, 2607, 3) plt.imshow(data2) Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
Hi All, i've data store in a multydimension numpy.array, it is composed by 3 MxN normalized (0 - 1) array but tring to display it using "imshow" i get an error, " TypeError: Invalid dimensions for image data " please can you help me to fix this problem ? my data is : In [119]: dd[0] Out[119]: array([[[ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], ..., [ 0.22834646, 0.39370079, 0.38976378, ..., 0.2519685 , 0.25590551, 0.38582677], [ 0.30708661, 0.25984252, 0.30314961, ..., 0.2480315 , 0.25984252, 0.37401575], [ 0.58661417, 0.62598425, 0.5984252 , ..., 0.2480315 , 0.2519685 , 0.32283465]], [[ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], ..., [ 0.17322835, 0.37401575, 0.4015748 , ..., 0.27952756, 0.27559055, 0.42519685], [ 0.30314961, 0.24409449, 0.30314961, ..., 0.26771654, 0.27165354, 0.38976378], [ 0.57086614, 0.61811024, 0.5984252 , ..., 0.28346457, 0.26771654, 0.34251969]], [[ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], [ 1. , 1. , 1. , ..., 1. , 1. , 1. ], ..., [ 0.19685039, 0.34251969, 0.37795276, ..., 0.2519685 , 0.25984252, 0.34251969], [ 0.27165354, 0.21653543, 0.27559055, ..., 0.2519685 , 0.26377953, 0.30708661], [ 0.57480315, 0.63385827, 0.58661417, ..., 0.26377953, 0.25590551, 0.29527559]]]) In [120]: len(dd[0]) Out[120]: 3 In [121]: dd[0].shape Out[121]: (3, 2058, 2607) In [122]: matplotlib.pyplot.imshow(dd[0]) ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> File "/Library/Python/2.6/site-packages/matplotlib/pyplot.py", line 2035, in imshow ret = ax.imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs) File "/Library/Python/2.6/site-packages/matplotlib/axes.py", line 6272, in imshow im.set_data(X) File "/Library/Python/2.6/site-packages/matplotlib/image.py", line 372, in set_data raise TypeError("Invalid dimensions for image data") TypeError: Invalid dimensions for image data thanks for any help!!! Massimo.
Interesting, but I think subdividing triangles like this is unnecessary. For most cases, when one triangle completely covers the other, all that is required it to Z order the triangles. This is what mplot3d does already. The only case we have yet to handle is when one triangle "pierces" the other. As seen in the attached image. Triangle B is mostly behind triangle A, except for a small piece labeled C. All we would have to do is determine the line of intersection, then create a new triangle C. Then we just draw B first, then A, then C. I think the hardest part is probably doing this for general polygons and handling the edges properly. But that should not be super hard. -Ben ________________________________________ From: Friedrich Romstedt [fri...@gm...] Sent: Saturday, February 27, 2010 11:28 AM To: matplotlib-users Subject: Re: [Matplotlib-users] mplot3d stays? http://www.friedrichromstedt.org/python/pyclip/a01.Zerteilung.pdf (It's unfortunately in german, but the graphics are self-explaining) A school mate working together with me on the project has worked that out. H = number of corners of the front triangle lying inside of the back triangle V = number of corners of the back triangle lying inside of the front triangle S = number of the collinear edges of the two triangles Z = number of intersection points of the two tringles' edges, minus the number of those occuring because of collinear edges. Red: front triangle Black: back triangle Green: subdivision lines in the back triangle. I will check my implementation in C++ today. I will maybe need some advice in making a Python module out of it. Friedrich ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users
On Sat, Feb 27, 2010 at 2:23 PM, David Goldsmith <d_l...@ya...> wrote: > Question 2) is there some way I can add pieces of the array incrementally to > the image into their proper place, i.e., modify the following code: > > ax.imshow(image[0:ny/2+1, 0:nx/2+1]) # upper left corner of image > ax.hold(True) > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1]) # lower left corner of image > ax.imshow(argW[0:ny/2+1, nx/2+1:-1]) # upper right corner of image > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1]) # lower right corner of image Try the extents keyword argument. It let's you specify the corners of the image in data coordinates. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
If I read your correctly, for l, b in zip(x, y): # And here I work with data coordinates (!) dashBox = Bbox.from_bounds(l, b, width+5, height+5) badness = 0 for line in lines: if line.intersects_bbox(dashBox): badness += 1 x, y (therefore l, b) in data coordinate. width, height?? this seems to be some wx specific coordinate, i have no idea. lines (therefore line) in display coordinate. converting x,y to display coordinate should straight forward. But I'm not sure what kind of coordinate width and height has. Is it a method of some class derived from matplotlib's Text?? If then, the extent of the text can be measured using the get_window_extent method. This requires a renderer instance, which should be known if the method is called during the drawing time. Again, post a complete but simple(!) code. -JJ On Sat, Feb 27, 2010 at 8:59 PM, Andrea Gavana <and...@gm...> wrote: > On 28 February 2010 01:18, Jae-Joon Lee wrote: >> On Sat, Feb 27, 2010 at 12:29 PM, Andrea Gavana <and...@gm...> wrote: >>> This code is not doing anything useful as I always get a badness of 0, >>> although I can see that the new text overlaps quite a lot of other >>> artists. >>> >>> Does anyone have some suggestion on how to improve the code? >>> >> >> A snippet of code seldom helps. >> Is your x,y input in display coordinates? > > No, data values. > >> Ideally, this must be checked in the drawing time (as in the legend). > > This is what I am trying to do, but I messed up screen/data/canvas > coordinates and I can't get my head around it :-( > > Andrea. > > "Imagination Is The Only Weapon In The War Against Reality." > http://xoomer.alice.it/infinity77/ > http://thedoomedcity.blogspot.com/ >
On 28 February 2010 01:18, Jae-Joon Lee wrote: > On Sat, Feb 27, 2010 at 12:29 PM, Andrea Gavana <and...@gm...> wrote: >> This code is not doing anything useful as I always get a badness of 0, >> although I can see that the new text overlaps quite a lot of other >> artists. >> >> Does anyone have some suggestion on how to improve the code? >> > > A snippet of code seldom helps. > Is your x,y input in display coordinates? No, data values. > Ideally, this must be checked in the drawing time (as in the legend). This is what I am trying to do, but I messed up screen/data/canvas coordinates and I can't get my head around it :-( Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ http://thedoomedcity.blogspot.com/
On Sat, Feb 27, 2010 at 12:29 PM, Andrea Gavana <and...@gm...> wrote: > This code is not doing anything useful as I always get a badness of 0, > although I can see that the new text overlaps quite a lot of other > artists. > > Does anyone have some suggestion on how to improve the code? > A snippet of code seldom helps. Is your x,y input in display coordinates? Ideally, this must be checked in the drawing time (as in the legend). With your current approach, there could be lots of possible reason that this does not work. Regards, -JJ
Did you try to turn off "useblit" option? As mentioned in the comment, that option is only supported in the agg backend. Regards, -JJ On Thu, Feb 25, 2010 at 10:45 PM, David Arnold <dwa...@su...> wrote: > All, > > I tried this code from: http://matplotlib.sourceforge.net/examples/widgets/cursor.py > > from matplotlib.widgets import Cursor > import pylab > > > fig = pylab.figure(figsize=(8,6)) > ax = fig.add_axes([0.075, 0.25, 0.9, 0.725], axisbg='#FFFFCC') > #ax = fig.add_subplot(111, axisbg='#FFFFCC') > canvas = ax.figure.canvas > > x,y = 4*(pylab.rand(2,100)-.5) > ax.plot(x,y,'o') > ax.set_xlim(-2,2) > ax.set_ylim(-2,2) > > # set useblit = True on gtkagg for enhanced performance > cursor = Cursor(ax, useblit=True, color='red', linewidth=2 ) > > pylab.show() > > I got this error on my Macbook Pro: > > The debugged program raised the exception unhandled AttributeError > "'FigureCanvasMac' object has no attribute 'copy_from_bbox'" > > Any suggestions? > > David > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
It seems that you must turn off autoFontsize first. the_table.auto_set_font_size(False) then change th font size. the_table.set_fontsize(10) -JJ On Thu, Feb 25, 2010 at 12:48 PM, afancy <gr...@gm...> wrote: > Hi, > > I want to generate a graph with line, and table at the bottom. However, I > found that the fontsize is very small and it is unchangeable. Could anybody > help me? thanks > > Regards > afancy > > > fig=figure() > > ax=fig.add_subplot(111) > > data=( > (0.529, 0.612, 0.855, 0.178, 1.432, 6.43, 41.311, 1.62, > 71.012, 1.59, 0.271, 0.066, 4.721), > (0.014, 0.512, 0.015, 0.161, 1.177, 6.793, 0.089, 1.495, > 25.65, 0.014, 0.045, 0.052, 5.423), > (0.493, 834.351, 0.156, 743.193,0.428, 84.101, 1058.062,8.652, > 1023, 0.168, 7.101, 8.135, 152.646), > (118.90,2035.35, 89.35, 15.402, 10.856,110.049,3024.42, > 8054.74,5214.36, 5.539, 11.539, 515.632,150.411) > ) > > rowLabels=['row1','row2', 'row3', 'row4'] > > colLabels=['Q%d'%(x+1) for x in range(13)] > > the_table = table(cellText=txtdata, rowLabels=rowLabels, > colLabels=colLabels, loc='bottom') > > the_table.set_fontsize(20.0) > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
I believe it is not just the size of font but the font itself should match. Depending on your setting, the tex file generated by matplotlib include preambles related with font setting. For example, below is mine. \documentclass{article} \usepackage{type1cm} \renewcommand{\rmdefault}{pnc} \usepackage{helvet} \usepackage{courier} \usepackage{textcomp} \usepackage{ucs} \usepackage[utf8x]{inputenc} And of course, the output is different from the output without these preambles. So when you say, On Fri, Feb 26, 2010 at 5:09 AM, Freddie Witherden <fr...@wi...> wrote: > Does anyone know what might be causing this? The document font sizes are the > same and I tried to match the LaTeX file as closely as possible to the one used > internally by matplotlib. > Did you match those font preambles also? Also, is it just the pdf backend? What about other backend? Regards, -JJ
Hi, folks! I'm again encountering the problem - imshow generating a MemoryError exception trying to image a very large array - discussed in this thread I started almost a year and a half ago. Question 1) has anything changed in MPL in that time interval which would provide an "easy" solution? Question 2) is there some way I can add pieces of the array incrementally to the image into their proper place, i.e., modify the following code: ax.imshow(image[0:ny/2+1, 0:nx/2+1]) # upper left corner of image ax.hold(True) ax.imshow(argW[ny/2+1:-1, 0:nx/2+1]) # lower left corner of image ax.imshow(argW[0:ny/2+1, nx/2+1:-1]) # upper right corner of image ax.imshow(argW[ny/2+1:-1, nx/2+1:-1]) # lower right corner of image so that each subsequent imshow doesn't cover up the previous imshow and is placed in the right place relative to each of the other pieces? Question 3) Would such incremental addition work to get around the memory limit, or does the fact (if the following statement is in fact correct) that eventually the entire too-large image needs to be handled doom this strategy to failure? Question 4) would I have this problem if I was running 64 bit (i.e., OS, as well as 64 bit builds of Python, numpy, MPL, etc.), i.e., is it most likely a memory addressing problem? Question 5) can anyone suggest any other work-around(s)? Thanks! DG On Sat, Sep 6, 2008 at 4:00 PM, David Goldsmith <d_l...@ya...>wrote: > Ah, Ich verstehe now. I'll try RGBA-ing it; in the meantime, let me know > if the colormapping conversion gets changed to 32 bit. Thanks again! > > DG > > --- On Sat, 9/6/08, Eric Firing <ef...@ha...> wrote: > > > From: Eric Firing <ef...@ha...> > > Subject: Re: [Matplotlib-users] imshow size limitations? > > To: d_l...@ya... > > Cc: mat...@li... > > Date: Saturday, September 6, 2008, 3:13 PM > > David Goldsmith wrote: > > > Thanks, Eric! > > > > > > --- On Sat, 9/6/08, Eric Firing > > <ef...@ha...> wrote: > > > > > > -- snip OP -- > > > > > >> It looks to me like you simply ran out of > > memory--this is > > >> not an imshow > > >> problem as such. Your array is about 1e8 > > elements, and as > > >> floats that > > >> would be close to a GB--just for that array alone. > > Do you > > > > > > Well, I anticipated that, so I do initialize the > > storage for the numpy array as numpy.uint8 and have > > confirmed that the data in the array returned by the > > function which creates it remains numpy.uint8, so it should > > "only" be ~100MB (indeed, the .na file into which > > I tofile it is 85,430 KB, just as it should be for a 10800 x > > 8100 array of uint8 elements). And the ax.imshow statement > > doesn't (directly) cause the crash (but I don't know > > that it isn't making either a float copy or an in-place > > conversion of the array). So, AFAIK, right up until the > > statement: > > > > > > canvas.print_figure('HiResHex') > > > > > > the data being imaged are all numpy.uint8 type. > > > > Yes, but it looks to me like they are still getting > > color-mapped, and > > this requires conversion to numpy.float. This may be a bad > > aspect of > > the mpl design, but it is quite deeply embedded. I suspect > > the best we > > could do would be to use float32 instead of float64; > > certainly for color > > mapping one does not need 64 bits. > > > > Using numpy.uint8 helps only if you are specifying RGBA > > directly, > > bypassing the colormapping. > > > > > > > >> really need > > >> all that resolution? > > > > > > Well, there's the rub: I fancy myself a fractal > > "artist" and I have > > > access to an HP DesignJet 500ps plotter with a maximum > > resolution of > > > 1200 x 600 dpi. For the size images I'm trying to > > make (I'm hoping to go > > > even bigger than 36" x 27", but I figured > > that as a good starting point) > > > even I regard _that_ resolution as too much - I was > > thinking of 300 x > > > 300 dpi (which is its "normal" resolution) > > as certainly worthy of giving > > > a try. :-) > > > > >> If you do, you will probably have to > > >> get a much > > >> more capable machine. > > > > > > Possible, but I was hoping to generate at least one > > "proof" first to determine how hard I'd need > > to try. > > > > > >> Otherwise, you need to knock down > > >> the size of > > >> that array before trying to plot or otherwise > > manipulate > > >> it. > > > > > > Forgive me, but I'd like a more detailed > > explanation as to why: I > > > have > > > ample (~35 GB, just on my built-in disc, much more > > than that on external > > > discs) harddisc space - isn't there some way to > > leverage that? > > > > I don't know enough about virtual memory > > implementations--especially on > > Win or Mac--to say. In practice, I suspect you would find > > that as soon > > as you are doing major swapping during a calculation, you > > will thrash > > the disk until you run out of patience. > > > > > > >> With respect to imshow, probably you can get it to > > handle > > >> larger images > > > > > > Again, imshow doesn't appear to be the culprit > > (contrary to my > > > original subject line), rather it would appear to be > > > canvas.print_figure. (While I'm on the subject of > > canvas.print_figure, > > > isn't there some way for MPL to "splash" > > the image directly to the > > > screen, without first having to write to a file? I > > didn't ask this > > > before because I did eventually want to write the > > image to a file, but I > > > would prefer to do so only after I've had a look > > at it.) > > > > It is imshow in the sense that most of the action in mpl > > doesn't happen > > when you call imshow or plot or whatever--they just set > > things up. The > > real work is done in the backend when you display with > > show() or write > > to a file. > > > > > > >> if you feed them in as NxMx4 numpy.uint8 RGBA > > arrays--but I > > >> doubt this > > >> is going to be enough, or the right approach, for > > your > > >> present situation. > > > > > > Right: I don't see how that would be better than > > having a single 8 > > > bit > > > datum at each point w/ color being determined from a > > color map (which is > > > how I'd prefer to do it anyway). > > > > The way it is better is that it avoids a major operation, > > including the > > generation of the double-precision array. The rgba array > > can go > > straight to agg. > > > > Eric > > > > > > > Thanks again, > > > > > > DG > > >> Eric > > >> > > >>> Platform Details: MPL 0.91.2 (sorry, I > > didn't > > >> realize I was running such an old version, maybe I > > just need > > >> to upgrade?), Python 2.5.2, Windows XP 2002 SP3, > > 504MB > > >> physical RAM, 1294MB VM Page size (1000MB init., > > 5000MB max) > > >>> Thanks! > > >>> > > >>> DG > > > >
Hi All, I am trying to visualize some more text in an already rather crowded 2D plot. As this new information I want to display is optional (it depends on a use choice) but possibly very useful as information, I would like to add it as text inside my plot, and possibly to add it in a "smart" way (i.e., with minimum or no overlapping between this new text and the rest of the plot, like legend does with loc=0). Now, I have tried to steal the code from legend.py but I am not getting anywhere, also because I am mixing display coordinates, data coordinates and wx.DC text extents and I am getting crazy :-( This is the code I have so far: def PositionAnnotation(self, dc, label, dash, x, y): """ Position a matplotlib text instance without overlapping with the rest of the data. :param `dc`: an instance of wx.ClientDC; :param `label`: the label to display (2 lines of text); :param `dash`: the actual TextWithDash matplotlib class to position :param `x`: a list of possible x location (this is fixed) :param `y`: a list of possible y location (this is fixed) """ # Stolen from legend.py lines = [] # Here I work with display coordinates (!) for handle in self.leftaxis.lines: path = handle.get_path() trans = handle.get_transform() tpath = trans.transform_path(path) lines.append(tpath) # End of stolen from legend.py # Here I work with screen/character coordinates (!) width, height, dummy = dc.GetMultiLineTextExtent(label) candidates = [] for l, b in zip(x, y): # And here I work with data coordinates (!) dashBox = Bbox.from_bounds(l, b, width+5, height+5) badness = 0 for line in lines: if line.intersects_bbox(dashBox): badness += 1 ox, oy = l, b if badness == 0: return ox, oy candidates.append((badness, (l, b))) # Stolen from legend.py # rather than use min() or list.sort(), do this so that we are assured # that in the case of two equal badnesses, the one first considered is # returned. # NOTE: list.sort() is stable.But leave as it is for now. -JJL minCandidate = candidates[0] for candidate in candidates: if candidate[0] < minCandidate[0]: minCandidate = candidate ox, oy = minCandidate[1] return ox, oy This code is not doing anything useful as I always get a badness of 0, although I can see that the new text overlaps quite a lot of other artists. Does anyone have some suggestion on how to improve the code? Thank you in advance. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ http://thedoomedcity.blogspot.com/
http://www.friedrichromstedt.org/python/pyclip/a01.Zerteilung.pdf (It's unfortunately in german, but the graphics are self-explaining) A school mate working together with me on the project has worked that out. H = number of corners of the front triangle lying inside of the back triangle V = number of corners of the back triangle lying inside of the front triangle S = number of the collinear edges of the two triangles Z = number of intersection points of the two tringles' edges, minus the number of those occuring because of collinear edges. Red: front triangle Black: back triangle Green: subdivision lines in the back triangle. I will check my implementation in C++ today. I will maybe need some advice in making a Python module out of it. Friedrich
Hi, I am a fan of the STIX sans serif typeface for mathtext, but I was wondering if it was possible to use this typeface for non-mathtext text as well. My main use for this is ticklabels, which seem to render in the non-mathtext font no matter what I do. I have tried using ax.xaxis.set_major_formatter(P.ScalarFormatter(useMathText=True)) to force the (scalar) major ticks to use mathtext and thus stixsans, but this does not work. Am I doing something wrong here? A better solution (for me) would be to use STIX sans serif faces as the regular font, ie something like rcParams["font.sans-serif"] = 'stixsans' I know this is possible for serif fonts, and I know that a post to the list back in 2008 noted that it was not (at that time) possible for sans-serifs. I am curious to know if there has been any progress on allowing STIX sans-serifs in non-mathtext text. thanks, Jeff Oishi
All, On: http://matplotlib.sourceforge.net/users/artists.html In the Axes Container section, you can see in what follows that I got some very different responses than what is shown on the page: In [1]: fig=figure() In [3]: ax=fig.add_subplot(111) In [4]: rect=matplotlib.patches.Rectangle((1,1),width=5,height=12) In [5]: print rect.get_axes() ------> print(rect.get_axes()) None In [6]: print rect.get_transform() ------> print(rect.get_transform()) BboxTransformTo(Bbox(array([[ 1., 1.], [ 6., 13.]]))) In [7]: ax.add_patch(rect) Out[7]: <matplotlib.patches.Rectangle object at 0x2144db0> In [8]: print rect.get_axes() ------> print(rect.get_axes()) Axes(0.125,0.1;0.775x0.8) In [9]: print rect.get_transform() ------> print(rect.get_transform()) CompositeGenericTransform(BboxTransformTo(Bbox(array([[ 1., 1.], [ 6., 13.]]))), CompositeGenericTransform(TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())), CompositeAffine2D(BboxTransformFrom(TransformedBbox(Bbox(array([[ 0., 0.], [ 1., 1.]])), TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())))), BboxTransformTo(TransformedBbox(Bbox(array([[ 0.125, 0.1 ], [ 0.9 , 0.9 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]]))))))))) In [10]: print ax.transData -------> print(ax.transData) CompositeGenericTransform(TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())), CompositeAffine2D(BboxTransformFrom(TransformedBbox(Bbox(array([[ 0., 0.], [ 1., 1.]])), TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())))), BboxTransformTo(TransformedBbox(Bbox(array([[ 0.125, 0.1 ], [ 0.9 , 0.9 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]])))))))) In [11]: print ax.get_xlim() -------> print(ax.get_xlim()) (0.0, 1.0) In [12]: print ax.dataLim.get_bounds() -------> print(ax.dataLim.get_bounds()) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/6.0.0/Examples/matplotlib-0.99.1.1/event_handling/<ipython console> in <module>() AttributeError: 'Bbox' object has no attribute 'get_bounds' In [13]: ax.autoscale_view() In [14]: print ax.get_xlim() -------> print(ax.get_xlim()) (1.0, 6.0) In [15]: ax.figure.canvas.draw() David.