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
(7) |
2
(8) |
|
3
(3) |
4
(5) |
5
(2) |
6
(3) |
7
(4) |
8
(11) |
9
(4) |
|
10
|
11
(8) |
12
(10) |
13
(16) |
14
(14) |
15
(13) |
16
(1) |
|
17
|
18
(8) |
19
(6) |
20
(13) |
21
(15) |
22
(5) |
23
(13) |
|
24
(2) |
25
(4) |
26
(1) |
27
(4) |
28
(8) |
29
(11) |
30
(5) |
|
31
(3) |
|
|
|
|
|
|
|
From: denoise <hub...@pa...> - 2011-07-28 10:42:01
|
Hi there, i'd like to plot a data series with signal values over timestamps, what works perfectly. But if I want to display 2 series with different time domains, theres a gap in between. For example my first set of data is from time (x) 1-3 and the second from 7-8. If I send the mixed array to the plot, I will receive something like that: y| x x x x x x x| 0 1 2 3 4 5 6 7 8 9 10 11 But if there is considerably more time between the to data sets, it soon will look confusing. What i need is a graph over this: y| x x x x x x x| 1 2 3 7 8 9 Of course I could do this with 2 subplots, but i want to scroll over a whole set of data. Is it possible wih matplotlib, or is there a workaround? Thanks! Hubert -- View this message in context: http://old.nabble.com/plot-with-discontinuous-x-axis-tp32155499p32155499.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Till S. <mai...@gm...> - 2011-07-28 05:55:23
|
Hi, try if: gcf().set_frameon(False) helps. greetings Till |
|
From: Andrea P. <an...@bi...> - 2011-07-27 15:35:56
|
Great. Thank you. I will check the master branch before reporting next time. Andrea > On Wed, Jul 27, 2011 at 10:07 AM, Andrea Pierleoni > <an...@bi...>wrote: > >> Hi all, >> >> I found that a matplotlib.text.Text istance reports wrong coordinates >> when >> converted to str >> I'm using version 1.0.1 >> >> this is the code in Text class: >> >> def __str__(self): >> return "Text(%g,%g,%s)"%(self._y,self._y,repr(self._text)) >> >> it is clearly reporting two times the y coordinates, and should be: >> >> def __str__(self): >> return "Text(%g,%g,%s)"%(self._x,self._y,repr(self._text)) >> >> >> I'm sorry if this is not the correct plase to report the bug, but I've >> not >> been able to find >> a bugtracker for matplotlib. >> >> Andrea >> >> > Andrea, > > Thanks for reporting. I recently spotted this bug and fixed it in the > master branch. > > Ben Root > |
|
From: Benjamin R. <ben...@ou...> - 2011-07-27 15:28:38
|
On Wed, Jul 27, 2011 at 10:07 AM, Andrea Pierleoni <an...@bi...>wrote: > Hi all, > > I found that a matplotlib.text.Text istance reports wrong coordinates when > converted to str > I'm using version 1.0.1 > > this is the code in Text class: > > def __str__(self): > return "Text(%g,%g,%s)"%(self._y,self._y,repr(self._text)) > > it is clearly reporting two times the y coordinates, and should be: > > def __str__(self): > return "Text(%g,%g,%s)"%(self._x,self._y,repr(self._text)) > > > I'm sorry if this is not the correct plase to report the bug, but I've not > been able to find > a bugtracker for matplotlib. > > Andrea > > Andrea, Thanks for reporting. I recently spotted this bug and fixed it in the master branch. Ben Root |
|
From: Andrea P. <an...@bi...> - 2011-07-27 15:24:39
|
Hi all,
I found that a matplotlib.text.Text istance reports wrong coordinates when
converted to str
I'm using version 1.0.1
this is the code in Text class:
def __str__(self):
return "Text(%g,%g,%s)"%(self._y,self._y,repr(self._text))
it is clearly reporting two times the y coordinates, and should be:
def __str__(self):
return "Text(%g,%g,%s)"%(self._x,self._y,repr(self._text))
I'm sorry if this is not the correct plase to report the bug, but I've not
been able to find
a bugtracker for matplotlib.
Andrea
|
|
From: Hugo H. P. S. <hu...@gm...> - 2011-07-27 09:37:44
|
After the tip from Ben Roots and a little tinkering with the matplotlib backends I've solved this issue by changing the backend from the default MacOSX to TkAgg. BTW, the default matplotlibrc file in my case was located at: /Library/Frameworks/Python.framework/Versions/X.X/lib/pythonX-X/site-packages/matplotlib/mpl-data/matplotlibrc Thank's, Hugo Silva Hugo H. P. Silva wrote: > > Hi all, > > In a prior installation of matplotlib I recall being able to have > real-time pan/zoom plot update while dragging the mouse (not only after > releasing the left/right button). > > I've just updated my Python and PyLab configurations and now matplotlib > only updates the plot after releasing the left/right button. > > Can anyone point me to a possible solution for this issue? > > Best regards, > Hugo Silva > -- View this message in context: http://old.nabble.com/Matplotlib-Dynamic-Drag-Pan-Zoom-tp32128170p32146578.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Jeffrey S. <jef...@gm...> - 2011-07-26 14:17:02
|
I had posted this question at the link below that contains the code and an example figure. As stated in the title, I am looking to get scientific notation on the minorFormatter. I use a custom minor formatter function. Also, this text seems bigger than the standard major formatter label size. I was wondering how to specify the minor formatter text size. Link: http://stackoverflow.com/questions/6828825/plotting-scientific-format-on-the-axis-label-and-different-size-minor-formatter-t Cheers, Jeff -- ________________________ Jeffrey Spencer jef...@gm... |
|
From: Andrew U. <acu...@lb...> - 2011-07-25 21:50:03
|
Greetings, I was just working through the build/install details for matplotlib on Mac OSX 10.6.8, and building against Python 2.7.1. The reported problem with TK version numbers prevented me from doing "easy_install", and the suggested alternative was to get the latest source (grumble). The recommended command line: > make -f make.osx PREFIX=<directory> PYVERSION=2.7 fetch deps mpl_install_std Invokes the building of dependencies, which is fine, except that one of them appears to have a problem: ... rm -rf libpng-1.5.1 &&\ tar xvfz libpng-1.5.1.tar.gz && \ cd libpng-1.5.1 &&\ ./configure --disable-dependency-tracking --prefix=/Users/uselton/src/python &&\ make -j3 install tar: Unrecognized archive format: Inappropriate file type or format tar: Error exit delayed from previous errors. A little effort seemed to suggest that the file in question really was not a gzipped tar file. I did not work too hard to discover why that is. I went and got an honest version of libpng-1.5.1.tar.gz and did the "configure;make install", which worked fine. A subsequent invocation of the above matplotlib build line, but without the "deps" also appeared to work. I have since used matplotlib in a simple test and it seemed to work fine. Others who have this problem may be interested that I did get around it. Maintainers may want to take a look with whats up with the automatically downloaded libpng-1.5.1.tar.gz. Cheers, Andrew |
|
From: Ben B. <bbr...@gm...> - 2011-07-25 18:21:42
|
I think that I have found the problem here. Line2D.draw() (and I presume other Artist subclasses) calls gc.set_foreground(self._color) ... gc.set_alpha(self._alpha) self._color is defined by the color kwarg, whether it be a hex value, 3-tuple, 4-tuple, or something else. self._alpha is defined by the alpha kwarg, but if the alpha kwarg is None, it is not overwritten with color[3]. Therefore, using color=(R,G,B,A) does not set alpha correctly. I'm not sure the best (i.e. most matplotlib-like) way to change this so that the A value gets used iff alpha is None, but I've attached a patch that does it one way (diff'ed against the github master, commit 67b1cd650f574f9c53ce). I know the patch is less than ideal, as it adds kwarg-specific handling into a place where none had previously been done, and it's also in a for loop. Maybe it would be better to do the checking along with the scalex and scaley pops? Separately, I noticed that backend_bases.GraphicsContextBase.set_foreground claims to only expect an RGB definition, and not an RGBA definition. As such, I think that it should call self._rgb = colors.colorConverter.to_rgb(fg) instead of self._rgb = colors.colorConverter.to_rgba(fg) since that will make self._rgb a 3-tuple instead of a 4-tuple. Ben On Sat, Jul 23, 2011 at 3:13 PM, Ben Breslauer <bbr...@gm...> wrote: > Hi, > > I'm trying to fade some data, using alpha values, that I am plotting with > Axes.plot(). I can recreate this problem with 1 line of pylab.plot. If I > use > > pylab.plot([1,2,3],[1,4,9], color=(1,0,0,.2), linewidth=7) > > then I get the equivalent of > > pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7) > > i.e. it does not use the alpha value. However, if instead I use > > pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7, alpha=.2) > > then the line is faded out appropriately. The plot documentation indicates > that RGBA tuples should be valid, so I'm wondering if this is a bug. Maybe > alpha is defaulting to 1 or None and then not being overwritten if color is > a 4-tuple? > > I'm using Arch Linux with kernel 2.6.39, matplotlib 1.0.1 from the Arch > repo, and the Qt4 backend. My installed Qt version is 4.7.3, and I am using > KDE 4.6.5. Below is verbose-debug output. Thanks for any help! > > Ben > > > $HOME=/home/ben > CONFIGDIR=/home/ben/.matplotlib > matplotlib data path /usr/lib/python2.7/site-packages/matplotlib/mpl-data > loaded rc file > /usr/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc > matplotlib version 1.0.1 > verbose.level debug > interactive is False > units is False > platform is linux2 > loaded modules: ['heapq', 'numpy.core.info', 'distutils', > 'numpy.lib.format', 'functools', 'pylab', '_bisect', 'subprocess', > 'sysconfig', 'gc', 'matplotlib.tempfile', 'distutils.sysconfig', > 'ctypes._endian', 'encodings.encodings', 'pyparsing', 'matplotlib.colors', > 'numpy.core.numerictypes', 'numpy.testing.sys', 'numpy.lib.__future__', > 'numpy.fft.types', 'numpy.ma.cPickle', 'struct', > 'numpy.matrixlib.defmatrix', 'numpy.random.info', 'tempfile', > 'numpy.compat.types', 'pprint', 'numpy.linalg', 'matplotlib.threading', > 'numpy.core.machar', 'numpy.testing.types', 'numpy.testing', 'collections', > 'numpy.polynomial.sys', 'unittest.sys', 'numpy.core.umath', 'unittest.main', > 'distutils.types', 'numpy.testing.operator', 'numpy.core.scalarmath', > 'numpy.ma.sys', 'zipimport', 'string', 'matplotlib.subprocess', > 'numpy.testing.os', 'unittest.functools', 'numpy.lib.arraysetops', > 'numpy.testing.unittest', 'numpy.lib.math', 'encodings.utf_8', > 'matplotlib.__future__', 'unittest.types', 'unittest.util', ' > numpy.testing.re', 'numpy.version', 'numpy.lib.re', 'distutils.re', > 'numpy.matrixlib.sys', 'ctypes.os', 'numpy.core.os', 'numpy.lib.type_check', > 'numpy.compat.sys', 'unittest.StringIO', 'bisect', 'numpy.core._internal', > 'signal', 'numpy.lib.types', 'numpy.lib._datasource', 'random', > 'numpy.lib.__builtin__', 'numpy.fft.fftpack_lite', 'matplotlib.cbook', > 'textwrap', 'numpy.core.multiarray', 'numpy.polynomial.string', > 'distutils.version', 'cStringIO', 'numpy.polynomial', 'numpy.numpy', > 'matplotlib.StringIO', 'unittest.time', 'locale', 'numpy.add_newdocs', > 'unittest.difflib', 'numpy.core.getlimits', 'base64', '_ssl', > 'numpy.lib.sys', 'encodings', 'numpy.ma.itertools', 'unittest.pprint', ' > unittest.re', 'abc', 'numpy.matrixlib', 'numpy.ctypes', > 'numpy.testing.decorators', 'matplotlib.warnings', 'rfc822', > 'numpy.lib.npyio', 'numpy.lib.numpy', 'matplotlib.sys', 're', > 'numpy.lib._compiled_base', 'numpy.polynomial.legendre', 'threading', 'new', > 'numpy.ma.warnings', 'numpy.random.mtrand', 'urllib2', 'matplotlib.cPickle', > 'math', 'numpy.fft.helper', 'fcntl', 'unittest.case', 'matplotlib.numpy', > 'UserDict', 'unittest.suite', 'numpy.lib.function_base', 'distutils.os', > 'matplotlib', 'numpy.fft.numpy', 'exceptions', 'numpy.lib.info', 'ctypes', > 'numpy.lib.warnings', 'ctypes.struct', 'codecs', 'numpy.core._sort', > 'numpy.os', 'unittest.loader', '_functools', '_locale', 'numpy.__builtin__', > 'matplotlib.os', 'thread', 'StringIO', 'numpy.core.memmap', 'traceback', > 'numpy.testing.warnings', 'weakref', 'itertools', 'numpy.fft.fftpack', > 'numpy.linalg.lapack_lite', 'numpy.ma', 'distutils.sys', 'os', 'marshal', > 'numpy.lib.itertools', '__future__', '_collections', 'urllib', > 'matplotlib.traceback', '_sre', 'unittest', 'numpy.core.sys', > 'numpy.random', 'numpy.linalg.numpy', '__builtin__', > 'numpy.lib.twodim_base', 'numpy.ma.core', 'matplotlib.re', > 'numpy.core.cPickle', 'unittest.runner', 'operator', > 'numpy.polynomial.polytemplate', 'numpy.core.arrayprint', > 'distutils.string', 'numpy.lib.arrayterator', 'select', 'ctypes._ctypes', > '_heapq', 'ctypes.sys', 'matplotlib.errno', 'unittest.collections', > 'posixpath', 'numpy.lib.financial', 'numpy.polynomial.laguerre', > 'matplotlib.random', 'errno', '_socket', 'binascii', 'sre_constants', > 'datetime', 'numpy.core.shape_base', 'os.path', 'numpy.core.function_base', > 'numpy.compat.py3k', 'numpy.lib.stride_tricks', 'numpy.core.numpy', 'numpy', > '_warnings', 'numpy.polynomial.chebyshev', 'matplotlib.types', 'cPickle', > 'encodings.__builtin__', 'numpy.polynomial.warnings', 'matplotlib.new', > '_codecs', 'numpy.lib.operator', 'unittest.fnmatch', > 'numpy.polynomial.polynomial', 'numpy.__config__', 'pwd', > 'matplotlib.pyparsing', 'httplib', 'numpy.lib.ufunclike', 'copy', ' > numpy.core.re', '_struct', 'numpy.core.fromnumeric', 'hashlib', > 'numpy.ctypeslib', 'keyword', 'array', 'numpy.lib.scimath', 'numpy.fft', > 'numpy.lib', 'numpy.ma.numpy', 'numpy.random.numpy', 'matplotlib.urllib2', > 'unittest.weakref', 'numpy.ma.extras', 'numpy.polynomial.__future__', > 'posix', 'encodings.aliases', 'matplotlib.fontconfig_pattern', 'fnmatch', > 'sre_parse', 'pickle', 'numpy.core.ctypes', 'mimetools', > 'distutils.distutils', 'unittest.signal', 'copy_reg', 'sre_compile', > '_hashlib', '_random', '_ctypes', 'site', 'numpy.lib.polynomial', > 'numpy.compat', 'numpy._import_tools', 'numpy.polynomial.hermite', > '__main__', 'numpy.fft.info', 'numpy.core.records', 'shutil', > 'numpy.lib.cPickle', 'numpy.sys', 'numpy.polynomial.hermite_e', 'urlparse', > 'unittest.result', 'strop', 'grp', 'linecache', 'numpy.polynomial.numpy', > 'numpy.core.numeric', 'numpy.linalg.info', 'encodings.codecs', '_abcoll', > 'numpy.core', 'matplotlib.locale', 'matplotlib.rcsetup', 'matplotlib.time', > 'matplotlib.weakref', 'genericpath', 'stat', 'socket', 'numpy.lib._iotools', > 'numpy.lib.index_tricks', 'numpy.testing.utils', 'warnings', > 'numpy.lib.utils', 'numpy.core.defchararray', 'numpy.polynomial.polyutils', > 'numpy.lib.shape_base', 'numpy.core.types', 'unittest.signals', 'sys', > 'numpy.core.warnings', 'numpy.compat._inspect', 'numpy.core.__builtin__', > 'ctypes.ctypes', 'numpy.testing.traceback', 'numpy.lib.os', > 'numpy.testing.nosetester', 'types', 'numpy.lib.shutil', > 'matplotlib.datetime', 'matplotlib.distutils', '_weakref', > 'numpy.testing.numpytest', 'difflib', 'distutils.errors', > 'numpy.matrixlib.numpy', 'matplotlib.matplotlib', '_weakrefset', > 'matplotlib.shutil', 'numpy.lib.cStringIO', 'unittest.warnings', 'time', > 'unittest.traceback', 'ssl', 'numpy.linalg.linalg', 'unittest.os', > 'numpy.testing.numpy'] > Using fontManager instance from /home/ben/.matplotlib/fontList.cache > backend Qt4Agg version 0.9.1 > findfont: Matching > :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium > to Bitstream Vera Sans > (/usr/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf) > with score of 0.000000 > > |
|
From: Hugo S. <hu...@gm...> - 2011-07-25 15:25:23
|
Hi Ben, The matplotlib version is ''1.0.1'' and the backend is ''MacOSX''. I've checked the backend using the ''mpl.get_backend()'' function as I couldn't find ''.matplotlibrc'' in my home folder. Hugo Silva On Jul 25, 2011, at 3:15 PM, Benjamin Root wrote: > > > On Sun, Jul 24, 2011 at 6:03 PM, Hugo H. P. Silva <hu...@gm...> wrote: > > Hi all, > > In a prior installation of matplotlib I recall being able to have real-time > pan/zoom plot update while dragging the mouse (not only after releasing the > left/right button). > > I've just updated my Python and PyLab configurations and now matplotlib only > updates the plot after releasing the left/right button. > > Can anyone point me to a possible solution for this issue? > > Best regards, > Hugo Silva > > Hugo, > > My only guess is that this may have been backend-specific. Which backend are you using now, and which version of matplotlib? > > Ben Root > |
|
From: Benjamin R. <ben...@ou...> - 2011-07-25 14:16:24
|
On Sun, Jul 24, 2011 at 6:03 PM, Hugo H. P. Silva <hu...@gm...> wrote: > > Hi all, > > In a prior installation of matplotlib I recall being able to have real-time > pan/zoom plot update while dragging the mouse (not only after releasing the > left/right button). > > I've just updated my Python and PyLab configurations and now matplotlib > only > updates the plot after releasing the left/right button. > > Can anyone point me to a possible solution for this issue? > > Best regards, > Hugo Silva > Hugo, My only guess is that this may have been backend-specific. Which backend are you using now, and which version of matplotlib? Ben Root |
|
From: Hugo H. P. S. <hu...@gm...> - 2011-07-24 23:03:23
|
Hi all, In a prior installation of matplotlib I recall being able to have real-time pan/zoom plot update while dragging the mouse (not only after releasing the left/right button). I've just updated my Python and PyLab configurations and now matplotlib only updates the plot after releasing the left/right button. Can anyone point me to a possible solution for this issue? Best regards, Hugo Silva -- View this message in context: http://old.nabble.com/Matplotlib-Dynamic-Drag-Pan-Zoom-tp32128170p32128170.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: robert r. <rob...@gm...> - 2011-07-24 11:47:53
|
Ok, your version is quite old, and might be older than when the bbox_inches='tight' feature was added. Unfortunately, the way savefig was designed, I think it would swallow extra kwargs. > > The current matplotlib is version 1.0.1, and we are getting close to > cutting a new v1.1.0 release. Debian (which Ubuntu is based on), had > a policy conflict with how we packaged our documents and did not > update matplotlib in their repositories (although it should be updated > in time for their next release). I would recommend building from source: > > http://matplotlib.sourceforge.net/users/installing.html#installing-from-source > > Note that you can obtain all of the required packages for building by > running: > > sudo apt-get build-dep python-matplotlib > > and then build matplotlib yourself from source. > > I hope this helps! > Ben Root > > I was barking up the wrong tree.. the picture is saved with imsave correctly (without extra space around it). However I generated it a second time using canvas.tostring_rgb() which I then send to the web server. When I pass a StringIO instance to imsave everything works as expected. thanks again for your help robert |
|
From: Benjamin R. <ben...@ou...> - 2011-07-23 22:04:54
|
On Sat, Jul 23, 2011 at 4:50 PM, robert rottermann <rob...@gm...
> wrote:
> **
> On 23/07/11 23:17, Benjamin Root wrote:
>
> On Sat, Jul 23, 2011 at 2:53 PM, robert rottermann <
> rob...@gm...> wrote:
>
>> thanks ben,
>> (sorry for sending answer twice)
>>
>> > When you call savefig(), you can pass it the kwarg option of
>> > bbox_inches='tight' and that should help get rid of any extra area you
>> > may have.
>> >
>> > Ben Root
>> I tried to follow your advice. however it did not help. This is what I
>> do:
>>
>> - get the current figure with gcf.
>> - read an image from a file with imread
>> - save it to the canvas with imsave
>> - hide the axes
>> - call fig.savefig('out.svg', transparent=True, bbox_inches='tight',
>> pad_inches=0)
>>
>> then I create a PIL Image and return it to the calling web server.
>>
>> The image is displayed with a fat (1.5 cm) gray border which I do not
>> want.
>>
>> thanks for any further intelligence
>>
>> robert
>>
>> here is my code cleansed of irrelevant parts
>>
>> # supporting method creating the plot
>> def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
>> # get current axes object
>> frame1 = plt.gca()
>> # get current figure
>> fig = plt.gcf()
>> # read the image file
>> pic = plt.imread(imp_path)
>> # the picture is upside down so rotate and fip it
>> pic = np.fliplr(np.rot90(pic, k=2))
>> # draw it on the canvas
>> plt.imshow(pic, figure=fig)
>> # hide axes
>> frame1.axes.get_xaxis().set_visible(False)
>> frame1.axes.get_yaxis().set_visible(False)
>>
>> fig.savefig('out.svg', transparent=True, bbox_inches='tight',
>> pad_inches=0)
>>
>> return pic
>>
>> # method called from the web server
>> def __call__(self, w=300, h=300, default_format = 'PNG',
>> set_headers=False):
>> # lock graphics
>> imageThreadLock.acquire()
>> # we don't want different threads to write on each other's canvases,
>> # make sure we have a new one
>> pylab.close()
>> # makeHlwdChart draws on the canvas, so we do not need its return
>> value
>> makeHlwdChart(self, values)
>> canvas = pylab.get_current_fig_manager().canvas
>> canvas.draw()
>> imageSize = canvas.get_width_height()
>> imageRgb = canvas.tostring_rgb()
>> img = Image.fromstring("RGB", imageSize, imageRgb)
>> #size = int(w), int(h)
>> #img.thumbnail(size, Image.ANTIALIAS)
>> format = img.format and img.format or default_format
>> thumbnail_file = StringIO()
>> ## quality parameter doesn't affect lossless formats
>> img.save(thumbnail_file, format, quality=88)
>> thumbnail_file.seek(0)
>> if set_headers:
>> self.request.RESPONSE.setHeader('Pragma', 'no-cache')
>> self.request.RESPONSE.setHeader('Content-Type', 'image/%s' %
>> format)
>>
>> # unlock graphics
>> imageThreadLock.release()
>>
>> return thumbnail_file.getvalue()
>>
>>
> Does the image look correct if you save it as a PNG file? It might be a
> problem with the SVG backend. Also, which version of matplotlib are you
> using. There was a lot of work on the bbox_inches stuff and this problem
> might have already been fixed.
>
> Ben Root
>
> using png did not help,
>
> matplotlib.__version__ : 0.99.3
> numpy: 1.5.1
>
> as provided by the newest ubuntu
>
>
> thanks
> robert
>
> Ok, your version is quite old, and might be older than when the
bbox_inches='tight' feature was added. Unfortunately, the way savefig was
designed, I think it would swallow extra kwargs.
The current matplotlib is version 1.0.1, and we are getting close to cutting
a new v1.1.0 release. Debian (which Ubuntu is based on), had a policy
conflict with how we packaged our documents and did not update matplotlib in
their repositories (although it should be updated in time for their next
release). I would recommend building from source:
http://matplotlib.sourceforge.net/users/installing.html#installing-from-source
Note that you can obtain all of the required packages for building by
running:
sudo apt-get build-dep python-matplotlib
and then build matplotlib yourself from source.
I hope this helps!
Ben Root
|
|
From: robert r. <rob...@gm...> - 2011-07-23 21:50:37
|
On 23/07/11 23:17, Benjamin Root wrote:
> On Sat, Jul 23, 2011 at 2:53 PM, robert rottermann
> <rob...@gm... <mailto:rob...@gm...>> wrote:
>
> thanks ben,
> (sorry for sending answer twice)
>
> > When you call savefig(), you can pass it the kwarg option of
> > bbox_inches='tight' and that should help get rid of any extra
> area you
> > may have.
> >
> > Ben Root
> I tried to follow your advice. however it did not help. This is
> what I do:
>
> - get the current figure with gcf.
> - read an image from a file with imread
> - save it to the canvas with imsave
> - hide the axes
> - call fig.savefig('out.svg', transparent=True, bbox_inches='tight',
> pad_inches=0)
>
> then I create a PIL Image and return it to the calling web server.
>
> The image is displayed with a fat (1.5 cm) gray border which I do
> not want.
>
> thanks for any further intelligence
>
> robert
>
> here is my code cleansed of irrelevant parts
>
> # supporting method creating the plot
> def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
> # get current axes object
> frame1 = plt.gca()
> # get current figure
> fig = plt.gcf()
> # read the image file
> pic = plt.imread(imp_path)
> # the picture is upside down so rotate and fip it
> pic = np.fliplr(np.rot90(pic, k=2))
> # draw it on the canvas
> plt.imshow(pic, figure=fig)
> # hide axes
> frame1.axes.get_xaxis().set_visible(False)
> frame1.axes.get_yaxis().set_visible(False)
>
> fig.savefig('out.svg', transparent=True, bbox_inches='tight',
> pad_inches=0)
>
> return pic
>
> # method called from the web server
> def __call__(self, w=300, h=300, default_format = 'PNG',
> set_headers=False):
> # lock graphics
> imageThreadLock.acquire()
> # we don't want different threads to write on each other's
> canvases,
> # make sure we have a new one
> pylab.close()
> # makeHlwdChart draws on the canvas, so we do not need its
> return value
> makeHlwdChart(self, values)
> canvas = pylab.get_current_fig_manager().canvas
> canvas.draw()
> imageSize = canvas.get_width_height()
> imageRgb = canvas.tostring_rgb()
> img = Image.fromstring("RGB", imageSize, imageRgb)
> #size = int(w), int(h)
> #img.thumbnail(size, Image.ANTIALIAS)
> format = img.format and img.format or default_format
> thumbnail_file = StringIO()
> ## quality parameter doesn't affect lossless formats
> img.save(thumbnail_file, format, quality=88)
> thumbnail_file.seek(0)
> if set_headers:
> self.request.RESPONSE.setHeader('Pragma', 'no-cache')
> self.request.RESPONSE.setHeader('Content-Type', 'image/%s' %
> format)
>
> # unlock graphics
> imageThreadLock.release()
>
> return thumbnail_file.getvalue()
>
>
> Does the image look correct if you save it as a PNG file? It might be
> a problem with the SVG backend. Also, which version of matplotlib
> are you using. There was a lot of work on the bbox_inches stuff and
> this problem might have already been fixed.
>
> Ben Root
>
using png did not help,
matplotlib.__version__ : 0.99.3
numpy: 1.5.1
as provided by the newest ubuntu
thanks
robert
|
|
From: Benjamin R. <ben...@ou...> - 2011-07-23 21:22:03
|
On Thu, Jul 21, 2011 at 7:46 PM, gary ruben <gr...@bi...> wrote: > Hi Ben, > Comments inline... > > On Fri, Jul 22, 2011 at 1:31 AM, Benjamin Root <ben...@ou...> wrote: > > > > > > On Thu, Jul 21, 2011 at 1:10 AM, gary ruben <gar...@gm...> > wrote: > >> > >> I'm trying to make a surface plot using the latest version of mplot3d > >> from the git trunk and I have a couple of questions. The attached > >> image is close to what I would like. The associated plot command I am > >> using is > >> > >> ax.plot_surface(X, Y, Z, rstride=1, cstride=1, alpha=0.8, shade=True, > >> cmap=plt.cm.summer, > >> color='k', > >> facecolors='k', > >> lightsource = LightSource(azdeg=0, altdeg=0), > >> ) > >> > >> 1. Is there support now to automatically annotate the axis so that a > >> multiplier is added, as occurs in 2D plots, or should I do this > >> manually by rescaling the data for the moment? > > > > Yes, offset text is now automatic and should activate in similar manner > as > > it does for regular 2D axis formatters. You were one order of magnitude > off > > from automatically triggering it. Also, I should note that it might be > > better to use "ax = fig.gca(projection='3d')" instead of "ax = > Axes3D(fig)" > > because the former will leave more of a margin, which would allow the > offset > > text to be fully visible. > > Thanks. That's actually what I am doing but I cropped the output image > before attaching it. > > > If you want the full figure area, then you may > > need to fiddle with the ax.zaxis._axinfo['label']['space_factor'] to > bring > > it and the axis label closer to the axis. > > Thanks. That's useful to know. > > > The odd thing that I am encountering right now while investigating your > > problem is that I can't seem to force the use of the offset. It could > just > > be that I am doing it wrong, but I will look closer. > > Yes, I had set 'axes.formatter.limits' : (-2, 2) hoping to trigger it > - I guess that's what you tried. > > >> 2. Currently, it doesn't appear possible to shade the surface patches > >> according to just a base facecolor and their orientation to a light > >> source. Do I have to define a new colormap with a constant/single > >> colour to achieve this? > > > > Looking over the plot_surface code, this appears to be the case, however, > > looking back over the LightSource code, I believe it might be possible to > > update plot_surface to operate on situations where no cmap is specified. > I > > will take a look today at that possibility and see if I can get it out > for > > the v1.1.0 release. > > That would be great - it is a very good way to visualize a surface so > it should be made as simple as possible. > > >> 3. I have set alpha=0.8 to allow the wireframe lines to show through a > >> little. When shade=False, the wireframe is visible but I lose > >> orientation-based shading. Is there a way to overlay the wireframe > >> properly when shade=True? > >> > > > > In plot_surface, when shade=True, it appears that both the facecolors and > > the edgecolors are set to the same colors. The only reason why the lines > > show up when you set transparency is that that alpha value is applied > only > > to the faces and not the edges. Specifically, the logic is as follows: > > > > if fcolors is specified, then set that color for both facecolor and > > edgecolor. > > Else, if a cmap is specified, then give the polygon collection the data, > > limits and norm it needs to determine color itself. > > Else, then use the value of "color" to specify only the facecolors. > > > > I think the first branch of this logic is a bit wonky. > > I agree, since fcolors must be specified in order to trigger the > lightsource-based shading. > > > I am inclined to > > make a small change that would only set the edgecolors if 'edgecolors' > was > > not provided as a kwarg. This would enable users to specify the > edgecolor > > they want without worrying about something else over-riding it. The only > > problem seems to be that there would be no shading of these grid lines. > > Would that still be acceptable to you? > > Absolutely acceptable. In fact I think it is preferable not to shade them. > > > Thanks for your valuable feedback! > > Ben Root > > Thanks for being responsive to it :) > regards, > Gary > Good to know. I am currently a little dis-satisfied with the documentation for plot_surface and I want to expand this significantly. Right now, there are two different "shadings" that occur depending upon inputs and this really needs to be spelled out. I will use your input to guide my write-up. Cheers, Ben Root |
|
From: Benjamin R. <ben...@ou...> - 2011-07-23 21:17:46
|
On Sat, Jul 23, 2011 at 2:53 PM, robert rottermann <rob...@gm...
> wrote:
> thanks ben,
> (sorry for sending answer twice)
>
> > When you call savefig(), you can pass it the kwarg option of
> > bbox_inches='tight' and that should help get rid of any extra area you
> > may have.
> >
> > Ben Root
> I tried to follow your advice. however it did not help. This is what I do:
>
> - get the current figure with gcf.
> - read an image from a file with imread
> - save it to the canvas with imsave
> - hide the axes
> - call fig.savefig('out.svg', transparent=True, bbox_inches='tight',
> pad_inches=0)
>
> then I create a PIL Image and return it to the calling web server.
>
> The image is displayed with a fat (1.5 cm) gray border which I do not want.
>
> thanks for any further intelligence
>
> robert
>
> here is my code cleansed of irrelevant parts
>
> # supporting method creating the plot
> def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
> # get current axes object
> frame1 = plt.gca()
> # get current figure
> fig = plt.gcf()
> # read the image file
> pic = plt.imread(imp_path)
> # the picture is upside down so rotate and fip it
> pic = np.fliplr(np.rot90(pic, k=2))
> # draw it on the canvas
> plt.imshow(pic, figure=fig)
> # hide axes
> frame1.axes.get_xaxis().set_visible(False)
> frame1.axes.get_yaxis().set_visible(False)
>
> fig.savefig('out.svg', transparent=True, bbox_inches='tight',
> pad_inches=0)
>
> return pic
>
> # method called from the web server
> def __call__(self, w=300, h=300, default_format = 'PNG',
> set_headers=False):
> # lock graphics
> imageThreadLock.acquire()
> # we don't want different threads to write on each other's canvases,
> # make sure we have a new one
> pylab.close()
> # makeHlwdChart draws on the canvas, so we do not need its return value
> makeHlwdChart(self, values)
> canvas = pylab.get_current_fig_manager().canvas
> canvas.draw()
> imageSize = canvas.get_width_height()
> imageRgb = canvas.tostring_rgb()
> img = Image.fromstring("RGB", imageSize, imageRgb)
> #size = int(w), int(h)
> #img.thumbnail(size, Image.ANTIALIAS)
> format = img.format and img.format or default_format
> thumbnail_file = StringIO()
> ## quality parameter doesn't affect lossless formats
> img.save(thumbnail_file, format, quality=88)
> thumbnail_file.seek(0)
> if set_headers:
> self.request.RESPONSE.setHeader('Pragma', 'no-cache')
> self.request.RESPONSE.setHeader('Content-Type', 'image/%s' %
> format)
>
> # unlock graphics
> imageThreadLock.release()
>
> return thumbnail_file.getvalue()
>
>
Does the image look correct if you save it as a PNG file? It might be a
problem with the SVG backend. Also, which version of matplotlib are you
using. There was a lot of work on the bbox_inches stuff and this problem
might have already been fixed.
Ben Root
|
|
From: robert r. <rob...@gm...> - 2011-07-23 19:53:26
|
thanks ben,
(sorry for sending answer twice)
> When you call savefig(), you can pass it the kwarg option of
> bbox_inches='tight' and that should help get rid of any extra area you
> may have.
>
> Ben Root
I tried to follow your advice. however it did not help. This is what I do:
- get the current figure with gcf.
- read an image from a file with imread
- save it to the canvas with imsave
- hide the axes
- call fig.savefig('out.svg', transparent=True, bbox_inches='tight',
pad_inches=0)
then I create a PIL Image and return it to the calling web server.
The image is displayed with a fat (1.5 cm) gray border which I do not want.
thanks for any further intelligence
robert
here is my code cleansed of irrelevant parts
# supporting method creating the plot
def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
# get current axes object
frame1 = plt.gca()
# get current figure
fig = plt.gcf()
# read the image file
pic = plt.imread(imp_path)
# the picture is upside down so rotate and fip it
pic = np.fliplr(np.rot90(pic, k=2))
# draw it on the canvas
plt.imshow(pic, figure=fig)
# hide axes
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
fig.savefig('out.svg', transparent=True, bbox_inches='tight',
pad_inches=0)
return pic
# method called from the web server
def __call__(self, w=300, h=300, default_format = 'PNG', set_headers=False):
# lock graphics
imageThreadLock.acquire()
# we don't want different threads to write on each other's canvases,
# make sure we have a new one
pylab.close()
# makeHlwdChart draws on the canvas, so we do not need its return value
makeHlwdChart(self, values)
canvas = pylab.get_current_fig_manager().canvas
canvas.draw()
imageSize = canvas.get_width_height()
imageRgb = canvas.tostring_rgb()
img = Image.fromstring("RGB", imageSize, imageRgb)
#size = int(w), int(h)
#img.thumbnail(size, Image.ANTIALIAS)
format = img.format and img.format or default_format
thumbnail_file = StringIO()
## quality parameter doesn't affect lossless formats
img.save(thumbnail_file, format, quality=88)
thumbnail_file.seek(0)
if set_headers:
self.request.RESPONSE.setHeader('Pragma', 'no-cache')
self.request.RESPONSE.setHeader('Content-Type', 'image/%s' %
format)
# unlock graphics
imageThreadLock.release()
return thumbnail_file.getvalue()
|
|
From: robert r. <rob...@gm...> - 2011-07-23 19:41:46
|
thanks ben,
(sorry for sending answer twice)
> When you call savefig(), you can pass it the kwarg option of
> bbox_inches='tight' and that should help get rid of any extra area you
> may have.
>
> Ben Root
I tried to follow your advice. however it did not help. This is what I do:
- get the current figure with gcf.
- read an image from a file with imread
- save it to the canvas with imsave
- hide the axes
- call fig.savefig('out.svg', transparent=True, bbox_inches='tight',
pad_inches=0)
then I create a PIL Image and return it to the calling web server.
The image is displayed with a fat (1.5 cm) gray border which I do not want.
thanks for any further intelligence
robert
here is my code cleansed of irrelevant parts
# supporting method creating the plot
def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
# get current axes object
frame1 = plt.gca()
# get current figure
fig = plt.gcf()
# read the image file
pic = plt.imread(imp_path)
# the picture is upside down so rotate and fip it
pic = np.fliplr(np.rot90(pic, k=2))
# draw it on the canvas
plt.imshow(pic, figure=fig)
# hide axes
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
fig.savefig('out.svg', transparent=True, bbox_inches='tight',
pad_inches=0)
return pic
# method called from the web server
def __call__(self, w=300, h=300, default_format = 'PNG', set_headers=False):
# lock graphics
imageThreadLock.acquire()
# we don't want different threads to write on each other's canvases,
# make sure we have a new one
pylab.close()
# makeHlwdChart draws on the canvas, so we do not need its return value
makeHlwdChart(self, values)
canvas = pylab.get_current_fig_manager().canvas
canvas.draw()
imageSize = canvas.get_width_height()
imageRgb = canvas.tostring_rgb()
img = Image.fromstring("RGB", imageSize, imageRgb)
#size = int(w), int(h)
#img.thumbnail(size, Image.ANTIALIAS)
format = img.format and img.format or default_format
thumbnail_file = StringIO()
## quality parameter doesn't affect lossless formats
img.save(thumbnail_file, format, quality=88)
thumbnail_file.seek(0)
if set_headers:
self.request.RESPONSE.setHeader('Pragma', 'no-cache')
self.request.RESPONSE.setHeader('Content-Type', 'image/%s' %
format)
# unlock graphics
imageThreadLock.release()
return thumbnail_file.getvalue()
|
|
From: Ben B. <bbr...@gm...> - 2011-07-23 19:13:45
|
Hi, I'm trying to fade some data, using alpha values, that I am plotting with Axes.plot(). I can recreate this problem with 1 line of pylab.plot. If I use pylab.plot([1,2,3],[1,4,9], color=(1,0,0,.2), linewidth=7) then I get the equivalent of pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7) i.e. it does not use the alpha value. However, if instead I use pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7, alpha=.2) then the line is faded out appropriately. The plot documentation indicates that RGBA tuples should be valid, so I'm wondering if this is a bug. Maybe alpha is defaulting to 1 or None and then not being overwritten if color is a 4-tuple? I'm using Arch Linux with kernel 2.6.39, matplotlib 1.0.1 from the Arch repo, and the Qt4 backend. My installed Qt version is 4.7.3, and I am using KDE 4.6.5. Below is verbose-debug output. Thanks for any help! Ben $HOME=/home/ben CONFIGDIR=/home/ben/.matplotlib matplotlib data path /usr/lib/python2.7/site-packages/matplotlib/mpl-data loaded rc file /usr/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc matplotlib version 1.0.1 verbose.level debug interactive is False units is False platform is linux2 loaded modules: ['heapq', 'numpy.core.info', 'distutils', 'numpy.lib.format', 'functools', 'pylab', '_bisect', 'subprocess', 'sysconfig', 'gc', 'matplotlib.tempfile', 'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings', 'pyparsing', 'matplotlib.colors', 'numpy.core.numerictypes', 'numpy.testing.sys', 'numpy.lib.__future__', 'numpy.fft.types', 'numpy.ma.cPickle', 'struct', 'numpy.matrixlib.defmatrix', 'numpy.random.info', 'tempfile', 'numpy.compat.types', 'pprint', 'numpy.linalg', 'matplotlib.threading', 'numpy.core.machar', 'numpy.testing.types', 'numpy.testing', 'collections', 'numpy.polynomial.sys', 'unittest.sys', 'numpy.core.umath', 'unittest.main', 'distutils.types', 'numpy.testing.operator', 'numpy.core.scalarmath', 'numpy.ma.sys', 'zipimport', 'string', 'matplotlib.subprocess', 'numpy.testing.os', 'unittest.functools', 'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 'encodings.utf_8', 'matplotlib.__future__', 'unittest.types', 'unittest.util', ' numpy.testing.re', 'numpy.version', 'numpy.lib.re', 'distutils.re', 'numpy.matrixlib.sys', 'ctypes.os', 'numpy.core.os', 'numpy.lib.type_check', 'numpy.compat.sys', 'unittest.StringIO', 'bisect', 'numpy.core._internal', 'signal', 'numpy.lib.types', 'numpy.lib._datasource', 'random', 'numpy.lib.__builtin__', 'numpy.fft.fftpack_lite', 'matplotlib.cbook', 'textwrap', 'numpy.core.multiarray', 'numpy.polynomial.string', 'distutils.version', 'cStringIO', 'numpy.polynomial', 'numpy.numpy', 'matplotlib.StringIO', 'unittest.time', 'locale', 'numpy.add_newdocs', 'unittest.difflib', 'numpy.core.getlimits', 'base64', '_ssl', 'numpy.lib.sys', 'encodings', 'numpy.ma.itertools', 'unittest.pprint', ' unittest.re', 'abc', 'numpy.matrixlib', 'numpy.ctypes', 'numpy.testing.decorators', 'matplotlib.warnings', 'rfc822', 'numpy.lib.npyio', 'numpy.lib.numpy', 'matplotlib.sys', 're', 'numpy.lib._compiled_base', 'numpy.polynomial.legendre', 'threading', 'new', 'numpy.ma.warnings', 'numpy.random.mtrand', 'urllib2', 'matplotlib.cPickle', 'math', 'numpy.fft.helper', 'fcntl', 'unittest.case', 'matplotlib.numpy', 'UserDict', 'unittest.suite', 'numpy.lib.function_base', 'distutils.os', 'matplotlib', 'numpy.fft.numpy', 'exceptions', 'numpy.lib.info', 'ctypes', 'numpy.lib.warnings', 'ctypes.struct', 'codecs', 'numpy.core._sort', 'numpy.os', 'unittest.loader', '_functools', '_locale', 'numpy.__builtin__', 'matplotlib.os', 'thread', 'StringIO', 'numpy.core.memmap', 'traceback', 'numpy.testing.warnings', 'weakref', 'itertools', 'numpy.fft.fftpack', 'numpy.linalg.lapack_lite', 'numpy.ma', 'distutils.sys', 'os', 'marshal', 'numpy.lib.itertools', '__future__', '_collections', 'urllib', 'matplotlib.traceback', '_sre', 'unittest', 'numpy.core.sys', 'numpy.random', 'numpy.linalg.numpy', '__builtin__', 'numpy.lib.twodim_base', 'numpy.ma.core', 'matplotlib.re', 'numpy.core.cPickle', 'unittest.runner', 'operator', 'numpy.polynomial.polytemplate', 'numpy.core.arrayprint', 'distutils.string', 'numpy.lib.arrayterator', 'select', 'ctypes._ctypes', '_heapq', 'ctypes.sys', 'matplotlib.errno', 'unittest.collections', 'posixpath', 'numpy.lib.financial', 'numpy.polynomial.laguerre', 'matplotlib.random', 'errno', '_socket', 'binascii', 'sre_constants', 'datetime', 'numpy.core.shape_base', 'os.path', 'numpy.core.function_base', 'numpy.compat.py3k', 'numpy.lib.stride_tricks', 'numpy.core.numpy', 'numpy', '_warnings', 'numpy.polynomial.chebyshev', 'matplotlib.types', 'cPickle', 'encodings.__builtin__', 'numpy.polynomial.warnings', 'matplotlib.new', '_codecs', 'numpy.lib.operator', 'unittest.fnmatch', 'numpy.polynomial.polynomial', 'numpy.__config__', 'pwd', 'matplotlib.pyparsing', 'httplib', 'numpy.lib.ufunclike', 'copy', ' numpy.core.re', '_struct', 'numpy.core.fromnumeric', 'hashlib', 'numpy.ctypeslib', 'keyword', 'array', 'numpy.lib.scimath', 'numpy.fft', 'numpy.lib', 'numpy.ma.numpy', 'numpy.random.numpy', 'matplotlib.urllib2', 'unittest.weakref', 'numpy.ma.extras', 'numpy.polynomial.__future__', 'posix', 'encodings.aliases', 'matplotlib.fontconfig_pattern', 'fnmatch', 'sre_parse', 'pickle', 'numpy.core.ctypes', 'mimetools', 'distutils.distutils', 'unittest.signal', 'copy_reg', 'sre_compile', '_hashlib', '_random', '_ctypes', 'site', 'numpy.lib.polynomial', 'numpy.compat', 'numpy._import_tools', 'numpy.polynomial.hermite', '__main__', 'numpy.fft.info', 'numpy.core.records', 'shutil', 'numpy.lib.cPickle', 'numpy.sys', 'numpy.polynomial.hermite_e', 'urlparse', 'unittest.result', 'strop', 'grp', 'linecache', 'numpy.polynomial.numpy', 'numpy.core.numeric', 'numpy.linalg.info', 'encodings.codecs', '_abcoll', 'numpy.core', 'matplotlib.locale', 'matplotlib.rcsetup', 'matplotlib.time', 'matplotlib.weakref', 'genericpath', 'stat', 'socket', 'numpy.lib._iotools', 'numpy.lib.index_tricks', 'numpy.testing.utils', 'warnings', 'numpy.lib.utils', 'numpy.core.defchararray', 'numpy.polynomial.polyutils', 'numpy.lib.shape_base', 'numpy.core.types', 'unittest.signals', 'sys', 'numpy.core.warnings', 'numpy.compat._inspect', 'numpy.core.__builtin__', 'ctypes.ctypes', 'numpy.testing.traceback', 'numpy.lib.os', 'numpy.testing.nosetester', 'types', 'numpy.lib.shutil', 'matplotlib.datetime', 'matplotlib.distutils', '_weakref', 'numpy.testing.numpytest', 'difflib', 'distutils.errors', 'numpy.matrixlib.numpy', 'matplotlib.matplotlib', '_weakrefset', 'matplotlib.shutil', 'numpy.lib.cStringIO', 'unittest.warnings', 'time', 'unittest.traceback', 'ssl', 'numpy.linalg.linalg', 'unittest.os', 'numpy.testing.numpy'] Using fontManager instance from /home/ben/.matplotlib/fontList.cache backend Qt4Agg version 0.9.1 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (/usr/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.000000 |
|
From: Jeff W. <js...@fa...> - 2011-07-23 18:58:57
|
On 7/23/11 9:32 AM, Yoshi Rokuko wrote:
> +----------------------------------------- Jeff Whitaker -----------+
>> Here's the basic idea:
>>
>> 1) read the germany.dat file, use it to create a _geoslib Poly instance,
>> i.e.
>>
>> from mpl_toolkits.basemap import _geoslib
>> b = np.asarray([lons,lats]).T # lons and lats are lists.
>> germanypoly = _geoslib.Polygon(b)
>>
>> 2) loop over all the points on the grid and do
>>
>> inside = _geoslib.Point((lonpt,latpt)).within(germanypoly)
>>
>> filling a boolean array with the values.
>>
>> 3) use this boolean array as a mask to create a masked array from your
>> data. Then, when you plot the masked array with contourf only the
>> points inside germany will be contoured.
>>
>> Give this a try and let us know how it goes.
>>
>> -Jeff
>>
> because of islands it doesn't work as expected i guess?
>
> here is what i did:
>
>>>> bmap = Basemap(projection='aeqd', ...)
>>>> x, y = bmap(lons, lats)
>>>> npoints = 300
>>>> xi = np.linspace(np.amin(x), np.amax(x), npoints*.7178)
>>>> yi = np.linspace(np.amin(y), np.amax(y), npoints)
>>>> zi = griddata(x, y, var, xi, yi)
>>>> inside = np.zeros_like(zi)
>>>> lon, lat = np.loadtxt('germany-lon-lat-np.arr')
>>>> bx, by = bmap(lon, lat)
>>>> b = np.asarray([bx, by]).T
>>>> poly = _geoslib.Polygon(b)
>>>> i = 0
>>>> # i know this is slow, but ...
>>>> for y in yi:
>>>> for x in xi:
>>>> inside.flat[i] = _geoslib.Point((x,y)).within(poly)
>>>> i += 1
>>>> mzi = ma.masked_array(zi, mask=inside)
> here is what it looks like:
> http://rokuko.net/test.png
>
> matlab includes NaNs right before and after islands in the lon
> lat lists, is there something similar ?
Yoshi: Islands would be a problem. I was assuming you had one polygon.
Can you get rid of the islands so you just have one closed polygon to
use for a mask?
-Jeff
|
|
From: Benjamin R. <ben...@ou...> - 2011-07-23 15:58:57
|
On Saturday, July 23, 2011, robert rottermann <ro...@re...> wrote:
> Hi there,
>
> I am creating an image with mathplotlib. This image is then shown an a web
page.
> now ma question.
> the Image is set in a large gray area. I assume it is the space needed for
the
> axis which I do not show.
> How can I suppress this gray background?
>
> thanks
> robert
>
> here the code I use to create the image:
> def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
> # the need for following two lines I learned by appling voodoo and
pdb
> img_resource =
> self.context.restrictedTraverse('++resource++effizienz_balken_01.jpg')
> imp_path = img_resource.context.path
> pic = plt.imread(imp_path)
> # the picture is upside down so rotate and fip it
> pic = np.fliplr(np.rot90(pic, k=2))
> # draw it on the canvas
> plt.imshow(pic)
> frame1 = plt.gca()
> # hide axes
> frame1.axes.get_xaxis().set_visible(False)
> frame1.axes.get_yaxis().set_visible(False)
> #frame1.subplots_adjust(left=0)
>
> # generate the colored markers that denot the value
> # write a label so, that it is within the marker
> funs = [th, ge, hh, en, pr]
> font0 = FontProperties()
> font = font0.copy()
> font.set_weight('bold')
> for i in range(len(values)):
> # add the colord marker
> frame1.add_patch(funs[i](values[i], True))
> # get postition of the label
> p = funs[i](values[i], offset=TEXTOFFSET)
> # write the label
> frame1.text(p[0], p[1], values[i].upper(),
fontproperties=font)
>
> return pic
>
When you call savefig(), you can pass it the kwarg option of
bbox_inches='tight' and that should help get rid of any extra area you may
have.
Ben Root
|
|
From: Yoshi R. <yo...@ro...> - 2011-07-23 15:32:52
|
+----------------------------------------- Jeff Whitaker -----------+
>
> Here's the basic idea:
>
> 1) read the germany.dat file, use it to create a _geoslib Poly instance,
> i.e.
>
> from mpl_toolkits.basemap import _geoslib
> b = np.asarray([lons,lats]).T # lons and lats are lists.
> germanypoly = _geoslib.Polygon(b)
>
> 2) loop over all the points on the grid and do
>
> inside = _geoslib.Point((lonpt,latpt)).within(germanypoly)
>
> filling a boolean array with the values.
>
> 3) use this boolean array as a mask to create a masked array from your
> data. Then, when you plot the masked array with contourf only the
> points inside germany will be contoured.
>
> Give this a try and let us know how it goes.
>
> -Jeff
>
because of islands it doesn't work as expected i guess?
here is what i did:
>>> bmap = Basemap(projection='aeqd', ...)
>>> x, y = bmap(lons, lats)
>>> npoints = 300
>>> xi = np.linspace(np.amin(x), np.amax(x), npoints*.7178)
>>> yi = np.linspace(np.amin(y), np.amax(y), npoints)
>>> zi = griddata(x, y, var, xi, yi)
>>> inside = np.zeros_like(zi)
>>> lon, lat = np.loadtxt('germany-lon-lat-np.arr')
>>> bx, by = bmap(lon, lat)
>>> b = np.asarray([bx, by]).T
>>> poly = _geoslib.Polygon(b)
>>> i = 0
>>> # i know this is slow, but ...
>>> for y in yi:
>>> for x in xi:
>>> inside.flat[i] = _geoslib.Point((x,y)).within(poly)
>>> i += 1
>>> mzi = ma.masked_array(zi, mask=inside)
here is what it looks like:
http://rokuko.net/test.png
matlab includes NaNs right before and after islands in the lon
lat lists, is there something similar ?
thank you so far, best regards
PS
http://rokuko.net/germany-lon-lat-np.arr
|
|
From: Jeff W. <js...@fa...> - 2011-07-23 13:44:01
|
+----------------------------------------- Jeff Whitaker -----------+ >> Jeff, I just had a thought.... >> >> Isn't the country borders drawn as Path or Polygon objects? I believe >> there are some matplotlib internal functions that can be given a list >> of points (such as those for a grid) and a path and it will return >> which points are within the path and which are outside. One could use >> that to make the mask. >> >> Might make for a nice feature for basemap in the upcoming v1.1.0 release. >> >> Ben Root >> > Ben/Yoshi: The countries are not polygons, they are line segments. > Worse yet, they are all just lumped together with no metadata (no way to > know which lines define the country you want). If you had a shapefile > with just the country of interest in it, defined as a polygon, then it's > doable You could take a look at the source code for the is_land method, > which tests to see if a given x,y point is inside any of the continent > polygons. > > Let us know if you have you have the country polygon, and then I can > help you with the details. > > -Jeff > >>> Sorry for being late, i was really busy. Thank you for your offer, I have >>> the polygon now (attached), could you help me with this? >>> Best regards, Yoshi Yoshi: Here's the basic idea: 1) read the germany.dat file, use it to create a _geoslib Poly instance, i.e. from mpl_toolkits.basemap import _geoslib b = np.asarray([lons,lats]).T # lons and lats are lists. germanypoly = _geoslib.Polygon(b) 2) loop over all the points on the grid and do inside = _geoslib.Point((lonpt,latpt)).within(germanypoly) filling a boolean array with the values. 3) use this boolean array as a mask to create a masked array from your data. Then, when you plot the masked array with contourf only the points inside germany will be contoured. Give this a try and let us know how it goes. -Jeff |
|
From: robert r. <ro...@re...> - 2011-07-23 09:45:03
|
Hi there,
I am creating an image with mathplotlib. This image is then shown an a web page.
now ma question.
the Image is set in a large gray area. I assume it is the space needed for the
axis which I do not show.
How can I suppress this gray background?
thanks
robert
here the code I use to create the image:
def makeHlwdChart(self, values = ['a', 'd', 'e', 'f', 'b']):
# the need for following two lines I learned by appling voodoo and pdb
img_resource =
self.context.restrictedTraverse('++resource++effizienz_balken_01.jpg')
imp_path = img_resource.context.path
pic = plt.imread(imp_path)
# the picture is upside down so rotate and fip it
pic = np.fliplr(np.rot90(pic, k=2))
# draw it on the canvas
plt.imshow(pic)
frame1 = plt.gca()
# hide axes
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
#frame1.subplots_adjust(left=0)
# generate the colored markers that denot the value
# write a label so, that it is within the marker
funs = [th, ge, hh, en, pr]
font0 = FontProperties()
font = font0.copy()
font.set_weight('bold')
for i in range(len(values)):
# add the colord marker
frame1.add_patch(funs[i](values[i], True))
# get postition of the label
p = funs[i](values[i], offset=TEXTOFFSET)
# write the label
frame1.text(p[0], p[1], values[i].upper(), fontproperties=font)
return pic
|