From imranal at student.matnat.uio.no Wed Nov 4 09:05:57 2015 From: imranal at student.matnat.uio.no (Imran Ali) Date: Wed, 4 Nov 2015 15:05:57 +0100 Subject: [Matplotlib-users] Installing matplotlib dev version on ubuntu from source file Message-ID: <572D05F9-ADFB-4071-BB48-F05CC55B8BF6@math.uio.no> I did the following in order to (try) to install matplotlib : $ git clone clone https://github.com/matplotlib/matplotlib.git $ cd matplotlib $ python setup.py build Which generates the following message : ============================================================================ Edit setup.cfg to change the build options BUILDING MATPLOTLIB matplotlib: yes [1.5.0+226.g2f3b2ca] python: yes [2.7.9 (default, Apr 2 2015, 15:33:21) [GCC 4.9.2]] platform: yes [linux2] REQUIRED DEPENDENCIES AND EXTENSIONS numpy: yes [version 1.8.2] dateutil: yes [using dateutil version 2.2] functools32: yes [functools32 was not found. It is required for forpython versions prior to 3.2] pytz: yes [using pytz version 2014.10] cycler: yes [cycler was not found. pip will attempt to install it after matplotlib.] tornado: yes [tornado was not found. It is required for the WebAgg backend. pip/easy_install may attempt to install it after matplotlib.] pyparsing: yes [using pyparsing version 2.0.3] libagg: yes [pkg-config information for 'libagg' could not be found. Using local copy.] freetype: no [The C/C++ header for freetype2 (ft2build.h) could not be found. You may need to install the development package.] png: no [pkg-config information for 'libpng' could not be found.] qhull: yes [pkg-config information for 'qhull' could not be found. Using local copy.] OPTIONAL SUBPACKAGES sample_data: yes [installing] toolkits: yes [installing] tests: yes [using nose version 1.3.4 / using mock 1.0.1] toolkits_tests: yes [using nose version 1.3.4 / using mock 1.0.1] OPTIONAL BACKEND EXTENSIONS macosx: no [Mac OS-X only] qt5agg: no [PyQt5 not found] qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide not found] gtk3agg: yes [installing, version 3.13.14] gtk3cairo: yes [installing, version 3.13.14] gtkagg: no [The C/C++ header for gtk (gtk/gtk.h) could not be found. You may need to install the development package.] tkagg: no [The C/C++ header for Tk (tk.h) could not be found. You may need to install the development package.] wxagg: no [requires wxPython] gtk: no [The C/C++ header for gtk (gtk/gtk.h) could not be found. You may need to install the development package.] agg: yes [installing] cairo: yes [installing, pycairo version 1.8.8] windowing: no [Microsoft Windows only] OPTIONAL LATEX DEPENDENCIES dvipng: yes [version 1.14] ghostscript: yes [version 9.15] latex: yes [version 3.14159265] pdftops: yes [version 0.30.0] OPTIONAL PACKAGE DATA dlls: no [skipping due to configuration] ============================================================================ * The following required packages can not be built: * freetype, png When I thereupon ran install command $ python setup.py install I got the same output as above. Nothing happend. I have got v.1.4.2 on my machine, but would really like to have the dev version to test the new colormaps. Imran -------------- next part -------------- An HTML attachment was scrubbed... URL: From imranal at student.matnat.uio.no Wed Nov 4 09:11:39 2015 From: imranal at student.matnat.uio.no (Imran Ali) Date: Wed, 4 Nov 2015 15:11:39 +0100 Subject: [Matplotlib-users] Installing matplotlib dev version on ubuntu from source file In-Reply-To: <572D05F9-ADFB-4071-BB48-F05CC55B8BF6@math.uio.no> References: <572D05F9-ADFB-4071-BB48-F05CC55B8BF6@math.uio.no> Message-ID: I forgot to mention, when I ran $ sudo apt-get build-dep python-matplotlib I got the following message : (translated from Norwegian) Reding package lits ... Done Creating overview for the dependencies Reading status information ... Done Choosing ?matplotlib? as source package instead of ?python-matplotlib? Following packages have unresolved dependency relationships: libgtk2.0-dev : Depends on: libglib2.0-dev (>= 2.27.3) but shall not be installed Depends on: libgdk-pixbuf2.0-dev (>= 2.21.0) but shall not be installed Depends on: libpango1.0-dev (>= 1.20) but shall not be installed Depends on: libatk1.0-dev (>= 1.29.2) but shall not be installed Depends on: libcairo2-dev (>= 1.6.4-6.1) but shall not be installed python-gtk2-dev : Depends on: libglib2.0-dev (>= 2.8) but shall not be installed Depends on: python-gobject-2-dev (>= 2.21.3) but shall not be installed E: Did not manage to satisfy build dependencies for python-matplotlib. > 4. nov. 2015 kl. 15.05 skrev Imran Ali : > > I did the following in order to (try) to install matplotlib : > > $ git clone clone https://github.com/matplotlib/matplotlib.git > $ cd matplotlib > $ python setup.py build > > Which generates the following message : > > ============================================================================ > Edit setup.cfg to change the build options > > BUILDING MATPLOTLIB > matplotlib: yes [1.5.0+226.g2f3b2ca] > python: yes [2.7.9 (default, Apr 2 2015, 15:33:21) [GCC > 4.9.2]] > platform: yes [linux2] > > REQUIRED DEPENDENCIES AND EXTENSIONS > numpy: yes [version 1.8.2] > dateutil: yes [using dateutil version 2.2] > functools32: yes [functools32 was not found. It is required for > forpython versions prior to 3.2] > pytz: yes [using pytz version 2014.10] > cycler: yes [cycler was not found. pip will attempt to > install it after matplotlib.] > tornado: yes [tornado was not found. It is required for the > WebAgg backend. pip/easy_install may attempt to > install it after matplotlib.] > pyparsing: yes [using pyparsing version 2.0.3] > libagg: yes [pkg-config information for 'libagg' could not > be found. Using local copy.] > freetype: no [The C/C++ header for freetype2 (ft2build.h) > could not be found. You may need to install the > development package.] > png: no [pkg-config information for 'libpng' could not > be found.] > qhull: yes [pkg-config information for 'qhull' could not be > found. Using local copy.] > > OPTIONAL SUBPACKAGES > sample_data: yes [installing] > toolkits: yes [installing] > tests: yes [using nose version 1.3.4 / using mock 1.0.1] > toolkits_tests: yes [using nose version 1.3.4 / using mock 1.0.1] > > OPTIONAL BACKEND EXTENSIONS > macosx: no [Mac OS-X only] > qt5agg: no [PyQt5 not found] > qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide not > found] > gtk3agg: yes [installing, version 3.13.14] > gtk3cairo: yes [installing, version 3.13.14] > gtkagg: no [The C/C++ header for gtk (gtk/gtk.h) could not > be found. You may need to install the development > package.] > tkagg: no [The C/C++ header for Tk (tk.h) could not be > found. You may need to install the development > package.] > wxagg: no [requires wxPython] > gtk: no [The C/C++ header for gtk (gtk/gtk.h) could not > be found. You may need to install the development > package.] > agg: yes [installing] > cairo: yes [installing, pycairo version 1.8.8] > windowing: no [Microsoft Windows only] > > OPTIONAL LATEX DEPENDENCIES > dvipng: yes [version 1.14] > ghostscript: yes [version 9.15] > latex: yes [version 3.14159265] > pdftops: yes [version 0.30.0] > > OPTIONAL PACKAGE DATA > dlls: no [skipping due to configuration] > > ============================================================================ > * The following required packages can not be built: > * freetype, png > > > When I thereupon ran install command > $ python setup.py install > > I got the same output as above. Nothing happend. I have got v.1.4.2 on my machine, but would really like to have the dev version to test the new colormaps. > > Imran -------------- next part -------------- An HTML attachment was scrubbed... URL: From aeuii at posteo.de Tue Nov 3 05:54:46 2015 From: aeuii at posteo.de (aeuii at posteo.de) Date: Tue, 03 Nov 2015 11:54:46 +0100 Subject: [Matplotlib-users] get nrows and ncols from Figure Message-ID: <86a8qvs689.fsf@posteo.de> Hi, I'm using fig, axes = plt.subplots(nrows=2, ncols=3) to generate a figure and later in code I would like to find out how many columns and rows of are in the layout having only Figure object (fig). I was not able to find those parameters stored in `fig`. I noticed that fig.axes or fig.get_axes() return a flattened list of all axes, but without structure (like `axes` from `plt.subplots`). What's the best way to find out `nrows` and `ncols` from `fig`? Thanks in advance! Please CC me, because I'm not subscribed to the list. Best regards, Stefan From ben.v.root at gmail.com Wed Nov 4 11:24:42 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Wed, 4 Nov 2015 11:24:42 -0500 Subject: [Matplotlib-users] get nrows and ncols from Figure In-Reply-To: <86a8qvs689.fsf@posteo.de> References: <86a8qvs689.fsf@posteo.de> Message-ID: Wow, it is a bit convoluted. It looks like you can't get this information directly from the figure object because it is never stored in the figure. It is stored in the individual axes objects (go figure!). Furthermore, you would need to watch out for the use of fig.get_axes() because other axes may be added, such as colorbar axes and such, that were never a part of the original set of axes. To get the nrows/ncols from an Axes object: nrows, ncols, _, _ = ax.get_subplotspec().get_geometry() I hope that helps! Ben Root On Tue, Nov 3, 2015 at 5:54 AM, wrote: > Hi, > > I'm using > > fig, axes = plt.subplots(nrows=2, ncols=3) > > to generate a figure and later in code I would like to find out how many > columns and rows of are in the layout having only Figure object (fig). > > I was not able to find those parameters stored in `fig`. I noticed that > fig.axes or fig.get_axes() return a flattened list of all axes, but > without structure (like `axes` from `plt.subplots`). What's the best > way to find out `nrows` and `ncols` from `fig`? > > Thanks in advance! > > Please CC me, because I'm not subscribed to the list. > > Best regards, > Stefan > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonnojohnson at gmail.com Wed Nov 4 11:59:21 2015 From: jonnojohnson at gmail.com (Jonno) Date: Wed, 4 Nov 2015 10:59:21 -0600 Subject: [Matplotlib-users] ImportError on Anaconda Win64 system In-Reply-To: References: Message-ID: FYI I updated anaconda to 2.4 and still had the same issues. Note that I had installed Anaconda for all users. I decided to wipe Anaconda completely and do a fresh install just for my user and now the issue is gone. On Fri, Oct 30, 2015 at 4:07 PM, Benjamin Root wrote: > import matplotlib > matplotlib.get_backend() > > On Fri, Oct 30, 2015 at 4:24 PM, Jonno wrote: > >> Argh this is what I get from trying to do too many things at once. >> >> Correction, if I try to do: >> from pylab import * - with either WxAgg or Qt4Agg set in matplotlibrc I >> get: >> >> Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, Oct 21 2015, 19:35:23) >> [MSC v. >> 1500 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >> Anaconda is brought to you by Continuum Analytics. >> Please check out: http://continuum.io/thanks and https://anaconda.org >> >>> from pylab import * >> Traceback (most recent call last): >> File "", line 1, in >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\pylab. >> py", line 1, in >> from matplotlib.pylab import * >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\pylab.py", line 231, in >> import matplotlib.finance >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\finance.py", line 38, in >> from matplotlib.collections import LineCollection, PolyCollection >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\collections.py", line 27, in >> import matplotlib.backend_bases as backend_bases >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\backend_bases.py", line 56, in >> import matplotlib.textpath as textpath >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\textpath.py", line 22, in >> from matplotlib.mathtext import MathTextParser >> File >> "C:\Users\marnj\AppData\Local\Continuum\Anaconda\lib\site-packages\matplo >> tlib\mathtext.py", line 63, in >> import matplotlib._png as _png >> ImportError: DLL load failed: The specified module could not be found. >> >> How do I check the selected backend from within a python session? >> >> >> On Fri, Oct 30, 2015 at 2:41 PM, Benjamin Root >> wrote: >> >>> Then I suspect that the backend isn't really set properly, or matplotlib >>> is picking up the parameter from somewhere else. I just don't see how >>> having WxAgg as your backend could possibly trigger an import of the Qt >>> libraries. >>> >>> On Fri, Oct 30, 2015 at 3:35 PM, Jonno wrote: >>> >>>> Both. >>>> >>>> On Fri, Oct 30, 2015 at 1:08 PM, Benjamin Root >>>> wrote: >>>> >>>>> Doing that from IPython or Python? >>>>> >>>>> On Fri, Oct 30, 2015 at 1:55 PM, Jonno wrote: >>>>> >>>>>> I also get the same import error DLL load failed if I set the backend >>>>>> to WXAgg in matplotlibrc then try from pylab import * >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Oct 30, 2015 at 7:50 AM, Jens Nielsen >>>>> > wrote: >>>>>> >>>>>>> If that fails that is a bug in PyQt/Qt or in your anaconda >>>>>>> installation and not a Matplotlib bug. You could try reinstall QT and PyQt. >>>>>>> >>>>>>> As a workaround you can tell Matplotlib to use a different backend >>>>>>> http://matplotlib.org/faq/usage_faq.html#what-is-a-backend >>>>>>> >>>>>>> BTW the matplotlib mailing list has changed to >>>>>>> matplotlib-users at python.org. >>>>>>> >>>>>>> best >>>>>>> Jens >>>>>>> >>>>>>> fre. 30. okt. 2015 kl. 12.43 skrev Jonno : >>>>>>> >>>>>>>> Traceback (most recent call last): >>>>>>>> File "", line 1, in >>>>>>>> ImportError: DLL load failed: The specified module could not be >>>>>>>> found. >>>>>>>> >>>>>>>> On Fri, Oct 30, 2015 at 2:26 AM, Jens Nielsen < >>>>>>>> jenshnielsen at gmail.com> wrote: >>>>>>>> >>>>>>>>> It sounds like your PyQt package is broken. >>>>>>>>> >>>>>>>>> What happens if you do: >>>>>>>>> >>>>>>>>> from PyQt4 import QtCore, QtGui >>>>>>>>> >>>>>>>>> in a python shell >>>>>>>>> >>>>>>>>> /Jens >>>>>>>>> >>>>>>>>> fre. 30. okt. 2015 kl. 03.06 skrev Jonno : >>>>>>>>> >>>>>>>>>> Not sure where to post this. >>>>>>>>>> >>>>>>>>>> I have a fresh Anaconda Win64 python 2.7.10 install which I then >>>>>>>>>> updated using conda update --all. >>>>>>>>>> >>>>>>>>>> If it try to: >>>>>>>>>> from pylab import * >>>>>>>>>> I get the following: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> File >>>>>>>>>> "~\Anaconda\lib\site-packages\matplotlib\backends\qt_compat.py", line 91, >>>>>>>>>> in >>>>>>>>>> from PyQt4 import QtCore, QtGui >>>>>>>>>> ImportError: DLL load failed: The specified module could not be >>>>>>>>>> found. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I have the following installed: >>>>>>>>>> qt: 4.8.7 >>>>>>>>>> pyqt 4.11.4 >>>>>>>>>> matplotlib 1.4.3 >>>>>>>>>> >>>>>>>>>> Should I open an issue on matplotlib github? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> ------------------------------------------------------------------------------ >>>>>>>>>> _______________________________________________ >>>>>>>>>> Matplotlib-users mailing list >>>>>>>>>> Matplotlib-users at lists.sourceforge.net >>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Matplotlib-users at python.org >>>>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>>>> >>>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptso at nestlabs.com Wed Nov 4 22:45:22 2015 From: ptso at nestlabs.com (petertso) Date: Wed, 4 Nov 2015 20:45:22 -0700 (MST) Subject: [Matplotlib-users] [MAC OSX 10.10.5] upgrade from 1.3.1 to 1.5.0 Fail Message-ID: <1446695122681-46390.post@n5.nabble.com> Hi all, I met this failure but I didn't know how to fix it. My original matplotlib version is 1.3.1. Could anyone please teach me how to fix it? Thanks Peter petertso-macbookpro:scripts petertso$ pip install matplotlib --upgrade Collecting matplotlib Using cached matplotlib-1.5.0.tar.gz Complete output from command python setup.py egg_info: IMPORTANT WARNING: pkg-config is not installed. matplotlib may not be able to find some of its dependencies ============================================================================ Edit setup.cfg to change the build options BUILDING MATPLOTLIB matplotlib: yes [1.5.0] python: yes [2.7.7 |Anaconda 2.0.1 (x86_64)| (default, Jun 2 2014, 12:48:16) [GCC 4.0.1 (Apple Inc. build 5493)]] platform: yes [darwin] REQUIRED DEPENDENCIES AND EXTENSIONS numpy: yes [version 1.8.1] dateutil: yes [using dateutil version 1.5] pytz: yes [using pytz version 2014.3] cycler: yes [cycler was not found. pip will attempt to install it after matplotlib.] tornado: yes [using tornado version 3.2.1] pyparsing: yes [using pyparsing version 2.0.1] libagg: yes [pkg-config information for 'libagg' could not be found. Using local copy.] freetype: no [The C/C++ header for freetype2 (ft2build.h) could not be found. You may need to install the development package.] png: yes [version 1.5.13] qhull: yes [pkg-config information for 'qhull' could not be found. Using local copy.] OPTIONAL SUBPACKAGES sample_data: yes [installing] toolkits: yes [installing] tests: yes [using nose version 1.3.3 / using mock 1.0.1] toolkits_tests: yes [using nose version 1.3.3 / using mock 1.0.1] OPTIONAL BACKEND EXTENSIONS macosx: yes [installing, darwin] qt5agg: no [PyQt5 not found] qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide not found] gtk3agg: no [Requires pygobject to be installed.] gtk3cairo: no [Requires cairocffi or pycairo to be installed.] gtkagg: no [Requires pygtk] tkagg: no [The C/C++ header for Tk (tk.h) could not be found. You may need to install the development package.] wxagg: no [requires wxPython] gtk: no [Requires pygtk] agg: yes [installing] cairo: no [cairocffi or pycairo not found] windowing: no [Microsoft Windows only] OPTIONAL LATEX DEPENDENCIES dvipng: yes [version 1.14] ghostscript: yes [version 9.10] latex: yes [version 3.14159265] pdftops: no OPTIONAL PACKAGE DATA dlls: no [skipping due to configuration] ============================================================================ * The following required packages can not be built: * freetype ---------------------------------------- *Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/00/1t1jr000h01000cxqpysvccm007867/T/pip-build-6pnLIL/matplotlib* petertso-macbookpro:scripts petertso$ -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MAC-OSX-10-10-5-upgrade-from-1-3-1-to-1-5-0-Fail-tp46390.html Sent from the matplotlib - users mailing list archive at Nabble.com. From egayer at gmail.com Thu Nov 5 05:00:13 2015 From: egayer at gmail.com (Eric Gayer) Date: Thu, 5 Nov 2015 11:00:13 +0100 Subject: [Matplotlib-users] natgrid Message-ID: <27327EB9-BA11-4A89-9794-0674EEEAAC55@gmail.com> Hi all, I would like to be able to use matplotlib.mlab.griddata(x, y, z, xi, yi, interp='nn?) using natural neighbor interpolation. To do so we need to install the mpl_toolkits.natgrid module (http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.griddata) However I have not found any tutorial to help me properly install the mpl_toolkits.natgrid module (https://github.com/matplotlib/natgrid). I am used to "conda install" and "pip install" and would like to know if anyone could give me some directions for properly installing this module. (I know this request may sounds crazy for some of you since it is basics) thanks in advance Eric mac osX 10.9.5 Python 2.7.10 |Anaconda 2.0.1 (x86_64)| [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Matplotlib 1.4.3 From tcaswell at gmail.com Thu Nov 5 08:03:45 2015 From: tcaswell at gmail.com (Thomas Caswell) Date: Thu, 05 Nov 2015 13:03:45 +0000 Subject: [Matplotlib-users] [MAC OSX 10.10.5] upgrade from 1.3.1 to 1.5.0 Fail In-Reply-To: <1446695122681-46390.post@n5.nabble.com> References: <1446695122681-46390.post@n5.nabble.com> Message-ID: It is odd that you are getting the tarball not the osx wheels. You need to install both pkg-config and the development version of freetype. Tom On Thu, Nov 5, 2015, 07:53 petertso wrote: > Hi all, > > I met this failure but I didn't know how to fix it. > My original matplotlib version is 1.3.1. > Could anyone please teach me how to fix it? > > Thanks > Peter > > petertso-macbookpro:scripts petertso$ pip install matplotlib --upgrade > Collecting matplotlib > Using cached matplotlib-1.5.0.tar.gz > Complete output from command python setup.py egg_info: > IMPORTANT WARNING: > pkg-config is not installed. > matplotlib may not be able to find some of its dependencies > > > ============================================================================ > Edit setup.cfg to change the build options > > BUILDING MATPLOTLIB > matplotlib: yes [1.5.0] > python: yes [2.7.7 |Anaconda 2.0.1 (x86_64)| (default, > Jun > 2 2014, 12:48:16) [GCC 4.0.1 (Apple Inc. build > 5493)]] > platform: yes [darwin] > > REQUIRED DEPENDENCIES AND EXTENSIONS > numpy: yes [version 1.8.1] > dateutil: yes [using dateutil version 1.5] > pytz: yes [using pytz version 2014.3] > cycler: yes [cycler was not found. pip will attempt to > install it after matplotlib.] > tornado: yes [using tornado version 3.2.1] > pyparsing: yes [using pyparsing version 2.0.1] > libagg: yes [pkg-config information for 'libagg' could > not > be found. Using local copy.] > freetype: no [The C/C++ header for freetype2 > (ft2build.h) > could not be found. You may need to install > the > development package.] > png: yes [version 1.5.13] > qhull: yes [pkg-config information for 'qhull' could > not be > found. Using local copy.] > > OPTIONAL SUBPACKAGES > sample_data: yes [installing] > toolkits: yes [installing] > tests: yes [using nose version 1.3.3 / using mock > 1.0.1] > toolkits_tests: yes [using nose version 1.3.3 / using mock > 1.0.1] > > OPTIONAL BACKEND EXTENSIONS > macosx: yes [installing, darwin] > qt5agg: no [PyQt5 not found] > qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide > not > found] > gtk3agg: no [Requires pygobject to be installed.] > gtk3cairo: no [Requires cairocffi or pycairo to be > installed.] > gtkagg: no [Requires pygtk] > tkagg: no [The C/C++ header for Tk (tk.h) could not > be > found. You may need to install the development > package.] > wxagg: no [requires wxPython] > gtk: no [Requires pygtk] > agg: yes [installing] > cairo: no [cairocffi or pycairo not found] > windowing: no [Microsoft Windows only] > > OPTIONAL LATEX DEPENDENCIES > dvipng: yes [version 1.14] > ghostscript: yes [version 9.10] > latex: yes [version 3.14159265] > pdftops: no > > OPTIONAL PACKAGE DATA > dlls: no [skipping due to configuration] > > > > ============================================================================ > * The following required packages can not be > built: > * freetype > > ---------------------------------------- > *Command "python setup.py egg_info" failed with error code 1 in > > /private/var/folders/00/1t1jr000h01000cxqpysvccm007867/T/pip-build-6pnLIL/matplotlib* > petertso-macbookpro:scripts petertso$ > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/MAC-OSX-10-10-5-upgrade-from-1-3-1-to-1-5-0-Fail-tp46390.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdroettboom at continuum.io Thu Nov 5 08:10:54 2015 From: mdroettboom at continuum.io (Michael Droettboom) Date: Thu, 5 Nov 2015 08:10:54 -0500 Subject: [Matplotlib-users] [MAC OSX 10.10.5] upgrade from 1.3.1 to 1.5.0 Fail In-Reply-To: References: <1446695122681-46390.post@n5.nabble.com> Message-ID: I just tested on a Mac and `pip install matplotlib` gives me a wheel. Maybe your version of pip is too old? (I have 1.5.6 here, for what it's worth). Mike On Thu, Nov 5, 2015 at 8:03 AM, Thomas Caswell wrote: > It is odd that you are getting the tarball not the osx wheels. > > You need to install both pkg-config and the development version of > freetype. > > Tom > > On Thu, Nov 5, 2015, 07:53 petertso wrote: > >> Hi all, >> >> I met this failure but I didn't know how to fix it. >> My original matplotlib version is 1.3.1. >> Could anyone please teach me how to fix it? >> >> Thanks >> Peter >> >> petertso-macbookpro:scripts petertso$ pip install matplotlib --upgrade >> Collecting matplotlib >> Using cached matplotlib-1.5.0.tar.gz >> Complete output from command python setup.py egg_info: >> IMPORTANT WARNING: >> pkg-config is not installed. >> matplotlib may not be able to find some of its dependencies >> >> >> ============================================================================ >> Edit setup.cfg to change the build options >> >> BUILDING MATPLOTLIB >> matplotlib: yes [1.5.0] >> python: yes [2.7.7 |Anaconda 2.0.1 (x86_64)| (default, >> Jun >> 2 2014, 12:48:16) [GCC 4.0.1 (Apple Inc. >> build >> 5493)]] >> platform: yes [darwin] >> >> REQUIRED DEPENDENCIES AND EXTENSIONS >> numpy: yes [version 1.8.1] >> dateutil: yes [using dateutil version 1.5] >> pytz: yes [using pytz version 2014.3] >> cycler: yes [cycler was not found. pip will attempt to >> install it after matplotlib.] >> tornado: yes [using tornado version 3.2.1] >> pyparsing: yes [using pyparsing version 2.0.1] >> libagg: yes [pkg-config information for 'libagg' could >> not >> be found. Using local copy.] >> freetype: no [The C/C++ header for freetype2 >> (ft2build.h) >> could not be found. You may need to install >> the >> development package.] >> png: yes [version 1.5.13] >> qhull: yes [pkg-config information for 'qhull' could >> not be >> found. Using local copy.] >> >> OPTIONAL SUBPACKAGES >> sample_data: yes [installing] >> toolkits: yes [installing] >> tests: yes [using nose version 1.3.3 / using mock >> 1.0.1] >> toolkits_tests: yes [using nose version 1.3.3 / using mock >> 1.0.1] >> >> OPTIONAL BACKEND EXTENSIONS >> macosx: yes [installing, darwin] >> qt5agg: no [PyQt5 not found] >> qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; >> PySide >> not >> found] >> gtk3agg: no [Requires pygobject to be installed.] >> gtk3cairo: no [Requires cairocffi or pycairo to be >> installed.] >> gtkagg: no [Requires pygtk] >> tkagg: no [The C/C++ header for Tk (tk.h) could not >> be >> found. You may need to install the >> development >> package.] >> wxagg: no [requires wxPython] >> gtk: no [Requires pygtk] >> agg: yes [installing] >> cairo: no [cairocffi or pycairo not found] >> windowing: no [Microsoft Windows only] >> >> OPTIONAL LATEX DEPENDENCIES >> dvipng: yes [version 1.14] >> ghostscript: yes [version 9.10] >> latex: yes [version 3.14159265] >> pdftops: no >> >> OPTIONAL PACKAGE DATA >> dlls: no [skipping due to configuration] >> >> >> >> ============================================================================ >> * The following required packages can not be >> built: >> * freetype >> >> ---------------------------------------- >> *Command "python setup.py egg_info" failed with error code 1 in >> >> /private/var/folders/00/1t1jr000h01000cxqpysvccm007867/T/pip-build-6pnLIL/matplotlib* >> petertso-macbookpro:scripts petertso$ >> >> >> >> -- >> View this message in context: >> http://matplotlib.1069221.n5.nabble.com/MAC-OSX-10-10-5-upgrade-from-1-3-1-to-1-5-0-Fail-tp46390.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -- Michael Droettboom Continuum Analytics -------------- next part -------------- An HTML attachment was scrubbed... URL: From tritemio at gmail.com Thu Nov 5 12:31:53 2015 From: tritemio at gmail.com (Antonino Ingargiola) Date: Thu, 5 Nov 2015 09:31:53 -0800 Subject: [Matplotlib-users] natgrid In-Reply-To: <27327EB9-BA11-4A89-9794-0674EEEAAC55@gmail.com> References: <27327EB9-BA11-4A89-9794-0674EEEAAC55@gmail.com> Message-ID: Hi Eric, in general, if a python package provides a properly written setup.py you can install it from sources with: $ pip install . from within the source directory. Hope this helps, Antonio On Thu, Nov 5, 2015 at 2:00 AM, Eric Gayer wrote: > Hi all, > > I would like to be able to use matplotlib.mlab.griddata(x, y, z, xi, yi, > interp='nn?) using natural neighbor interpolation. To do so we need to > install the mpl_toolkits.natgrid module > (http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.griddata) > > However I have not found any tutorial to help me properly install the > mpl_toolkits.natgrid module (https://github.com/matplotlib/natgrid). > I am used to "conda install" and "pip install" and would like to know if > anyone could give me some directions for properly installing this module. > (I know this request may sounds crazy for some of you since it is basics) > > thanks in advance > Eric > > mac osX 10.9.5 > Python 2.7.10 |Anaconda 2.0.1 (x86_64)| > > [GCC 4.2.1 (Apple Inc. build 5577)] on darwin > > Matplotlib 1.4.3 > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Sat Nov 7 00:41:03 2015 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 6 Nov 2015 19:41:03 -1000 Subject: [Matplotlib-users] Installing matplotlib dev version on ubuntu from source file In-Reply-To: <572D05F9-ADFB-4071-BB48-F05CC55B8BF6@math.uio.no> References: <572D05F9-ADFB-4071-BB48-F05CC55B8BF6@math.uio.no> Message-ID: <563D8EEF.8070904@hawaii.edu> On 2015/11/04 4:05 AM, Imran Ali wrote: > / freetype: no [The C/C++ header for freetype2 (ft2build.h)/ > / could not be found. You may need to install the/ > / development package.]/ > / png: no [pkg-config information for 'libpng' could not/ > / be found.]/ It looks like you need to install two development packages using your linux distro package manager. If you are using ubuntu 14.04, for example, it would be sudo apt-get install libfreetype6-dev libpng12-dev Eric From egayer at gmail.com Thu Nov 5 15:30:58 2015 From: egayer at gmail.com (Eric Gayer) Date: Thu, 5 Nov 2015 21:30:58 +0100 Subject: [Matplotlib-users] natgrid In-Reply-To: References: <27327EB9-BA11-4A89-9794-0674EEEAAC55@gmail.com> Message-ID: Dear Antonino, Thanks for your help, i was not sure if typing : python setup.py install would work, especially because I was not sure if setup.py would find the anaconda distribution. I will try your way Thanks again Eric > On Nov 5, 2015, at 6:31 PM, Antonino Ingargiola wrote: > > Hi Eric, > > in general, if a python package provides a properly written setup.py you can install it from sources with: > > $ pip install . > > from within the source directory. > > Hope this helps, > Antonio > >> On Thu, Nov 5, 2015 at 2:00 AM, Eric Gayer wrote: >> Hi all, >> >> I would like to be able to use matplotlib.mlab.griddata(x, y, z, xi, yi, interp='nn?) using natural neighbor interpolation. To do so we need to install the mpl_toolkits.natgrid module >> (http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.griddata) >> >> However I have not found any tutorial to help me properly install the mpl_toolkits.natgrid module (https://github.com/matplotlib/natgrid). >> I am used to "conda install" and "pip install" and would like to know if anyone could give me some directions for properly installing this module. (I know this request may sounds crazy for some of you since it is basics) >> >> thanks in advance >> Eric >> >> mac osX 10.9.5 >> Python 2.7.10 |Anaconda 2.0.1 (x86_64)| >> >> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin >> >> Matplotlib 1.4.3 >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From src10 at hotmail.com Fri Nov 6 10:37:55 2015 From: src10 at hotmail.com (src10) Date: Fri, 6 Nov 2015 08:37:55 -0700 (MST) Subject: [Matplotlib-users] [Mac OS X 10.10.5] Macports install error :unknown locale: UTF-8 Message-ID: <1446824275638-46395.post@n5.nabble.com> Hi guys! I am new to python and matplotlib. I installed everything with macports and when I run the matplotlib test python2.7 -c 'import matplotlib; print matplotlib.__version__, matplotlib.__file__' I get the following Traceback (most recent call last): File "", line 1, in File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in rcParams = rc_params() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params return rc_params_from_file(fname, fail_on_error) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file config_from_file = _rc_params_in_file(fname, fail_on_error) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file with _open_file_or_url(fname) as fd: File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url encoding = locale.getdefaultlocale()[1] File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale return _parse_localename(localename) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename raise ValueError, 'unknown locale: %s' % localename ValueError: unknown locale: UTF-8 Do you guys have any idea what is happening....I have not done enything weards just follow simple steps to install it. I want to use QUTIP and the matplotlib is essential for it...please if someone know it would be really nice thanks! regards, -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Mac-OS-X-10-10-5-Macports-install-error-unknown-locale-UTF-8-tp46395.html Sent from the matplotlib - users mailing list archive at Nabble.com. From ross.john.de at gmail.com Sat Nov 7 09:14:04 2015 From: ross.john.de at gmail.com (rossjohn) Date: Sat, 7 Nov 2015 07:14:04 -0700 (MST) Subject: [Matplotlib-users] [matplotlib.finance] is there some methods to define timeout while using fetch_historical_yahoo Message-ID: <1446905644397-46400.post@n5.nabble.com> Hello, I have a question while I was using fetch_historical_yahoo to download trading data from Yahoo. I was trying to fetch nearly 4000 stocks data everyday. But sometimes there was no response from Yahoo and the Programm was hanging there like it died. I checked the manuell of fetch_historical_yahoo but did not found something to kill the requests or to define the amount of retrys. Could someone tell me how to add a timeout check into fetch_historical_yahoo? Thanks Ross from Germany -- View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-finance-is-there-some-methods-to-define-timeout-while-using-fetch-historical-yahoo-tp46400.html Sent from the matplotlib - users mailing list archive at Nabble.com. From tcaswell at gmail.com Sat Nov 7 10:45:28 2015 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 07 Nov 2015 15:45:28 +0000 Subject: [Matplotlib-users] [Mac OS X 10.10.5] Macports install error :unknown locale: UTF-8 In-Reply-To: <1446824275638-46395.post@n5.nabble.com> References: <1446824275638-46395.post@n5.nabble.com> Message-ID: See https://github.com/matplotlib/matplotlib/issues/5420 for previous discussion of this issue. On Sat, Nov 7, 2015 at 10:23 AM src10 wrote: > Hi guys! > I am new to python and matplotlib. > I installed everything with macports and when I run the matplotlib test > > python2.7 -c 'import matplotlib; print matplotlib.__version__, > matplotlib.__file__' > > I get the following > > Traceback (most recent call last): > File "", line 1, in > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 1131, in > rcParams = rc_params() > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 975, in rc_params > return rc_params_from_file(fname, fail_on_error) > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 1100, in rc_params_from_file > config_from_file = _rc_params_in_file(fname, fail_on_error) > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 1018, in _rc_params_in_file > with _open_file_or_url(fname) as fd: > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", > line 17, in __enter__ > return self.gen.next() > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 1000, in _open_file_or_url > encoding = locale.getdefaultlocale()[1] > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 543, in getdefaultlocale > return _parse_localename(localename) > File > > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 475, in _parse_localename > raise ValueError, 'unknown locale: %s' % localename > ValueError: unknown locale: UTF-8 > > > Do you guys have any idea what is happening....I have not done enything > weards just follow simple steps to install it. > > I want to use QUTIP and the matplotlib is essential for it...please if > someone know it would be really nice > > > thanks! > regards, > > > > > > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Mac-OS-X-10-10-5-Macports-install-error-unknown-locale-UTF-8-tp46395.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmhobson at gmail.com Sat Nov 7 18:52:20 2015 From: pmhobson at gmail.com (Paul Hobson) Date: Sat, 7 Nov 2015 15:52:20 -0800 Subject: [Matplotlib-users] natgrid In-Reply-To: References: <27327EB9-BA11-4A89-9794-0674EEEAAC55@gmail.com> Message-ID: > I was not sure if setup.py would find the anaconda distribution It finds the first python on your path. So activate your environment before running, On Thu, Nov 5, 2015 at 12:30 PM, Eric Gayer wrote: > Dear Antonino, > Thanks for your help, i was not sure if typing : > > python setup.py install > > would work, especially because I was not sure if setup.py would find the > anaconda distribution. > I will try your way > > Thanks again > Eric > > > On Nov 5, 2015, at 6:31 PM, Antonino Ingargiola > wrote: > > Hi Eric, > > in general, if a python package provides a properly written setup.py you > can install it from sources with: > > $ pip install . > > from within the source directory. > > Hope this helps, > Antonio > > On Thu, Nov 5, 2015 at 2:00 AM, Eric Gayer wrote: > >> Hi all, >> >> I would like to be able to use matplotlib.mlab.griddata(x, y, z, xi, yi, >> interp='nn?) using natural neighbor interpolation. To do so we need to >> install the mpl_toolkits.natgrid module >> (http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.griddata) >> >> However I have not found any tutorial to help me properly install the >> mpl_toolkits.natgrid module (https://github.com/matplotlib/natgrid). >> I am used to "conda install" and "pip install" and would like to know if >> anyone could give me some directions for properly installing this module. >> (I know this request may sounds crazy for some of you since it is basics) >> >> thanks in advance >> Eric >> >> mac osX 10.9.5 >> Python 2.7.10 |Anaconda 2.0.1 (x86_64)| >> >> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin >> >> Matplotlib 1.4.3 >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Wed Nov 11 06:16:38 2015 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Wed, 11 Nov 2015 22:16:38 +1100 Subject: [Matplotlib-users] Unable to install 1.5.0 on conda env in OSX 10.11 Message-ID: Hi, I'm having the same problem as a previous user: missing freetype (even though I have placed the freetype devel headers in my/conda/env/include), and I don't get a wheel with pip install (pip --version says 7.1.2). I notice that the wheels on PyPI don't mention OSX 10.11 at all... Any ideas? (Of course it would be best if there were some conda packages somewhere...!) Thanks, Juan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From surf at libecciu.ch Wed Nov 11 08:28:26 2015 From: surf at libecciu.ch (Remo Goetschi) Date: Wed, 11 Nov 2015 14:28:26 +0100 Subject: [Matplotlib-users] contourf looking ugly with transparent colors Message-ID: <5643427A.8020302@libecciu.ch> Hi, Does somebody know how to produce a good-looking filled contour plot with semi-transparent colors? If contourf() is passed a colormap with semi-transparent colors, it produces small gaps between the filled areas: http://i.stack.imgur.com/eEQXI.png According to the docs, this is not a bug ("contourf() [...] does not draw the polygon edges"). To draw the edges, it is suggested to "add line contours with calls to contour()". But that doesn't look good either as the edges become too opaque: http://i.stack.imgur.com/s17F9.png You can play with the linewidth argument of contour(), but that doesn't help much. Any ideas? The code that reproduces the problem is attached below (I use the object-oriented API, but the result is the same with pyplot). BTW, pcolormesh() suffers from a similar problem: http://i.stack.imgur.com/Gbwcb.png Both problems do not seem to occur with the SVG backend. I asked the same question already on stackoverflow. Feel free to respond there: http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors Thanks, Remo --------- import matplotlib import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg # generate some data shape = (100, 100) x_rng = np.linspace(-1, 1, shape[1]) y_rng = np.linspace(-1, 1, shape[0]) x, y = np.meshgrid(x_rng, y_rng) z = np.sqrt(x**2 + y**2) # create figure width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 fig = Figure() fig.set_size_inches((width_inch, height_inch)) FigureCanvasAgg(fig) ax = fig.add_axes([0., 0., 1., 1.]) ax.set_axis_off() # define some colors with alpha < 1 alpha = 0.9 colors = [ (0.1, 0.1, 0.5, alpha), # dark blue (0.0, 0.7, 0.3, alpha), # green (0.9, 0.2, 0.7, alpha), # pink (0.0, 0.0, 0.0, alpha), # black (0.1, 0.7, 0.7, alpha), # light blue ] cmap = matplotlib.colors.ListedColormap(colors) levels = np.array(np.linspace(0, z.max(), len(colors))) norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) # contourf plot produces small gaps between filled areas cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, antialiased=True, linecolor='none') # this fills the gaps, but it makes them too opaque # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, # antialiased=True) # the same is true for this trick: # for c in cnt.collections: # c.set_edgecolor("face") filename = "/tmp/contourf.png" fig.savefig(filename, dpi=100, transparent=True, format="png") print("Saved plot to {}.".format(filename)) From jenshnielsen at gmail.com Wed Nov 11 09:53:09 2015 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Wed, 11 Nov 2015 14:53:09 +0000 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: <5643427A.8020302@libecciu.ch> References: <5643427A.8020302@libecciu.ch> Message-ID: The issue you are seeing is slightly different from the one the docs mention. I wrote the docs suggesting the work around and this is mainly relevant for vector backends (PDF and so on) The problem with PDF viewers is that many of them create visible gaps when two polygons are rendered next to each other with zero overlap. This is a viewer specific thing but lots of viewers suffers from this. This effect is much more visible that the one you see. I think the one you see is due to the way the edge between the 2 colours is antialiased by the render. The work around with adding edges is only a workaround exactly as you remarked because it doesn't work well with non transparent surfaces. best Jens On Wed, 11 Nov 2015 at 13:44 Remo Goetschi wrote: > Hi, > > Does somebody know how to produce a good-looking filled contour plot > with semi-transparent colors? If contourf() is passed a colormap with > semi-transparent colors, it produces small gaps between the filled areas: > http://i.stack.imgur.com/eEQXI.png > > According to the docs, this is not a bug ("contourf() [...] does not > draw the polygon edges"). To draw the edges, it is suggested to "add > line contours with calls to contour()". But that doesn't look good > either as the edges become too opaque: > http://i.stack.imgur.com/s17F9.png > You can play with the linewidth argument of contour(), but that doesn't > help much. Any ideas? > > The code that reproduces the problem is attached below (I use the > object-oriented API, but the result is the same with pyplot). > > BTW, pcolormesh() suffers from a similar problem: > http://i.stack.imgur.com/Gbwcb.png > > Both problems do not seem to occur with the SVG backend. > > I asked the same question already on stackoverflow. Feel free to respond > there: > > http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors > > Thanks, > Remo > > --------- > import matplotlib > import numpy as np > from matplotlib.figure import Figure > from matplotlib.backends.backend_agg import FigureCanvasAgg > > # generate some data > shape = (100, 100) > x_rng = np.linspace(-1, 1, shape[1]) > y_rng = np.linspace(-1, 1, shape[0]) > x, y = np.meshgrid(x_rng, y_rng) > z = np.sqrt(x**2 + y**2) > > # create figure > width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 > fig = Figure() > fig.set_size_inches((width_inch, height_inch)) > FigureCanvasAgg(fig) > ax = fig.add_axes([0., 0., 1., 1.]) > ax.set_axis_off() > > # define some colors with alpha < 1 > alpha = 0.9 > colors = [ > (0.1, 0.1, 0.5, alpha), # dark blue > (0.0, 0.7, 0.3, alpha), # green > (0.9, 0.2, 0.7, alpha), # pink > (0.0, 0.0, 0.0, alpha), # black > (0.1, 0.7, 0.7, alpha), # light blue > ] > cmap = matplotlib.colors.ListedColormap(colors) > levels = np.array(np.linspace(0, z.max(), len(colors))) > norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) > > # contourf plot produces small gaps between filled areas > cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, > antialiased=True, linecolor='none') > > # this fills the gaps, but it makes them too opaque > # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, > # antialiased=True) > > # the same is true for this trick: > # for c in cnt.collections: > # c.set_edgecolor("face") > > filename = "/tmp/contourf.png" > fig.savefig(filename, dpi=100, transparent=True, format="png") > print("Saved plot to {}.".format(filename)) > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Al.Niessner at gmx.net Wed Nov 11 22:47:31 2015 From: Al.Niessner at gmx.net (Al Niessner) Date: Wed, 11 Nov 2015 19:47:31 -0800 Subject: [Matplotlib-users] paths optimizer Message-ID: <1447300051.2629.22.camel@charon> I have three paths that each define a bounding box. Lets just say I have these three in (x,y) coordinates and all are moveto, lineto, lineto, lineto, and closepoly: 1: (0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1), (0, 0) 2: (.9, 0), (2, 0), (2, 1.1), (.9, 1.1), (.9, 0) 3: (.9, .9), (2, .9), (2, 2), (.9, 2) (.9, .9) While my paths have more nodes and are not as cleanly vertical and horizontal, it does cover the nature of what I am experiencing. The first thing to note is that each box has overlap at x = 1 and y = 1 and all three boxes overlap at (1,1). What I am looking for is an optimizer that would be smart enough to say hey, because of the overlap, we can trim the boxes to: 1: (0,0) (1,0) (1,1) (0,1) (0,0) 2: (1,0) (2,0) (2,1), (1,1), (1,0) 3: (1,1) (2,1) (2,2), (1,2), (1,1) I am not sure that optimizer is the right word to use either. I have poked around matplotlib a bit (over many years) and tried searching but guessing the search terms is not simple either. Hence, I am asking if anyone is aware of matplotlib functionality that will help me do this task. Any other tool outside of matplotlib would be just as nice of a suggestion. One last bit, it has to work for N paths. As always, thanks in advance. -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers From ianthomas23 at gmail.com Thu Nov 12 03:21:01 2015 From: ianthomas23 at gmail.com (Ian Thomas) Date: Thu, 12 Nov 2015 08:21:01 +0000 Subject: [Matplotlib-users] paths optimizer In-Reply-To: <1447300051.2629.22.camel@charon> References: <1447300051.2629.22.camel@charon> Message-ID: Hello Al, The search terms you are looking for are 'polygon clipping' and 'boolean operations on polygons'. Matplotlib can clip one polygon with respect to another, there is a simple example at http://stackoverflow.com/questions/22612323/clipping-a-triagle-with-a-circle-in-matplotlib Alternatively, for more flexibility use shapely. For example: from shapely.geometry import Polygon a = Polygon([(0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1)]) b = Polygon([(.9, 0), (2, 0), (2, 1.1), (.9, 1.1)]) c = Polygon([(.9, .9), (2, .9), (2, 2), (.9, 2)]) d = a.intersection(b).intersection(c) print(d) which outputs POLYGON ((0.9 0.9, 0.9 1.1, 1.1 1.1, 1.1 0.9, 0.9 0.9)) i.e. a rectangle from x = 0.9 to 1.1 and y from 0.9 to 1.1. Ian Thomas On 12 November 2015 at 03:47, Al Niessner wrote: > > I have three paths that each define a bounding box. Lets just say I have > these three in (x,y) coordinates and all are moveto, lineto, lineto, > lineto, and closepoly: > > 1: (0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1), (0, 0) > 2: (.9, 0), (2, 0), (2, 1.1), (.9, 1.1), (.9, 0) > 3: (.9, .9), (2, .9), (2, 2), (.9, 2) (.9, .9) > > While my paths have more nodes and are not as cleanly vertical and > horizontal, it does cover the nature of what I am experiencing. > > The first thing to note is that each box has overlap at x = 1 and y = 1 > and all three boxes overlap at (1,1). > > What I am looking for is an optimizer that would be smart enough to say > hey, because of the overlap, we can trim the boxes to: > > 1: (0,0) (1,0) (1,1) (0,1) (0,0) > 2: (1,0) (2,0) (2,1), (1,1), (1,0) > 3: (1,1) (2,1) (2,2), (1,2), (1,1) > > I am not sure that optimizer is the right word to use either. I have > poked around matplotlib a bit (over many years) and tried searching but > guessing the search terms is not simple either. Hence, I am asking if > anyone is aware of matplotlib functionality that will help me do this > task. Any other tool outside of matplotlib would be just as nice of a > suggestion. One last bit, it has to work for N paths. > > As always, thanks in advance. > > -- > Al Niessner > > I have never found the companion that was so companionable as solitude. > - From Walden by Henry David Thoreau > > The universe is indifferent, and life is brutal; however, it is man's > choice of behavior that makes them malevolent rather than benevolent. > > Some will fall in love with life and drink it from a fountain > That is pouring like an avalanche coming down the mountain. > - From the song Pepper by the Butthole Surfers > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From surf at libecciu.ch Thu Nov 12 04:07:40 2015 From: surf at libecciu.ch (Remo Goetschi) Date: Thu, 12 Nov 2015 10:07:40 +0100 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: References: <5643427A.8020302@libecciu.ch> Message-ID: <564456DC.6080709@libecciu.ch> Hi, Thanks for your response. Hm, are you saying there is probably no way to work around this? Are there other opinions? Personally, I consider this a bug (or two bugs, since pcolormesh() has a problem as well). It looks really ugly if you, e.g., use semi-transparent plots as map overlays. Cheers, Remo On 11.11.2015 15:53, Jens Nielsen wrote: > The issue you are seeing is slightly different from the one the docs > mention. > I wrote the docs suggesting the work around and this is mainly relevant > for vector backends (PDF and so on) The problem with PDF viewers is that > many of them create visible gaps when two polygons are rendered next to > each other with zero overlap. This is a viewer specific thing but lots > of viewers suffers from this. > This effect is much more visible that the one you see. I think the one > you see is due to the way the edge between the 2 colours is antialiased > by the render. > > The work around with adding edges is only a workaround exactly as you > remarked because it doesn't work well with non transparent surfaces. > > best > Jens > > On Wed, 11 Nov 2015 at 13:44 Remo Goetschi > wrote: > > Hi, > > Does somebody know how to produce a good-looking filled contour plot > with semi-transparent colors? If contourf() is passed a colormap with > semi-transparent colors, it produces small gaps between the filled > areas: > http://i.stack.imgur.com/eEQXI.png > > According to the docs, this is not a bug ("contourf() [...] does not > draw the polygon edges"). To draw the edges, it is suggested to "add > line contours with calls to contour()". But that doesn't look good > either as the edges become too opaque: > http://i.stack.imgur.com/s17F9.png > You can play with the linewidth argument of contour(), but that doesn't > help much. Any ideas? > > The code that reproduces the problem is attached below (I use the > object-oriented API, but the result is the same with pyplot). > > BTW, pcolormesh() suffers from a similar problem: > http://i.stack.imgur.com/Gbwcb.png > > Both problems do not seem to occur with the SVG backend. > > I asked the same question already on stackoverflow. Feel free to respond > there: > http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors > > Thanks, > Remo > > --------- > import matplotlib > import numpy as np > from matplotlib.figure import Figure > from matplotlib.backends.backend_agg import FigureCanvasAgg > > # generate some data > shape = (100, 100) > x_rng = np.linspace(-1, 1, shape[1]) > y_rng = np.linspace(-1, 1, shape[0]) > x, y = np.meshgrid(x_rng, y_rng) > z = np.sqrt(x**2 + y**2) > > # create figure > width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 > fig = Figure() > fig.set_size_inches((width_inch, height_inch)) > FigureCanvasAgg(fig) > ax = fig.add_axes([0., 0., 1., 1.]) > ax.set_axis_off() > > # define some colors with alpha < 1 > alpha = 0.9 > colors = [ > (0.1, 0.1, 0.5, alpha), # dark blue > (0.0, 0.7, 0.3, alpha), # green > (0.9, 0.2, 0.7, alpha), # pink > (0.0, 0.0, 0.0, alpha), # black > (0.1, 0.7, 0.7, alpha), # light blue > ] > cmap = matplotlib.colors.ListedColormap(colors) > levels = np.array(np.linspace(0, z.max(), len(colors))) > norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) > > # contourf plot produces small gaps between filled areas > cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, > antialiased=True, linecolor='none') > > # this fills the gaps, but it makes them too opaque > # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, > # antialiased=True) > > # the same is true for this trick: > # for c in cnt.collections: > # c.set_edgecolor("face") > > filename = "/tmp/contourf.png" > fig.savefig(filename, dpi=100, transparent=True, format="png") > print("Saved plot to {}.".format(filename)) > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From Al.Niessner at gmx.net Thu Nov 12 11:34:56 2015 From: Al.Niessner at gmx.net (Al Niessner) Date: Thu, 12 Nov 2015 08:34:56 -0800 Subject: [Matplotlib-users] paths optimizer In-Reply-To: References: <1447300051.2629.22.camel@charon> Message-ID: <1447346096.3470.3.camel@charon> If I understand them both correctly (will need more time to fully appreciate what the documentation is telling me) it seems I will need to use both. I can use shapely to find the intersections in order to form my new path and then use matplotlib patches to clip the original polygons. Maybe shapely can clip too but I did not find it in the first 30 seconds that I was looking at the documentation. Thanks for the help. On Thu, 2015-11-12 at 08:21 +0000, Ian Thomas wrote: > Hello Al, > > The search terms you are looking for are 'polygon clipping' and > 'boolean operations on polygons'. > > > Matplotlib can clip one polygon with respect to another, there is a > simple example at > http://stackoverflow.com/questions/22612323/clipping-a-triagle-with-a-circle-in-matplotlib > > > Alternatively, for more flexibility use shapely. For example: > > from shapely.geometry import Polygon > a = Polygon([(0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1)]) > b = Polygon([(.9, 0), (2, 0), (2, 1.1), (.9, 1.1)]) > c = Polygon([(.9, .9), (2, .9), (2, 2), (.9, 2)]) > > d = a.intersection(b).intersection(c) > > print(d) > > which outputs > > POLYGON ((0.9 0.9, 0.9 1.1, 1.1 1.1, 1.1 0.9, 0.9 0.9)) > > i.e. a rectangle from x = 0.9 to 1.1 and y from 0.9 to 1.1. > > > Ian Thomas > > > > > On 12 November 2015 at 03:47, Al Niessner wrote: > > I have three paths that each define a bounding box. Lets just > say I have > these three in (x,y) coordinates and all are moveto, lineto, > lineto, > lineto, and closepoly: > > 1: (0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1), (0, 0) > 2: (.9, 0), (2, 0), (2, 1.1), (.9, 1.1), (.9, 0) > 3: (.9, .9), (2, .9), (2, 2), (.9, 2) (.9, .9) > > While my paths have more nodes and are not as cleanly vertical > and > horizontal, it does cover the nature of what I am > experiencing. > > The first thing to note is that each box has overlap at x = 1 > and y = 1 > and all three boxes overlap at (1,1). > > What I am looking for is an optimizer that would be smart > enough to say > hey, because of the overlap, we can trim the boxes to: > > 1: (0,0) (1,0) (1,1) (0,1) (0,0) > 2: (1,0) (2,0) (2,1), (1,1), (1,0) > 3: (1,1) (2,1) (2,2), (1,2), (1,1) > > I am not sure that optimizer is the right word to use either. > I have > poked around matplotlib a bit (over many years) and tried > searching but > guessing the search terms is not simple either. Hence, I am > asking if > anyone is aware of matplotlib functionality that will help me > do this > task. Any other tool outside of matplotlib would be just as > nice of a > suggestion. One last bit, it has to work for N paths. > > As always, thanks in advance. > > -- > Al Niessner > > I have never found the companion that was so companionable as > solitude. > - From Walden by Henry David Thoreau > > The universe is indifferent, and life is brutal; however, it > is man's > choice of behavior that makes them malevolent rather than > benevolent. > > Some will fall in love with life and drink it from a fountain > That is pouring like an avalanche coming down the mountain. > - From the song Pepper by the Butthole Surfers > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers From ben.v.root at gmail.com Fri Nov 13 11:17:54 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Fri, 13 Nov 2015 11:17:54 -0500 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: <564456DC.6080709@libecciu.ch> References: <5643427A.8020302@libecciu.ch> <564456DC.6080709@libecciu.ch> Message-ID: Remo, I certainly do consider this a bug, however, it is one of those rare situations where we just can't seem to figure out how to fix it. We have made attempts before and it has had some limited success, particularly in the colorbar situation which goes through similar code paths in AGG. I would certainly love to see it get totally fixed, as it is an unsightly wart in the library. I think the main problem is that there aren't enough people who are experts in the AGG library that could either tell us what we are doing wrong in using AGG, or recognize the problem and propose a patch that would fix the problem in AGG (assuming that the problem is even located there). For all we know, the problem could be in our path-handling code. As it stands right now, the core devs probably just simply have too much on their plate to hunt this particular one down at this time. If someone else can figure this problem out, we would accept the patch in a heartbeat. Ben Root On Thu, Nov 12, 2015 at 4:07 AM, Remo Goetschi wrote: > Hi, > > Thanks for your response. Hm, are you saying there is probably no way to > work around this? > Are there other opinions? > > Personally, I consider this a bug (or two bugs, since pcolormesh() has a > problem as well). It looks really ugly if you, e.g., use > semi-transparent plots as map overlays. > > Cheers, > Remo > > > On 11.11.2015 15:53, Jens Nielsen wrote: > > The issue you are seeing is slightly different from the one the docs > > mention. > > I wrote the docs suggesting the work around and this is mainly relevant > > for vector backends (PDF and so on) The problem with PDF viewers is that > > many of them create visible gaps when two polygons are rendered next to > > each other with zero overlap. This is a viewer specific thing but lots > > of viewers suffers from this. > > This effect is much more visible that the one you see. I think the one > > you see is due to the way the edge between the 2 colours is antialiased > > by the render. > > > > The work around with adding edges is only a workaround exactly as you > > remarked because it doesn't work well with non transparent surfaces. > > > > best > > Jens > > > > On Wed, 11 Nov 2015 at 13:44 Remo Goetschi > > wrote: > > > > Hi, > > > > Does somebody know how to produce a good-looking filled contour plot > > with semi-transparent colors? If contourf() is passed a colormap with > > semi-transparent colors, it produces small gaps between the filled > > areas: > > http://i.stack.imgur.com/eEQXI.png > > > > According to the docs, this is not a bug ("contourf() [...] does not > > draw the polygon edges"). To draw the edges, it is suggested to "add > > line contours with calls to contour()". But that doesn't look good > > either as the edges become too opaque: > > http://i.stack.imgur.com/s17F9.png > > You can play with the linewidth argument of contour(), but that > doesn't > > help much. Any ideas? > > > > The code that reproduces the problem is attached below (I use the > > object-oriented API, but the result is the same with pyplot). > > > > BTW, pcolormesh() suffers from a similar problem: > > http://i.stack.imgur.com/Gbwcb.png > > > > Both problems do not seem to occur with the SVG backend. > > > > I asked the same question already on stackoverflow. Feel free to > respond > > there: > > > http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors > > > > Thanks, > > Remo > > > > --------- > > import matplotlib > > import numpy as np > > from matplotlib.figure import Figure > > from matplotlib.backends.backend_agg import FigureCanvasAgg > > > > # generate some data > > shape = (100, 100) > > x_rng = np.linspace(-1, 1, shape[1]) > > y_rng = np.linspace(-1, 1, shape[0]) > > x, y = np.meshgrid(x_rng, y_rng) > > z = np.sqrt(x**2 + y**2) > > > > # create figure > > width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 > > fig = Figure() > > fig.set_size_inches((width_inch, height_inch)) > > FigureCanvasAgg(fig) > > ax = fig.add_axes([0., 0., 1., 1.]) > > ax.set_axis_off() > > > > # define some colors with alpha < 1 > > alpha = 0.9 > > colors = [ > > (0.1, 0.1, 0.5, alpha), # dark blue > > (0.0, 0.7, 0.3, alpha), # green > > (0.9, 0.2, 0.7, alpha), # pink > > (0.0, 0.0, 0.0, alpha), # black > > (0.1, 0.7, 0.7, alpha), # light blue > > ] > > cmap = matplotlib.colors.ListedColormap(colors) > > levels = np.array(np.linspace(0, z.max(), len(colors))) > > norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) > > > > # contourf plot produces small gaps between filled areas > > cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, > > antialiased=True, linecolor='none') > > > > # this fills the gaps, but it makes them too opaque > > # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, > > # antialiased=True) > > > > # the same is true for this trick: > > # for c in cnt.collections: > > # c.set_edgecolor("face") > > > > filename = "/tmp/contourf.png" > > fig.savefig(filename, dpi=100, transparent=True, format="png") > > print("Saved plot to {}.".format(filename)) > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Fri Nov 13 13:08:30 2015 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 13 Nov 2015 08:08:30 -1000 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: <5643427A.8020302@libecciu.ch> References: <5643427A.8020302@libecciu.ch> Message-ID: <5646271E.7080900@hawaii.edu> On 2015/11/11 3:28 AM, Remo Goetschi wrote: > Hi, > > Does somebody know how to produce a good-looking filled contour plot > with semi-transparent colors? If contourf() is passed a colormap with > semi-transparent colors, it produces small gaps between the filled areas: > http://i.stack.imgur.com/eEQXI.png There are potentially two problems, depending on whether anti-aliasing is on. Without anti-aliasing, the fundamental problem is how pixels are filled in adjacent patches with a common boundary specified as floating point. This should be solvable, but it might be down in the darkest corners of agg. With anti-aliasing, I think the problem is inherent and has no solution, thought there might be ways its visual effect could be reduced in common cases. The problem here is that antialiasing fuzzes the boundary by fading out pixels depending on how much of the pixel is outside a patch. With alpha not equal to one, this means that the background, and anything plotted earlier, shows through. Therefore the end result depends on the background color, and will in general not be just a blend of the two colors of the adjacent patches, which is what one intended. It can be darker or lighter, etc. I think that in other filled contour implementations (Matlab, Ferret) the problems we see in mpl with some renderers even with no transparency and no antialiasing are absent because they build a stack of superimposed filled regions instead of adjacent regions. We could provide an option to do this. Eric > > According to the docs, this is not a bug ("contourf() [...] does not > draw the polygon edges"). To draw the edges, it is suggested to "add > line contours with calls to contour()". But that doesn't look good > either as the edges become too opaque: > http://i.stack.imgur.com/s17F9.png > You can play with the linewidth argument of contour(), but that doesn't > help much. Any ideas? > > The code that reproduces the problem is attached below (I use the > object-oriented API, but the result is the same with pyplot). > > BTW, pcolormesh() suffers from a similar problem: > http://i.stack.imgur.com/Gbwcb.png > > Both problems do not seem to occur with the SVG backend. > > I asked the same question already on stackoverflow. Feel free to respond > there: > http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors > > Thanks, > Remo > > --------- > import matplotlib > import numpy as np > from matplotlib.figure import Figure > from matplotlib.backends.backend_agg import FigureCanvasAgg > > # generate some data > shape = (100, 100) > x_rng = np.linspace(-1, 1, shape[1]) > y_rng = np.linspace(-1, 1, shape[0]) > x, y = np.meshgrid(x_rng, y_rng) > z = np.sqrt(x**2 + y**2) > > # create figure > width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 > fig = Figure() > fig.set_size_inches((width_inch, height_inch)) > FigureCanvasAgg(fig) > ax = fig.add_axes([0., 0., 1., 1.]) > ax.set_axis_off() > > # define some colors with alpha < 1 > alpha = 0.9 > colors = [ > (0.1, 0.1, 0.5, alpha), # dark blue > (0.0, 0.7, 0.3, alpha), # green > (0.9, 0.2, 0.7, alpha), # pink > (0.0, 0.0, 0.0, alpha), # black > (0.1, 0.7, 0.7, alpha), # light blue > ] > cmap = matplotlib.colors.ListedColormap(colors) > levels = np.array(np.linspace(0, z.max(), len(colors))) > norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) > > # contourf plot produces small gaps between filled areas > cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, > antialiased=True, linecolor='none') > > # this fills the gaps, but it makes them too opaque > # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, > # antialiased=True) > > # the same is true for this trick: > # for c in cnt.collections: > # c.set_edgecolor("face") > > filename = "/tmp/contourf.png" > fig.savefig(filename, dpi=100, transparent=True, format="png") > print("Saved plot to {}.".format(filename)) > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From warren.weckesser at gmail.com Fri Nov 13 16:42:52 2015 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Fri, 13 Nov 2015 16:42:52 -0500 Subject: [Matplotlib-users] Generating animated PNG files with numpngw Message-ID: Matplotlib users, I just put the package "numpngw" up on pypi: https://pypi.python.org/pypi/numpngw The development version is on github: https://github.com/WarrenWeckesser/numpngw The reason this might be of interest to maplotlib users is the class "numpngw.AnimatedPNGWriter". This class can be used as the "writer" argument of the "save" method of the Animation class. So if you've ever wanted to use matplotlib to create an animated PNG (and who hasn't?), now you can! If you go to the github page, scroll down to Example 8 to see an example of how to save an animation as an animated PNG. You'll need a browser that supports animated PNG to actually see the animation. Firefox does, Safari doesn't, and I haven't checked any others. If you use it and find problems or have suggestions for improvements, email me or create an issue on github. Warren -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Mon Nov 16 05:55:02 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 16 Nov 2015 10:55:02 +0000 Subject: [Matplotlib-users] Beginner questions about OO interface Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> Hi I am new to Matplotlib and am struggling a bit to differentiate between the OO and pyplot interfaces. I'm actually working with the Kivy GUI framework and trying to plot 4 subplots on a single figure, to be displayed by Kivy. Here's a snippet of my code: def create_plot(self): self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = plt.subplots(nrows=2, ncols=2) self.ax0.set_title("A") self.ax0.grid(True, lw = 2, ls = '--', c = '.75') self.ax1.set_title("B") self.ax1.grid(True, lw = 2, ls = '--', c = '.75') self.ax2.set_title("C") self.ax2.grid(True, lw = 2, ls = '--', c = '.75') self.ax3.set_title("D") self.ax3.grid(True, lw = 2, ls = '--', c = '.75') #plt.tight_layout() plt.show() canvas = self.fig.canvas self.add_widget(canvas) What worries me is that I am calling plt methods and assigning the results to my objects. Is plt the state machine interface and not the OO interface, or is this OK? Secondly, I want to periodically update the plotted lines, so I have a plot method that does this: def plot(self, xCoords, yCoords): if len(self.ax0.lines) > 0: self.ax0.lines.pop(0) line = self.ax0.plot(xCoords, yCoords, color='blue') canvas = self.fig.canvas canvas.draw() Does that look ok? Can I just pop the existing line, or should I reuse the existing line? Lastly, and most difficult, if I enable: plt.tight_layout() I get an exception: C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer warnings.warn("tight_layout : falling back to Agg renderer") Traceback (most recent call last): File "main.py", line 1117, in GuiApp().run() File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 801, in run self.load_kv(filename=self.kv_file) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 598, in load_kv root = Builder.load_file(rfilename) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1801, in load_file return self.load_string(data, **kwargs) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1880, in load_string self._apply_rule(widget, parser.root, parser.root) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2037, in _apply_rule self.apply(child) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1924, in apply self._apply_rule(widget, rule, rule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2035, in _apply_rule child = cls(__no_builder=True) File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, in __init__ self.create_plot() File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, in create_plot self.add_widget(canvas) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", line 211, in add_widget widget.bind( AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' Can anyone help with that please? Best regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon Nov 16 12:23:12 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 16 Nov 2015 12:23:12 -0500 Subject: [Matplotlib-users] Beginner questions about OO interface In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> Message-ID: Hello David, On Mon, Nov 16, 2015 at 5:55 AM, David Aldrich wrote: > Hi > > > > I am new to Matplotlib and am struggling a bit to differentiate between > the OO and pyplot interfaces. I?m actually working with the Kivy GUI > framework and trying to plot 4 subplots on a single figure, to be displayed > by Kivy. Here?s a snippet of my code: > > > > def create_plot(self): > > > > self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = > plt.subplots(nrows=2, ncols=2) > > > > self.ax0.set_title("A") > > self.ax0.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax1.set_title("B") > > self.ax1.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax2.set_title("C") > > self.ax2.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax3.set_title("D") > > self.ax3.grid(True, lw = 2, ls = '--', c = '.75') > > > > #plt.tight_layout() > > plt.show() > > > > canvas = self.fig.canvas > > self.add_widget(canvas) > > > > What worries me is that I am calling plt methods and assigning the results > to my objects. Is plt the state machine interface and not the OO > interface, or is this OK? > > Indeed, plt is the state machine interface, and it isn't exactly the same thing to say "plt.show()" and to show a particular figure. You can call `self.fig.show()`, though. > > > Secondly, I want to periodically update the plotted lines, so I have a > plot method that does this: > > > > def plot(self, xCoords, yCoords): > > > > if len(self.ax0.lines) > 0: > > self.ax0.lines.pop(0) > > > > line = self.ax0.plot(xCoords, yCoords, color='blue') > > > > canvas = self.fig.canvas > > canvas.draw() > > > > Does that look ok? Can I just pop the existing line, or should I reuse > the existing line? > That would work, but it is very inefficient. Most matplotlib artist objects have some sort of "set_data()" or "set_offsets()" method that would let you update the data contained in the artist. See the following animation example: http://matplotlib.org/examples/animation/animate_decay.html > > > Lastly, and most difficult, if I enable: > > > > plt.tight_layout() > > > > I get an exception: > > > > C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: > UserWarning: tight_layout : falling back to Agg renderer > > warnings.warn("tight_layout : falling back to Agg renderer") > > Traceback (most recent call last): > > File "main.py", line 1117, in > > GuiApp().run() > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", > line 801, in run > > self.load_kv(filename=self.kv_file) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", > line 598, in load_kv > > root = Builder.load_file(rfilename) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1801, in load_file > > return self.load_string(data, **kwargs) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1880, in load_string > > self._apply_rule(widget, parser.root, parser.root) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2037, in _apply_rule > > self.apply(child) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1924, in apply > > self._apply_rule(widget, rule, rule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2035, in _apply_rule > > child = cls(__no_builder=True) > > File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, in > __init__ > > self.create_plot() > > File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, in > create_plot > > self.add_widget(canvas) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", > line 211, in add_widget > > widget.bind( > > AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' > > > > Can anyone help with that please? > > tight_layout() isn't the issue here (well, directly). The issue is that the canvas object that you added as a widget is not a widget as far as Kivy is concerned. It doesn't subclass anything that Kivy recognizes as a widget. By its very nature, FigureCanvasAgg is completely independent of any GUI frameworks. You would need to have selected the appropriate backend for matplotlib to use prior to importing pyplot (I don't know which one Kivy is compatible with, GTK? QT? something else?). By the way, chapter 5 of my book, "Interactive Applications Using Matplotlib" goes into detail explaining the ins and outs of GUI embedding with matplotlib. While I don't cover Kivy, I do a Rosetta Stone-like explanation covering GTK, Qt4, Wx, and Tk, and I explain the general concepts. Perhaps it might be useful? http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ Cheers! Ben Root > > > Best regards > > > > David > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Nov 16 12:33:19 2015 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 16 Nov 2015 17:33:19 +0000 Subject: [Matplotlib-users] Beginner questions about OO interface In-Reply-To: References: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> Message-ID: There is on-going work to write a mpl backend for kivy: https://github.com/kivy-garden/garden.matplotlib On Mon, Nov 16, 2015 at 12:23 PM Benjamin Root wrote: > Hello David, > > On Mon, Nov 16, 2015 at 5:55 AM, David Aldrich > wrote: > >> Hi >> >> >> >> I am new to Matplotlib and am struggling a bit to differentiate between >> the OO and pyplot interfaces. I?m actually working with the Kivy GUI >> framework and trying to plot 4 subplots on a single figure, to be displayed >> by Kivy. Here?s a snippet of my code: >> >> >> >> def create_plot(self): >> >> >> >> self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = >> plt.subplots(nrows=2, ncols=2) >> >> >> >> self.ax0.set_title("A") >> >> self.ax0.grid(True, lw = 2, ls = '--', c = '.75') >> >> >> >> self.ax1.set_title("B") >> >> self.ax1.grid(True, lw = 2, ls = '--', c = '.75') >> >> >> >> self.ax2.set_title("C") >> >> self.ax2.grid(True, lw = 2, ls = '--', c = '.75') >> >> >> >> self.ax3.set_title("D") >> >> self.ax3.grid(True, lw = 2, ls = '--', c = '.75') >> >> >> >> #plt.tight_layout() >> >> plt.show() >> >> >> >> canvas = self.fig.canvas >> >> self.add_widget(canvas) >> >> >> >> What worries me is that I am calling plt methods and assigning the >> results to my objects. Is plt the state machine interface and not the OO >> interface, or is this OK? >> >> > Indeed, plt is the state machine interface, and it isn't exactly the same > thing to say "plt.show()" and to show a particular figure. You can call > `self.fig.show()`, though. > > >> >> >> Secondly, I want to periodically update the plotted lines, so I have a >> plot method that does this: >> >> >> >> def plot(self, xCoords, yCoords): >> >> >> >> if len(self.ax0.lines) > 0: >> >> self.ax0.lines.pop(0) >> >> >> >> line = self.ax0.plot(xCoords, yCoords, color='blue') >> >> >> >> canvas = self.fig.canvas >> >> canvas.draw() >> >> >> >> Does that look ok? Can I just pop the existing line, or should I reuse >> the existing line? >> > > That would work, but it is very inefficient. Most matplotlib artist > objects have some sort of "set_data()" or "set_offsets()" method that would > let you update the data contained in the artist. See the following > animation example: > http://matplotlib.org/examples/animation/animate_decay.html > > >> >> >> Lastly, and most difficult, if I enable: >> >> >> >> plt.tight_layout() >> >> >> >> I get an exception: >> >> >> >> C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: >> UserWarning: tight_layout : falling back to Agg renderer >> >> warnings.warn("tight_layout : falling back to Agg renderer") >> >> Traceback (most recent call last): >> >> File "main.py", line 1117, in >> >> GuiApp().run() >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", >> line 801, in run >> >> self.load_kv(filename=self.kv_file) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", >> line 598, in load_kv >> >> root = Builder.load_file(rfilename) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 1801, in load_file >> >> return self.load_string(data, **kwargs) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 1880, in load_string >> >> self._apply_rule(widget, parser.root, parser.root) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 2038, in _apply_rule >> >> self._apply_rule(child, crule, rootrule) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 2037, in _apply_rule >> >> self.apply(child) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 1924, in apply >> >> self._apply_rule(widget, rule, rule) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 2038, in _apply_rule >> >> self._apply_rule(child, crule, rootrule) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 2038, in _apply_rule >> >> self._apply_rule(child, crule, rootrule) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", >> line 2035, in _apply_rule >> >> child = cls(__no_builder=True) >> >> File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, >> in __init__ >> >> self.create_plot() >> >> File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, >> in create_plot >> >> self.add_widget(canvas) >> >> File >> "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", >> line 211, in add_widget >> >> widget.bind( >> >> AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' >> >> >> >> Can anyone help with that please? >> >> > > tight_layout() isn't the issue here (well, directly). The issue is that > the canvas object that you added as a widget is not a widget as far as Kivy > is concerned. It doesn't subclass anything that Kivy recognizes as a > widget. By its very nature, FigureCanvasAgg is completely independent of > any GUI frameworks. You would need to have selected the appropriate backend > for matplotlib to use prior to importing pyplot (I don't know which one > Kivy is compatible with, GTK? QT? something else?). > > By the way, chapter 5 of my book, "Interactive Applications Using > Matplotlib" goes into detail explaining the ins and outs of GUI embedding > with matplotlib. While I don't cover Kivy, I do a Rosetta Stone-like > explanation covering GTK, Qt4, Wx, and Tk, and I explain the general > concepts. Perhaps it might be useful? > > > http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ > > Cheers! > Ben Root > > > >> >> >> Best regards >> >> >> >> David >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon Nov 16 12:42:11 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 16 Nov 2015 12:42:11 -0500 Subject: [Matplotlib-users] Beginner questions about OO interface In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B9FF825@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> <41302A7145AC054FA7A96CFD03835A0A0B9FF825@EX10MBX02.EU.NEC.COM> Message-ID: David, I should point out that Sandro's book is fairly old and that there is a new one that replaces it: "Mastering Matplotlib". Note that neither book really goes into any details about embedding figures into GUIs. Ben On Mon, Nov 16, 2015 at 12:37 PM, David Aldrich wrote: > Hi Benjamin > > > > Thanks for your reply. I have looked at your book on Amazon but thought I > should go for Sandro Tosi?s book initially, just to learn the basics of > Matplotlib. Perhaps I can get yours later J > > > > Best regards > > > > David > > > > *From:* Benjamin Root [mailto:ben.v.root at gmail.com] > *Sent:* 16 November 2015 17:23 > *To:* David Aldrich > *Cc:* matplotlib-users at python.org > *Subject:* Re: [Matplotlib-users] Beginner questions about OO interface > > > > Hello David, > > > > On Mon, Nov 16, 2015 at 5:55 AM, David Aldrich > wrote: > > Hi > > > > I am new to Matplotlib and am struggling a bit to differentiate between > the OO and pyplot interfaces. I?m actually working with the Kivy GUI > framework and trying to plot 4 subplots on a single figure, to be displayed > by Kivy. Here?s a snippet of my code: > > > > def create_plot(self): > > > > self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = > plt.subplots(nrows=2, ncols=2) > > > > self.ax0.set_title("A") > > self.ax0.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax1.set_title("B") > > self.ax1.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax2.set_title("C") > > self.ax2.grid(True, lw = 2, ls = '--', c = '.75') > > > > self.ax3.set_title("D") > > self.ax3.grid(True, lw = 2, ls = '--', c = '.75') > > > > #plt.tight_layout() > > plt.show() > > > > canvas = self.fig.canvas > > self.add_widget(canvas) > > > > What worries me is that I am calling plt methods and assigning the results > to my objects. Is plt the state machine interface and not the OO > interface, or is this OK? > > > > Indeed, plt is the state machine interface, and it isn't exactly the same > thing to say "plt.show()" and to show a particular figure. You can call > `self.fig.show()`, though. > > > > > > Secondly, I want to periodically update the plotted lines, so I have a > plot method that does this: > > > > def plot(self, xCoords, yCoords): > > > > if len(self.ax0.lines) > 0: > > self.ax0.lines.pop(0) > > > > line = self.ax0.plot(xCoords, yCoords, color='blue') > > > > canvas = self.fig.canvas > > canvas.draw() > > > > Does that look ok? Can I just pop the existing line, or should I reuse > the existing line? > > > > That would work, but it is very inefficient. Most matplotlib artist > objects have some sort of "set_data()" or "set_offsets()" method that would > let you update the data contained in the artist. See the following > animation example: > http://matplotlib.org/examples/animation/animate_decay.html > > > > > > Lastly, and most difficult, if I enable: > > > > plt.tight_layout() > > > > I get an exception: > > > > C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: > UserWarning: tight_layout : falling back to Agg renderer > > warnings.warn("tight_layout : falling back to Agg renderer") > > Traceback (most recent call last): > > File "main.py", line 1117, in > > GuiApp().run() > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", > line 801, in run > > self.load_kv(filename=self.kv_file) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", > line 598, in load_kv > > root = Builder.load_file(rfilename) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1801, in load_file > > return self.load_string(data, **kwargs) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1880, in load_string > > self._apply_rule(widget, parser.root, parser.root) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2037, in _apply_rule > > self.apply(child) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 1924, in apply > > self._apply_rule(widget, rule, rule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2038, in _apply_rule > > self._apply_rule(child, crule, rootrule) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", > line 2035, in _apply_rule > > child = cls(__no_builder=True) > > File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, in > __init__ > > self.create_plot() > > File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, in > create_plot > > self.add_widget(canvas) > > File > "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", > line 211, in add_widget > > widget.bind( > > AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' > > > > Can anyone help with that please? > > > > tight_layout() isn't the issue here (well, directly). The issue is that > the canvas object that you added as a widget is not a widget as far as Kivy > is concerned. It doesn't subclass anything that Kivy recognizes as a > widget. By its very nature, FigureCanvasAgg is completely independent of > any GUI frameworks. You would need to have selected the appropriate backend > for matplotlib to use prior to importing pyplot (I don't know which one > Kivy is compatible with, GTK? QT? something else?). > > By the way, chapter 5 of my book, "Interactive Applications Using > Matplotlib" goes into detail explaining the ins and outs of GUI embedding > with matplotlib. While I don't cover Kivy, I do a Rosetta Stone-like > explanation covering GTK, Qt4, Wx, and Tk, and I explain the general > concepts. Perhaps it might be useful? > > > http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ > > Cheers! > > Ben Root > > > > > > > Best regards > > > > David > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > > Click here > > to report this email as spam. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From warren.weckesser at gmail.com Mon Nov 16 16:00:05 2015 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Mon, 16 Nov 2015 16:00:05 -0500 Subject: [Matplotlib-users] Generating animated PNG files with numpngw In-Reply-To: References: Message-ID: On Fri, Nov 13, 2015 at 5:13 PM, Sterling Smith wrote: > I needed an apng viewer plug-in for Chrome > > https://chrome.google.com/webstore/detail/apng/ehkepjiconegkhpodgoaeamnpckdbblp?hl=en > > -Sterling > > Sterling, thanks for trying it out, and for pointing out the animated PNG plugin for Chrome. Warren P.S. I changed the mailing list group from the old sourceforge list to matplotlib-users at python.org. I sent my first email to the sourceforge list because that's what showed up first when I searched for "matplotlib-users mailing list". > On Nov 13, 2015, at 1:31PM, Warren Weckesser > wrote: > > > Matplotlib users, > > > > I just put the package "numpngw" up on pypi: > https://pypi.python.org/pypi/numpngw > > The development version is on github: > https://github.com/WarrenWeckesser/numpngw > > > > The reason this might be of interest to maplotlib users is the class > "numpngw.AnimatedPNGWriter". This class can be used as the "writer" > argument of the "save" method of the Animation class. So if you've ever > wanted to use matplotlib to create an animated PNG (and who hasn't?), now > you can! > > > > If you go to the github page, scroll down to Example 8 to see an example > of how to save an animation as an animated PNG. You'll need a browser that > supports animated PNG to actually see the animation. Firefox does, Safari > doesn't, and I haven't checked any others. > > > > If you use it and find problems or have suggestions for improvements, > email me or create an issue on github. > > > > Warren > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From surf at libecciu.ch Tue Nov 17 03:13:25 2015 From: surf at libecciu.ch (Remo Goetschi) Date: Tue, 17 Nov 2015 09:13:25 +0100 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: <5646271E.7080900@hawaii.edu> References: <5643427A.8020302@libecciu.ch> <5646271E.7080900@hawaii.edu> Message-ID: <564AE1A5.2060800@libecciu.ch> Hi Eric and Ben Thanks a lot for your elaborations on this problem. I am a non-expert in both agg and matplotlib development. On the other hand, this issue is a serious problem for us and we have some motivation to solve it. On 13.11.2015 19:08, Eric Firing wrote: > I think that in other filled contour implementations (Matlab, Ferret) > the problems we see in mpl with some renderers even with no > transparency and no antialiasing are absent because they build a > stack of superimposed filled regions instead of adjacent regions. We > could provide an option to do this. To me, that sounds like a reasonable solution. What's a good way to start? Open an issue on github? Cheers, Remo On 13.11.2015 19:08, Eric Firing wrote: > On 2015/11/11 3:28 AM, Remo Goetschi wrote: >> Hi, >> >> Does somebody know how to produce a good-looking filled contour plot >> with semi-transparent colors? If contourf() is passed a colormap with >> semi-transparent colors, it produces small gaps between the filled areas: >> http://i.stack.imgur.com/eEQXI.png > > There are potentially two problems, depending on whether anti-aliasing > is on. > > Without anti-aliasing, the fundamental problem is how pixels are filled > in adjacent patches with a common boundary specified as floating point. > This should be solvable, but it might be down in the darkest corners of > agg. > > With anti-aliasing, I think the problem is inherent and has no solution, > thought there might be ways its visual effect could be reduced in common > cases. The problem here is that antialiasing fuzzes the boundary by > fading out pixels depending on how much of the pixel is outside a patch. > With alpha not equal to one, this means that the background, and > anything plotted earlier, shows through. Therefore the end result > depends on the background color, and will in general not be just a blend > of the two colors of the adjacent patches, which is what one intended. > It can be darker or lighter, etc. > > I think that in other filled contour implementations (Matlab, Ferret) > the problems we see in mpl with some renderers even with no transparency > and no antialiasing are absent because they build a stack of > superimposed filled regions instead of adjacent regions. We could > provide an option to do this. > > Eric > >> >> According to the docs, this is not a bug ("contourf() [...] does not >> draw the polygon edges"). To draw the edges, it is suggested to "add >> line contours with calls to contour()". But that doesn't look good >> either as the edges become too opaque: >> http://i.stack.imgur.com/s17F9.png >> You can play with the linewidth argument of contour(), but that doesn't >> help much. Any ideas? >> >> The code that reproduces the problem is attached below (I use the >> object-oriented API, but the result is the same with pyplot). >> >> BTW, pcolormesh() suffers from a similar problem: >> http://i.stack.imgur.com/Gbwcb.png >> >> Both problems do not seem to occur with the SVG backend. >> >> I asked the same question already on stackoverflow. Feel free to respond >> there: >> http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors >> >> >> Thanks, >> Remo >> >> --------- >> import matplotlib >> import numpy as np >> from matplotlib.figure import Figure >> from matplotlib.backends.backend_agg import FigureCanvasAgg >> >> # generate some data >> shape = (100, 100) >> x_rng = np.linspace(-1, 1, shape[1]) >> y_rng = np.linspace(-1, 1, shape[0]) >> x, y = np.meshgrid(x_rng, y_rng) >> z = np.sqrt(x**2 + y**2) >> >> # create figure >> width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 >> fig = Figure() >> fig.set_size_inches((width_inch, height_inch)) >> FigureCanvasAgg(fig) >> ax = fig.add_axes([0., 0., 1., 1.]) >> ax.set_axis_off() >> >> # define some colors with alpha < 1 >> alpha = 0.9 >> colors = [ >> (0.1, 0.1, 0.5, alpha), # dark blue >> (0.0, 0.7, 0.3, alpha), # green >> (0.9, 0.2, 0.7, alpha), # pink >> (0.0, 0.0, 0.0, alpha), # black >> (0.1, 0.7, 0.7, alpha), # light blue >> ] >> cmap = matplotlib.colors.ListedColormap(colors) >> levels = np.array(np.linspace(0, z.max(), len(colors))) >> norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) >> >> # contourf plot produces small gaps between filled areas >> cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, >> antialiased=True, linecolor='none') >> >> # this fills the gaps, but it makes them too opaque >> # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, >> # antialiased=True) >> >> # the same is true for this trick: >> # for c in cnt.collections: >> # c.set_edgecolor("face") >> >> filename = "/tmp/contourf.png" >> fig.savefig(filename, dpi=100, transparent=True, format="png") >> print("Saved plot to {}.".format(filename)) >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From efiring at hawaii.edu Tue Nov 17 11:45:36 2015 From: efiring at hawaii.edu (Eric Firing) Date: Tue, 17 Nov 2015 06:45:36 -1000 Subject: [Matplotlib-users] contourf looking ugly with transparent colors In-Reply-To: <564AE1A5.2060800@libecciu.ch> References: <5643427A.8020302@libecciu.ch> <5646271E.7080900@hawaii.edu> <564AE1A5.2060800@libecciu.ch> Message-ID: <564B59B0.9080704@hawaii.edu> On 2015/11/16 10:13 PM, Remo Goetschi wrote: > Hi Eric and Ben > > Thanks a lot for your elaborations on this problem. I am a non-expert in > both agg and matplotlib development. On the other hand, this issue is a > serious problem for us and we have some motivation to solve it. > > On 13.11.2015 19:08, Eric Firing wrote: >> I think that in other filled contour implementations (Matlab, Ferret) >> the problems we see in mpl with some renderers even with no >> transparency and no antialiasing are absent because they build a >> stack of superimposed filled regions instead of adjacent regions. We >> could provide an option to do this. > To me, that sounds like a reasonable solution. > > What's a good way to start? Open an issue on github? You could open a "wishlist" issue, referring to this email thread, requesting the stacking option above. I don't think it would be difficult to implement, but I might be missing something. However...I'm not sure it would do what you want in the case of *transparent* colors. If you stack transparent colors, what you get is a blend with everything underneath. Is this what you want? Can you supply examples of the desired result, produced by some other plotting software? Eric > > Cheers, > Remo > > > On 13.11.2015 19:08, Eric Firing wrote: >> On 2015/11/11 3:28 AM, Remo Goetschi wrote: >>> Hi, >>> >>> Does somebody know how to produce a good-looking filled contour plot >>> with semi-transparent colors? If contourf() is passed a colormap with >>> semi-transparent colors, it produces small gaps between the filled areas: >>> http://i.stack.imgur.com/eEQXI.png >> >> There are potentially two problems, depending on whether anti-aliasing >> is on. >> >> Without anti-aliasing, the fundamental problem is how pixels are filled >> in adjacent patches with a common boundary specified as floating point. >> This should be solvable, but it might be down in the darkest corners of >> agg. >> >> With anti-aliasing, I think the problem is inherent and has no solution, >> thought there might be ways its visual effect could be reduced in common >> cases. The problem here is that antialiasing fuzzes the boundary by >> fading out pixels depending on how much of the pixel is outside a patch. >> With alpha not equal to one, this means that the background, and >> anything plotted earlier, shows through. Therefore the end result >> depends on the background color, and will in general not be just a blend >> of the two colors of the adjacent patches, which is what one intended. >> It can be darker or lighter, etc. >> >> I think that in other filled contour implementations (Matlab, Ferret) >> the problems we see in mpl with some renderers even with no transparency >> and no antialiasing are absent because they build a stack of >> superimposed filled regions instead of adjacent regions. We could >> provide an option to do this. >> >> Eric >> >>> >>> According to the docs, this is not a bug ("contourf() [...] does not >>> draw the polygon edges"). To draw the edges, it is suggested to "add >>> line contours with calls to contour()". But that doesn't look good >>> either as the edges become too opaque: >>> http://i.stack.imgur.com/s17F9.png >>> You can play with the linewidth argument of contour(), but that doesn't >>> help much. Any ideas? >>> >>> The code that reproduces the problem is attached below (I use the >>> object-oriented API, but the result is the same with pyplot). >>> >>> BTW, pcolormesh() suffers from a similar problem: >>> http://i.stack.imgur.com/Gbwcb.png >>> >>> Both problems do not seem to occur with the SVG backend. >>> >>> I asked the same question already on stackoverflow. Feel free to respond >>> there: >>> http://stackoverflow.com/questions/33547926/matplotlib-filled-contour-plot-with-transparent-colors >>> >>> >>> Thanks, >>> Remo >>> >>> --------- >>> import matplotlib >>> import numpy as np >>> from matplotlib.figure import Figure >>> from matplotlib.backends.backend_agg import FigureCanvasAgg >>> >>> # generate some data >>> shape = (100, 100) >>> x_rng = np.linspace(-1, 1, shape[1]) >>> y_rng = np.linspace(-1, 1, shape[0]) >>> x, y = np.meshgrid(x_rng, y_rng) >>> z = np.sqrt(x**2 + y**2) >>> >>> # create figure >>> width_inch, height_inch = 5, 5 # results in 500x500px with dpi=100 >>> fig = Figure() >>> fig.set_size_inches((width_inch, height_inch)) >>> FigureCanvasAgg(fig) >>> ax = fig.add_axes([0., 0., 1., 1.]) >>> ax.set_axis_off() >>> >>> # define some colors with alpha < 1 >>> alpha = 0.9 >>> colors = [ >>> (0.1, 0.1, 0.5, alpha), # dark blue >>> (0.0, 0.7, 0.3, alpha), # green >>> (0.9, 0.2, 0.7, alpha), # pink >>> (0.0, 0.0, 0.0, alpha), # black >>> (0.1, 0.7, 0.7, alpha), # light blue >>> ] >>> cmap = matplotlib.colors.ListedColormap(colors) >>> levels = np.array(np.linspace(0, z.max(), len(colors))) >>> norm = matplotlib.colors.BoundaryNorm(levels, ncolors=cmap.N) >>> >>> # contourf plot produces small gaps between filled areas >>> cnt = ax.contourf(x, y, z, levels, cmap=cmap, norm=norm, >>> antialiased=True, linecolor='none') >>> >>> # this fills the gaps, but it makes them too opaque >>> # ax.contour(x, y, z, levels, cmap=cmap, norm=norm, >>> # antialiased=True) >>> >>> # the same is true for this trick: >>> # for c in cnt.collections: >>> # c.set_edgecolor("face") >>> >>> filename = "/tmp/contourf.png" >>> fig.savefig(filename, dpi=100, transparent=True, format="png") >>> print("Saved plot to {}.".format(filename)) >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From christine.e.smit at nasa.gov Tue Nov 17 17:22:28 2015 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Tue, 17 Nov 2015 22:22:28 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation Message-ID: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 (64-bit). What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I expect to see one pixel per data point, but that's not what I'm seeing. Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob in the middle of the correct one pixel diagonal. --------------------------------------------------------------------------- import numpy as np import matplotlib.pylab as plt if __name__ == "__main__": n = 7 data = np.identity(n, float) # Create an nxn size figure with no frame fig = plt.figure(figsize=(n, n), frameon=False) # make the axes to the edge of the figure ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) # turn the axes off ax.set_axis_off() # add the axes to this figure fig.add_axes(ax) # show the data. Don't do any interpolation. ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') # Save the figure at 1 dot per inch, which should mean 1 data point per # pixel fig.savefig("image.png", dpi=1) --------------------------------------------------------------------------- Since I'm not sure that if I can attach the png image I get, here is a ppm version of the image I get (between the ------). Save this image.ppm minus the dashes and you should be able to open it in something like gimp. --------------------------------------------------------------------------- P3 # CREATOR: GIMP PNM Filter Version 1.1 7 7 255 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 --------------------------------------------------------------------------- Thanks. Christine -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan12343 at gmail.com Tue Nov 17 17:38:10 2015 From: nathan12343 at gmail.com (Nathan Goldbaum) Date: Tue, 17 Nov 2015 16:38:10 -0600 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: This seems to be working ok for me: https://gist.github.com/faa6b4008a8e3db68f46 On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: > Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 > (64-bit). > > What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I > expect to see one pixel per data point, but that's not what I'm seeing. > Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob > in the middle of the correct one pixel diagonal. > > --------------------------------------------------------------------------- > import numpy as np > import matplotlib.pylab as plt > > > if __name__ == "__main__": > n = 7 > data = np.identity(n, float) > > # Create an nxn size figure with no frame > fig = plt.figure(figsize=(n, n), frameon=False) > > # make the axes to the edge of the figure > ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) > # turn the axes off > ax.set_axis_off() > # add the axes to this figure > fig.add_axes(ax) > # show the data. Don't do any interpolation. > ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') > # Save the figure at 1 dot per inch, which should mean 1 data point per > # pixel > fig.savefig("image.png", dpi=1) > > --------------------------------------------------------------------------- > > Since I'm not sure that if I can attach the png image I get, here is a ppm > version of the image I get (between the ------). Save this image.ppm minus > the dashes and you should be able to open it in something like gimp. > > --------------------------------------------------------------------------- > P3 > # CREATOR: GIMP PNM Filter Version 1.1 > 7 7 > 255 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > --------------------------------------------------------------------------- > > Thanks. > Christine > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jenshnielsen at gmail.com Wed Nov 18 06:28:21 2015 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Wed, 18 Nov 2015 11:28:21 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: I can confirm this. The issue is notable with a dpi lower than 10 or so and seems to get worse as it is lowered towards 1. Can you try plotting the image with interpolation='none' If I do that I get the correct behaviour. 'none' is probably the correct setting if you wish to match image matrix 1to1 to png coords anyway. @nathan The image in the notebook is plotted with a different dpi and works correctly. best Jens On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum wrote: > This seems to be working ok for me: > https://gist.github.com/faa6b4008a8e3db68f46 > > On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE > CORP] wrote: > >> Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 >> (64-bit). >> >> What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I >> expect to see one pixel per data point, but that's not what I'm seeing. >> Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob >> in the middle of the correct one pixel diagonal. >> >> >> --------------------------------------------------------------------------- >> import numpy as np >> import matplotlib.pylab as plt >> >> >> if __name__ == "__main__": >> n = 7 >> data = np.identity(n, float) >> >> # Create an nxn size figure with no frame >> fig = plt.figure(figsize=(n, n), frameon=False) >> >> # make the axes to the edge of the figure >> ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) >> # turn the axes off >> ax.set_axis_off() >> # add the axes to this figure >> fig.add_axes(ax) >> # show the data. Don't do any interpolation. >> ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') >> # Save the figure at 1 dot per inch, which should mean 1 data point >> per >> # pixel >> fig.savefig("image.png", dpi=1) >> >> >> --------------------------------------------------------------------------- >> >> Since I'm not sure that if I can attach the png image I get, here is a >> ppm version of the image I get (between the ------). Save this image.ppm >> minus the dashes and you should be able to open it in something like gimp. >> >> >> --------------------------------------------------------------------------- >> P3 >> # CREATOR: GIMP PNM Filter Version 1.1 >> 7 7 >> 255 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> >> --------------------------------------------------------------------------- >> >> Thanks. >> Christine >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christine.e.smit at nasa.gov Wed Nov 18 18:08:03 2015 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Wed, 18 Nov 2015 23:08:03 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: Yes. It works with 'none.' The problem is that sometimes we need to create images with low inflation factors. So, our data is nxm data points and we want a 2nx2m image or a 3nx3m image. We're currently getting around this bug by using 'none' to create an nxm image and then using imagemagick's convert to resize. From: Jens Nielsen > Date: Wednesday, November 18, 2015 at 6:28 AM To: Nathan Goldbaum >, csmit > Cc: "matplotlib-users at python.org" > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation I can confirm this. The issue is notable with a dpi lower than 10 or so and seems to get worse as it is lowered towards 1. Can you try plotting the image with interpolation='none' If I do that I get the correct behaviour. 'none' is probably the correct setting if you wish to match image matrix 1to1 to png coords anyway. @nathan The image in the notebook is plotted with a different dpi and works correctly. best Jens On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum > wrote: This seems to be working ok for me: https://gist.github.com/faa6b4008a8e3db68f46 On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 (64-bit). What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I expect to see one pixel per data point, but that's not what I'm seeing. Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob in the middle of the correct one pixel diagonal. --------------------------------------------------------------------------- import numpy as np import matplotlib.pylab as plt if __name__ == "__main__": n = 7 data = np.identity(n, float) # Create an nxn size figure with no frame fig = plt.figure(figsize=(n, n), frameon=False) # make the axes to the edge of the figure ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) # turn the axes off ax.set_axis_off() # add the axes to this figure fig.add_axes(ax) # show the data. Don't do any interpolation. ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') # Save the figure at 1 dot per inch, which should mean 1 data point per # pixel fig.savefig("image.png", dpi=1) --------------------------------------------------------------------------- Since I'm not sure that if I can attach the png image I get, here is a ppm version of the image I get (between the ------). Save this image.ppm minus the dashes and you should be able to open it in something like gimp. --------------------------------------------------------------------------- P3 # CREATOR: GIMP PNM Filter Version 1.1 7 7 255 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 --------------------------------------------------------------------------- Thanks. Christine _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From jenshnielsen at gmail.com Thu Nov 19 09:34:48 2015 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Thu, 19 Nov 2015 14:34:48 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: It seem like this is a genuine bug but I am not sure how to fix it. Can you submit a bug report at Github so we are sure that this is captured? At github you can attach pictures Best Jens On Thu, 19 Nov 2015 at 14:25 Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: > Yes. It works with 'none.' The problem is that sometimes we need to create > images with low inflation factors. So, our data is nxm data points and we > want a 2nx2m image or a 3nx3m image. We're currently getting around this > bug by using 'none' to create an nxm image and then using imagemagick's > convert to resize. > > From: Jens Nielsen > Date: Wednesday, November 18, 2015 at 6:28 AM > To: Nathan Goldbaum , csmit < > christine.e.smit at nasa.gov> > Cc: "matplotlib-users at python.org" > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation > > I can confirm this. The issue is notable with a dpi lower than 10 or so > and seems to get worse as it is lowered towards 1. > Can you try plotting the image with interpolation='none' If I do that I > get the correct behaviour. 'none' is probably the correct setting if you > wish to match > image matrix 1to1 to png coords anyway. > > @nathan The image in the notebook is plotted with a different dpi and > works correctly. > > best Jens > > On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum > wrote: > >> This seems to be working ok for me: >> https://gist.github.com/faa6b4008a8e3db68f46 >> >> On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. >> (GSFC-610.2)[TELOPHASE CORP] wrote: >> >>> Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 >>> (64-bit). >>> >>> What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I >>> expect to see one pixel per data point, but that's not what I'm seeing. >>> Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob >>> in the middle of the correct one pixel diagonal. >>> >>> >>> --------------------------------------------------------------------------- >>> import numpy as np >>> import matplotlib.pylab as plt >>> >>> >>> if __name__ == "__main__": >>> n = 7 >>> data = np.identity(n, float) >>> >>> # Create an nxn size figure with no frame >>> fig = plt.figure(figsize=(n, n), frameon=False) >>> >>> # make the axes to the edge of the figure >>> ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) >>> # turn the axes off >>> ax.set_axis_off() >>> # add the axes to this figure >>> fig.add_axes(ax) >>> # show the data. Don't do any interpolation. >>> ax.imshow(data, interpolation='nearest', >>> origin='lower',aspect='auto') >>> # Save the figure at 1 dot per inch, which should mean 1 data point >>> per >>> # pixel >>> fig.savefig("image.png", dpi=1) >>> >>> >>> --------------------------------------------------------------------------- >>> >>> Since I'm not sure that if I can attach the png image I get, here is a >>> ppm version of the image I get (between the ------). Save this image.ppm >>> minus the dashes and you should be able to open it in something like gimp. >>> >>> >>> --------------------------------------------------------------------------- >>> P3 >>> # CREATOR: GIMP PNM Filter Version 1.1 >>> 7 7 >>> 255 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 127 >>> 0 >>> 0 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> 0 >>> 0 >>> 127 >>> >>> --------------------------------------------------------------------------- >>> >>> Thanks. >>> Christine >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >>> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christine.e.smit at nasa.gov Thu Nov 19 09:25:03 2015 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Thu, 19 Nov 2015 14:25:03 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: Yes. It works with 'none.' The problem is that sometimes we need to create images with low inflation factors. So, our data is nxm data points and we want a 2nx2m image or a 3nx3m image. We're currently getting around this bug by using 'none' to create an nxm image and then using imagemagick's convert to resize. From: Jens Nielsen > Date: Wednesday, November 18, 2015 at 6:28 AM To: Nathan Goldbaum >, csmit > Cc: "matplotlib-users at python.org" > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation I can confirm this. The issue is notable with a dpi lower than 10 or so and seems to get worse as it is lowered towards 1. Can you try plotting the image with interpolation='none' If I do that I get the correct behaviour. 'none' is probably the correct setting if you wish to match image matrix 1to1 to png coords anyway. @nathan The image in the notebook is plotted with a different dpi and works correctly. best Jens On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum > wrote: This seems to be working ok for me: https://gist.github.com/faa6b4008a8e3db68f46 On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 (64-bit). What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I expect to see one pixel per data point, but that's not what I'm seeing. Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob in the middle of the correct one pixel diagonal. --------------------------------------------------------------------------- import numpy as np import matplotlib.pylab as plt if __name__ == "__main__": n = 7 data = np.identity(n, float) # Create an nxn size figure with no frame fig = plt.figure(figsize=(n, n), frameon=False) # make the axes to the edge of the figure ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) # turn the axes off ax.set_axis_off() # add the axes to this figure fig.add_axes(ax) # show the data. Don't do any interpolation. ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') # Save the figure at 1 dot per inch, which should mean 1 data point per # pixel fig.savefig("image.png", dpi=1) --------------------------------------------------------------------------- Since I'm not sure that if I can attach the png image I get, here is a ppm version of the image I get (between the ------). Save this image.ppm minus the dashes and you should be able to open it in something like gimp. --------------------------------------------------------------------------- P3 # CREATOR: GIMP PNM Filter Version 1.1 7 7 255 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 --------------------------------------------------------------------------- Thanks. Christine _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From christine.e.smit at nasa.gov Thu Nov 19 14:38:35 2015 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Thu, 19 Nov 2015 19:38:35 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: Thanks! I have. https://github.com/matplotlib/matplotlib/issues/5520 From: Jens Nielsen > Date: Thursday, November 19, 2015 at 9:34 AM To: csmit >, Nathan Goldbaum > Cc: "matplotlib-users at python.org" > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation It seem like this is a genuine bug but I am not sure how to fix it. Can you submit a bug report at Github so we are sure that this is captured? At github you can attach pictures Best Jens On Thu, 19 Nov 2015 at 14:25 Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: Yes. It works with 'none.' The problem is that sometimes we need to create images with low inflation factors. So, our data is nxm data points and we want a 2nx2m image or a 3nx3m image. We're currently getting around this bug by using 'none' to create an nxm image and then using imagemagick's convert to resize. From: Jens Nielsen > Date: Wednesday, November 18, 2015 at 6:28 AM To: Nathan Goldbaum >, csmit > Cc: "matplotlib-users at python.org" > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation I can confirm this. The issue is notable with a dpi lower than 10 or so and seems to get worse as it is lowered towards 1. Can you try plotting the image with interpolation='none' If I do that I get the correct behaviour. 'none' is probably the correct setting if you wish to match image matrix 1to1 to png coords anyway. @nathan The image in the notebook is plotted with a different dpi and works correctly. best Jens On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum > wrote: This seems to be working ok for me: https://gist.github.com/faa6b4008a8e3db68f46 On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 (64-bit). What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I expect to see one pixel per data point, but that's not what I'm seeing. Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob in the middle of the correct one pixel diagonal. --------------------------------------------------------------------------- import numpy as np import matplotlib.pylab as plt if __name__ == "__main__": n = 7 data = np.identity(n, float) # Create an nxn size figure with no frame fig = plt.figure(figsize=(n, n), frameon=False) # make the axes to the edge of the figure ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) # turn the axes off ax.set_axis_off() # add the axes to this figure fig.add_axes(ax) # show the data. Don't do any interpolation. ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') # Save the figure at 1 dot per inch, which should mean 1 data point per # pixel fig.savefig("image.png", dpi=1) --------------------------------------------------------------------------- Since I'm not sure that if I can attach the png image I get, here is a ppm version of the image I get (between the ------). Save this image.ppm minus the dashes and you should be able to open it in something like gimp. --------------------------------------------------------------------------- P3 # CREATOR: GIMP PNM Filter Version 1.1 7 7 255 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 127 0 0 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 0 0 127 --------------------------------------------------------------------------- Thanks. Christine _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From warren.weckesser at gmail.com Thu Nov 19 15:26:18 2015 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Thu, 19 Nov 2015 15:26:18 -0500 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: On 11/19/15, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: > Thanks! I have. https://github.com/matplotlib/matplotlib/issues/5520 > FYI: If you want to write a numpy array directly to a PNG file, you can use numpngw: * github: https://github.com/WarrenWeckesser/numpngw * pypi: https://pypi.python.org/pypi/numpngw/ Warren (Christine, sorry for the double email. I forgot to "reply all".) > From: Jens Nielsen > > Date: Thursday, November 19, 2015 at 9:34 AM > To: csmit >, > Nathan Goldbaum > > Cc: "matplotlib-users at python.org" > > > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation > > It seem like this is a genuine bug but I am not sure how to fix it. Can you > submit a bug report at Github so we are sure that this is captured? At > github you can attach pictures > > Best Jens > > > On Thu, 19 Nov 2015 at 14:25 Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > > wrote: > Yes. It works with 'none.' The problem is that sometimes we need to create > images with low inflation factors. So, our data is nxm data points and we > want a 2nx2m image or a 3nx3m image. We're currently getting around this bug > by using 'none' to create an nxm image and then using imagemagick's convert > to resize. > > From: Jens Nielsen > > Date: Wednesday, November 18, 2015 at 6:28 AM > To: Nathan Goldbaum >, > csmit > > Cc: "matplotlib-users at python.org" > > > Subject: Re: [Matplotlib-users] odd behavior with 'nearest' interpolation > > I can confirm this. The issue is notable with a dpi lower than 10 or so and > seems to get worse as it is lowered towards 1. > Can you try plotting the image with interpolation='none' If I do that I get > the correct behaviour. 'none' is probably the correct setting if you wish to > match > image matrix 1to1 to png coords anyway. > > @nathan The image in the notebook is plotted with a different dpi and works > correctly. > > best Jens > > On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum > > wrote: > This seems to be working ok for me: > https://gist.github.com/faa6b4008a8e3db68f46 > > On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. (GSFC-610.2)[TELOPHASE > CORP] > wrote: > Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 > (64-bit). > > What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I > expect to see one pixel per data point, but that's not what I'm seeing. > Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel blob > in the middle of the correct one pixel diagonal. > > --------------------------------------------------------------------------- > import numpy as np > import matplotlib.pylab as plt > > > if __name__ == "__main__": > n = 7 > data = np.identity(n, float) > > # Create an nxn size figure with no frame > fig = plt.figure(figsize=(n, n), frameon=False) > > # make the axes to the edge of the figure > ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) > # turn the axes off > ax.set_axis_off() > # add the axes to this figure > fig.add_axes(ax) > # show the data. Don't do any interpolation. > ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto') > # Save the figure at 1 dot per inch, which should mean 1 data point per > # pixel > fig.savefig("image.png", dpi=1) > > --------------------------------------------------------------------------- > > Since I'm not sure that if I can attach the png image I get, here is a ppm > version of the image I get (between the ------). Save this image.ppm minus > the dashes and you should be able to open it in something like gimp. > > --------------------------------------------------------------------------- > P3 > # CREATOR: GIMP PNM Filter Version 1.1 > 7 7 > 255 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 127 > 0 > 0 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > 0 > 0 > 127 > --------------------------------------------------------------------------- > > Thanks. > Christine > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From christine.e.smit at nasa.gov Thu Nov 19 16:47:10 2015 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Thu, 19 Nov 2015 21:47:10 +0000 Subject: [Matplotlib-users] odd behavior with 'nearest' interpolation In-Reply-To: References: <4FD09EDB6251A44E94C60207D5A0B2670CADC8B0@NDMSMBX403.ndc.nasa.gov> Message-ID: That looks interesting. It's definitely what we are currently trying to do. Thank you for mentioning it. On 11/19/15, 3:26 PM, "Warren Weckesser" wrote: >On 11/19/15, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: >> Thanks! I have. https://github.com/matplotlib/matplotlib/issues/5520 >> > > >FYI: If you want to write a numpy array directly to a PNG file, you >can use numpngw: > >* github: https://github.com/WarrenWeckesser/numpngw >* pypi: https://pypi.python.org/pypi/numpngw/ > > >Warren > >(Christine, sorry for the double email. I forgot to "reply all".) > >> From: Jens Nielsen >>> >> Date: Thursday, November 19, 2015 at 9:34 AM >> To: csmit >, >> Nathan Goldbaum > >> Cc: "matplotlib-users at python.org" >> > >> Subject: Re: [Matplotlib-users] odd behavior with 'nearest' >>interpolation >> >> It seem like this is a genuine bug but I am not sure how to fix it. Can >>you >> submit a bug report at Github so we are sure that this is captured? At >> github you can attach pictures >> >> Best Jens >> >> >> On Thu, 19 Nov 2015 at 14:25 Smit, Christine E. (GSFC-610.2)[TELOPHASE >>CORP] >> > wrote: >> Yes. It works with 'none.' The problem is that sometimes we need to >>create >> images with low inflation factors. So, our data is nxm data points and >>we >> want a 2nx2m image or a 3nx3m image. We're currently getting around >>this bug >> by using 'none' to create an nxm image and then using imagemagick's >>convert >> to resize. >> >> From: Jens Nielsen >>> >> Date: Wednesday, November 18, 2015 at 6:28 AM >> To: Nathan Goldbaum >>>, >> csmit > >> Cc: "matplotlib-users at python.org" >> > >> Subject: Re: [Matplotlib-users] odd behavior with 'nearest' >>interpolation >> >> I can confirm this. The issue is notable with a dpi lower than 10 or so >>and >> seems to get worse as it is lowered towards 1. >> Can you try plotting the image with interpolation='none' If I do that I >>get >> the correct behaviour. 'none' is probably the correct setting if you >>wish to >> match >> image matrix 1to1 to png coords anyway. >> >> @nathan The image in the notebook is plotted with a different dpi and >>works >> correctly. >> >> best Jens >> >> On Tue, 17 Nov 2015 at 22:38 Nathan Goldbaum >> > wrote: >> This seems to be working ok for me: >> https://gist.github.com/faa6b4008a8e3db68f46 >> >> On Tue, Nov 17, 2015 at 4:22 PM, Smit, Christine E. >>(GSFC-610.2)[TELOPHASE >> CORP] > >>wrote: >> Hi! I am using matplotlib v 1.4.3 with Python 2.7.10 :: Anaconda 2.4.0 >> (64-bit). >> >> What I am doing here is creating a 7x7 pixel image from a 7x7 matrix. I >> expect to see one pixel per data point, but that's not what I'm seeing. >> Instead of a diagonal make up of single pixels, I get an odd 2x2 pixel >>blob >> in the middle of the correct one pixel diagonal. >> >> >>------------------------------------------------------------------------- >>-- >> import numpy as np >> import matplotlib.pylab as plt >> >> >> if __name__ == "__main__": >> n = 7 >> data = np.identity(n, float) >> >> # Create an nxn size figure with no frame >> fig = plt.figure(figsize=(n, n), frameon=False) >> >> # make the axes to the edge of the figure >> ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0]) >> # turn the axes off >> ax.set_axis_off() >> # add the axes to this figure >> fig.add_axes(ax) >> # show the data. Don't do any interpolation. >> ax.imshow(data, interpolation='nearest', >>origin='lower',aspect='auto') >> # Save the figure at 1 dot per inch, which should mean 1 data point >>per >> # pixel >> fig.savefig("image.png", dpi=1) >> >> >>------------------------------------------------------------------------- >>-- >> >> Since I'm not sure that if I can attach the png image I get, here is a >>ppm >> version of the image I get (between the ------). Save this image.ppm >>minus >> the dashes and you should be able to open it in something like gimp. >> >> >>------------------------------------------------------------------------- >>-- >> P3 >> # CREATOR: GIMP PNM Filter Version 1.1 >> 7 7 >> 255 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 127 >> 0 >> 0 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> 0 >> 0 >> 127 >> >>------------------------------------------------------------------------- >>-- >> >> Thanks. >> Christine >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> From alain.muls at gmail.com Mon Nov 23 06:16:24 2015 From: alain.muls at gmail.com (Alain Muls) Date: Mon, 23 Nov 2015 12:16:24 +0100 Subject: [Matplotlib-users] pyplot problem between 62bit and 32bit system Message-ID: Hi I have a problem with a script that fails on my 64bit system, but runs well on a 32bit system. I get a core dump at import matplotlib.pyplot as plt ... ... fig = plt.figure(figsize=(20.0, 16.0)) (core dump) Any ideas? Tx/Alain *Please take note of new phone number since 1 April 2015* ------------------------------ *Alain Muls* *alain.muls at rma.ac.be * Royal Military Academy - Department CISS Phone +32 2 441 39 36 Renaissance Avenue 30 B1000 Brussels (Belgium) http://www.rma.ac.be/ciss/ http://www.sic.rma.ac.be/ ------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmhobson at gmail.com Mon Nov 23 10:18:59 2015 From: pmhobson at gmail.com (Paul Hobson) Date: Mon, 23 Nov 2015 07:18:59 -0800 Subject: [Matplotlib-users] pyplot problem between 62bit and 32bit system In-Reply-To: References: Message-ID: How did you install python, matplotlib, and matplotlib's dependencies? What operating system? Which python interpreter? I use matplotlib all day on 64-bit Linux, Mac OS X, and Windows system w/o core dumps. On Mon, Nov 23, 2015 at 3:16 AM, Alain Muls wrote: > Hi > > I have a problem with a script that fails on my 64bit system, but runs > well on a 32bit system. > I get a core dump at > > import matplotlib.pyplot as plt > ... > ... > fig = plt.figure(figsize=(20.0, 16.0)) > (core dump) > > Any ideas? > > Tx/Alain > > *Please take note of new phone number since 1 April 2015* > ------------------------------ > *Alain Muls* *alain.muls at rma.ac.be * Royal Military > Academy - Department CISS Phone +32 2 441 39 36 Renaissance Avenue 30 > B1000 Brussels (Belgium) > > http://www.rma.ac.be/ciss/ > http://www.sic.rma.ac.be/ > ------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Nov 23 21:06:41 2015 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 24 Nov 2015 02:06:41 +0000 Subject: [Matplotlib-users] =?utf-8?q?Two_circles_with_=E2=80=9Cexponentia?= =?utf-8?q?l_decay=E2=80=9D_coloring=2C_and_alpha_=3C_1=2C_having_t?= =?utf-8?q?rouble_with_color_mixing=3F?= In-Reply-To: References: <07D7BEBE-EA04-466A-ACF3-FE18F820EB03@fusion.gat.com> Message-ID: Please keep all emails on-list. I am actually not sure this is possible. The problem is even if the background is transparent, the first image is still composited on to it first, thus the bottom value still comes in with alpha ** 2 when the second layer is added. Why are you trying to do this? You might be a better to add your data into one image and then use shapely to compute the union of the paths for clipping. Tom On Mon, Nov 23, 2015 at 8:07 PM Brian Merchant wrote: > Hi Thomas, > > Ah, so should I somehow set the background to be transparent? Put another > way, how would I remove the influence of the background on the compositing? > > On Mon, Nov 23, 2015 at 2:41 PM, Thomas Caswell > wrote: > >> The way we do the alpha blending, the output value is (alpha * v1) + >> ((alpha-1) * v2). All of the artists are compsited down on top of a white >> background so the compositing is not commutative. >> >> (a * .5) + (.5 * (b * .5 + .5)) =/= (b * .5) + (.5 * (a * .5 + .5)) >> >> >> On Mon, Nov 23, 2015 at 1:55 PM Sterling Smith >> wrote: >> >>> Maybe the issue is with the colormap not having an alpha? Does this >>> >>> http://stackoverflow.com/questions/10127284/overlay-imshow-plots-in-matplotlib >>> help? >>> >>> Otherwise, you might file a bug at >>> https://github.com/matplotlib/matplotlib/issues/new >>> >>> -Sterling >>> >>> On Nov 20, 2015, at 4:46PM, Brian Merchant wrote: >>> >>> > Hi all, >>> > >>> > In order to get circles such that their coloring is radially >>> symmetric, with center being the darkest, and exponential decay in color as >>> one moves farther away from the center along the radius, I used imshow with >>> clip_path using Circle patches. >>> > >>> > Here's a toy script that overlaps two such circles: >>> https://gist.github.com/bmer/7063cc2dd09f1b80a252 >>> > >>> > As you can see if you run the script (or, if you follow this link: >>> http://i.imgur.com/H9jEAZ3.png), even though the alpha is set at 0.5, >>> there doesn't seem to be proper "color mixing" occurring (we should see a >>> result that is symmetric along the x-axis). >>> > >>> > Why is that, and what could I do to fix this issue? >>> > >>> > Kind regards, >>> > Brian >>> > >>> ------------------------------------------------------------------------------ >>> > _______________________________________________ >>> > Matplotlib-users mailing list >>> > Matplotlib-users at lists.sourceforge.net >>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Go from Idea to Many App Stores Faster with Intel(R) XDK >>> Give your users amazing mobile app experiences with Intel(R) XDK. >>> Use one codebase in this all-in-one HTML5 development environment. >>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple >>> OSs. >>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140 >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alain.muls at gmail.com Tue Nov 24 14:57:19 2015 From: alain.muls at gmail.com (Alain Muls) Date: Tue, 24 Nov 2015 20:57:19 +0100 Subject: [Matplotlib-users] Matplotlib-users Digest, Vol 4, Issue 20 In-Reply-To: References: Message-ID: Hi Paul, I use virtualenv installed as 'user'. For this project I have the following packages installed on both 64 and 32 bit systems. (pyEphem) [513] [amuls at gnssfield: /home/amuls/amPython/pyEphem]$ pip freeze cycler==0.9.0 matplotlib==1.5.0 numpy==1.10.1 pyephem==3.7.6.0 pyparsing==2.0.5 PySide==1.2.4 python-dateutil==2.4.2 pytz==2015.7 requests==2.8.1 six==1.10.0 wheel==0.24.0 Everything is OK on 32bit Ubuntu 14.04 while the core dump occurs on the 64 bit Ubuntu 14.04 I changed the matplotlib on 64 bit system to 1.4.3 and now I do not have a problem, but the 1.5 matplotlib causes the error. Tx/ALain *Please take note of new phone number since 1 April 2015* ------------------------------ *Alain Muls* *alain.muls at rma.ac.be * Royal Military Academy - Department CISS Phone +32 2 441 39 36 Renaissance Avenue 30 B1000 Brussels (Belgium) http://www.rma.ac.be/ciss/ http://www.sic.rma.ac.be/ ------------------------------ On 23 November 2015 at 18:00, wrote: > Send Matplotlib-users mailing list submissions to > matplotlib-users at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/matplotlib-users > or, via email, send a message with subject or body 'help' to > matplotlib-users-request at python.org > > You can reach the person managing the list at > matplotlib-users-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Matplotlib-users digest..." > > > Today's Topics: > > 1. pyplot problem between 62bit and 32bit system (Alain Muls) > 2. Re: pyplot problem between 62bit and 32bit system (Paul Hobson) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 23 Nov 2015 12:16:24 +0100 > From: Alain Muls > To: matplotlib-users at python.org > Subject: [Matplotlib-users] pyplot problem between 62bit and 32bit > system > Message-ID: > hnTPi-u_jg at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hi > > I have a problem with a script that fails on my 64bit system, but runs > well on a 32bit system. > I get a core dump at > > import matplotlib.pyplot as plt > ... > ... > fig = plt.figure(figsize=(20.0, 16.0)) > (core dump) > > Any ideas? > > Tx/Alain > > *Please take note of new phone number since 1 April 2015* > ------------------------------ > *Alain Muls* *alain.muls at rma.ac.be * Royal Military > Academy - Department CISS Phone +32 2 441 39 36 Renaissance Avenue 30 > B1000 Brussels (Belgium) > > http://www.rma.ac.be/ciss/ > http://www.sic.rma.ac.be/ > ------------------------------ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/matplotlib-users/attachments/20151123/e98fd0cd/attachment-0001.html > > > > ------------------------------ > > Message: 2 > Date: Mon, 23 Nov 2015 07:18:59 -0800 > From: Paul Hobson > To: Alain Muls > Cc: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] pyplot problem between 62bit and 32bit > system > Message-ID: > < > CADT3MEAbMus7CFcQggA1X18WM_PjgMdEKrwLcJW7a9LOy8HhJg at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > How did you install python, matplotlib, and matplotlib's dependencies? What > operating system? Which python interpreter? > > I use matplotlib all day on 64-bit Linux, Mac OS X, and Windows system w/o > core dumps. > > On Mon, Nov 23, 2015 at 3:16 AM, Alain Muls wrote: > > > Hi > > > > I have a problem with a script that fails on my 64bit system, but runs > > well on a 32bit system. > > I get a core dump at > > > > import matplotlib.pyplot as plt > > ... > > ... > > fig = plt.figure(figsize=(20.0, 16.0)) > > (core dump) > > > > Any ideas? > > > > Tx/Alain > > > > *Please take note of new phone number since 1 April 2015* > > ------------------------------ > > *Alain Muls* *alain.muls at rma.ac.be * Royal > Military > > Academy - Department CISS Phone +32 2 441 39 36 Renaissance Avenue 30 > > B1000 Brussels (Belgium) > > > > http://www.rma.ac.be/ciss/ > > http://www.sic.rma.ac.be/ > > ------------------------------ > > > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/matplotlib-users/attachments/20151123/c7020db3/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ------------------------------ > > End of Matplotlib-users Digest, Vol 4, Issue 20 > *********************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anshul6 at yahoo.com Sun Nov 29 16:26:36 2015 From: anshul6 at yahoo.com (anshul6) Date: Sun, 29 Nov 2015 14:26:36 -0700 (MST) Subject: [Matplotlib-users] Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) Message-ID: <1448832396233-46477.post@n5.nabble.com> Hello, I just installed "Anaconda3 for Windows v2.4.0" on my Windows 10 Home (64 bit) machine. (Downloaded the Windows 64-bit Graphical Installer "Anaconda3-2.4.0-Windows-x86_64.exe" (392 MB) from https://www.continuum.io/downloads) In a Command Prompt window, I did the conda "Test Drive", including "conda update conda", etc, and in the end see the following: The installation seems to have been successful: However, I get an error message when I try to import "matplotlib.pyplot" as below (note that matplotlib appears to be imported fine): I opened "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py" in a text editor and tried to look for the source of the error. I think this is where things are going wrong: But I'm at a loss as to why this is happening, and how to rectify it. Please help. Thanks, Anshul -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Error-on-import-matplotlib-pyplot-on-Anaconda3-for-Windows-10-Home-64-bit-PC-tp46477.html Sent from the matplotlib - users mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fchabouis at gmail.com Mon Nov 30 12:46:32 2015 From: fchabouis at gmail.com (Francis Chabouis) Date: Mon, 30 Nov 2015 18:46:32 +0100 Subject: [Matplotlib-users] exporting tricontour function results Message-ID: Hello, I'm having some difficulties with the results of the tricontour function. What I'm trying to achieve is fairly simple : I'd like to export the results of the tricontour function as a geoJson. (I think a function doing exactly this job would be nice to have in the library). I wrote this : cs = plt.tricontourf(t, v, levels) for i,collection in enumerate(cs.collections): for path in collection.get_paths(): Now I have this path object. My first problem : when I check the number of vertices (via len(path.vertices)) I get 732 vertices. If I try to access those vertices with iter_segments as recommended in the doc, I get only 125 vertices. seg = path.iter_segments() print len(list(seg)) ==> 125 Am I doing something wrong, or is it possibly a bug ? My second problem : geoJson works with interior and exterior rings. To describe a polygon with a hole in it, we first declare a closed line (that will be the exterior) and all the subsequent lines will be the "holes" (interiors). It seems that what I get from iter_segments and to_polygons is a bunch of lines, but there is no way to know which is an interior, which is an exterior. But I guess this must be stored somewhere as MPL is able to draw a graph from this information ! Any hints on how I should proceed ? Let me know if you need additional information. Thanks ps : I got some of my infos from this thread : http://matplotlib.1069221.n5.nabble.com/Structure-of-contour-object-returned-from-tricontourf-td44203.html ps2 : If I can write this function I would be happy to integrate it in the lib if you're interested. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon Nov 30 13:37:26 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 30 Nov 2015 13:37:26 -0500 Subject: [Matplotlib-users] exporting tricontour function results In-Reply-To: References: Message-ID: Francis, I bet you that the inconsistency in the number of vertexes is due to path simplification. The list of Path objects you get when you call get_paths() on the collection object each have an attribute "should_simplify" and that defaults to True. Set it to False, and you will have all of the vertexes. Also, what you want to call is to_polygons() on the Path object after setting "should_simplify" to False. That will return a list of lists. The first element of that list is the external vertexes, and the rest of the elements are all vertex lists of the internal holes. I hope this description helps. I can't really give you more detailed description due to the fact that I have developed software that does this very thing for my employer, but what you want is certainly possible. Also, as for whether or not we would want a geojson export function available for matplotlib, it isn't really correct to have it in matplotlib because we are a graphing library. However, it would make sense to make the process of extracting the polygon information a bit easier, which would make it easier for another package to be made that would export that information into various data formats, not just geojson. Cheers! Ben Root On Mon, Nov 30, 2015 at 12:46 PM, Francis Chabouis wrote: > Hello, > I'm having some difficulties with the results of the tricontour function. > What I'm trying to achieve is fairly simple : I'd like to export the > results of the tricontour function as a geoJson. (I think a function doing > exactly this job would be nice to have in the library). > > I wrote this : > > cs = plt.tricontourf(t, v, levels) > > for i,collection in enumerate(cs.collections): > for path in collection.get_paths(): > > > Now I have this path object. > > My first problem : when I check the number of vertices (via > len(path.vertices)) I get 732 vertices. > If I try to access those vertices with iter_segments as recommended in the > doc, I get only 125 vertices. > seg = path.iter_segments() > print len(list(seg)) > ==> 125 > > Am I doing something wrong, or is it possibly a bug ? > > My second problem : geoJson works with interior and exterior rings. To > describe a polygon with a hole in it, we first declare a closed line (that > will be the exterior) and all the subsequent lines will be the "holes" > (interiors). It seems that what I get from iter_segments and to_polygons is > a bunch of lines, but there is no way to know which is an interior, which > is an exterior. But I guess this must be stored somewhere as MPL is able to > draw a graph from this information ! > > Any hints on how I should proceed ? > Let me know if you need additional information. > > Thanks > > ps : I got some of my infos from this thread : > http://matplotlib.1069221.n5.nabble.com/Structure-of-contour-object-returned-from-tricontourf-td44203.html > > ps2 : If I can write this function I would be happy to integrate it in the > lib if you're interested. > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon Nov 30 13:56:31 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 30 Nov 2015 13:56:31 -0500 Subject: [Matplotlib-users] Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) In-Reply-To: <1448832396233-46477.post@n5.nabble.com> References: <1448832396233-46477.post@n5.nabble.com> Message-ID: Sigh, this is mostly a py3k/Windows issue, I think (a long-standing one). We have been seeing some strange issues in Windows where users who have certain Unicode characters in their username and something unusual about their filesystem (I don't recall what it is, specifically). Those characters end up messing up various parts of the standard library and return incorrect results or raise exceptions like these. I do remember that there was a discussion thread about a year or two ago that really went into detail about why this was happening, and that there was nothing we could do from within the library. Perhaps someone remembers what thread that was? Ben Root On Sun, Nov 29, 2015 at 4:26 PM, anshul6 via Matplotlib-users < matplotlib-users at python.org> wrote: > Hello, > > I just installed "Anaconda3 for Windows v2.4.0" on my Windows 10 Home (64 > bit) machine. > > (Downloaded the Windows 64-bit Graphical Installer > "Anaconda3-2.4.0-Windows-x86_64.exe" (392 MB) from > https://www.continuum.io/downloads) > > In a Command Prompt window, I did the conda "Test Drive", including "conda > update conda", etc, and in the end see the following: > > C:\Users\Anshul\Downloads\Python>conda update conda > Fetching package metadata: .... > # All requested packages already installed. > # packages in environment at C:\Anaconda3: > # > conda 3.18.6 py35_0 defaults > > C:\Users\Anshul\Downloads\Python>conda list matplotlib > # packages in environment at C:\Anaconda3: > # > matplotlib 1.5.0 np110py35_0 defaults > > > The installation seems to have been successful: > > C:\Users\Anshul\Downloads\Python>python > Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Nov 7 2015, 13:15:24) [MSC v.1900 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> print("Hello World") > Hello World > >>> import os > >>> os.getcwd() > 'C:\\Users\\Anshul\\Downloads\\Python' > >>> import matplotlib as mpl > >>> print(mpl.__version__) > 1.5.0 > >>> > > > However, I get an error message when I try to import "matplotlib.pyplot" > as below (note that matplotlib appears to be imported fine): > > >>> import matplotlib.pyplot as pp > Traceback (most recent call last): > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1412, in > fontManager = pickle_load(_fmcache) > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 963, in pickle_load > with open(filename, 'rb') as fh: > FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Anshul\\.matplotlib\\fontList.py3k.cache' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "", line 1, in > File "C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 29, in > import matplotlib.colorbar > File "C:\Anaconda3\lib\site-packages\matplotlib\colorbar.py", line 34, in > import matplotlib.collections as collections > File "C:\Anaconda3\lib\site-packages\matplotlib\collections.py", line 27, in > import matplotlib.backend_bases as backend_bases > File "C:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 62, in > import matplotlib.textpath as textpath > File "C:\Anaconda3\lib\site-packages\matplotlib\textpath.py", line 15, in > import matplotlib.font_manager as font_manager > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1420, in > _rebuild() > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1405, in _rebuild > fontManager = FontManager() > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1043, in __init__ > self.ttffiles = findSystemFonts(paths) + findSystemFonts() > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 312, in findSystemFonts > for f in win32InstalledFonts(fontdir): > File "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 231, in win32InstalledFonts > direc = os.path.abspath(direc).lower() > File "C:\Anaconda3\lib\ntpath.py", line 535, in abspath > path = _getfullpathname(path) > ValueError: _getfullpathname: embedded null character > >>> > > > I opened "C:\Anaconda3\lib\site-packages\matplotlib\font_manager.py" in a > text editor and tried to look for the source of the error. I think this is > where things are going wrong: > > >>> mpl.get_cachedir() > 'C:\\Users\\Anshul\\.matplotlib' > >>> mpl.get_configdir() > 'C:\\Users\\Anshul\\.matplotlib' > >>> > > > But I'm at a loss as to why this is happening, and how to rectify it. > Please help. > > Thanks, > Anshul > ------------------------------ > View this message in context: Error on import matplotlib.pyplot (on > Anaconda3 for Windows 10 Home 64-bit PC) > > Sent from the matplotlib - users mailing list archive > at > Nabble.com. > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anshul6 at yahoo.com Mon Nov 30 15:38:28 2015 From: anshul6 at yahoo.com (anshul6) Date: Mon, 30 Nov 2015 13:38:28 -0700 (MST) Subject: [Matplotlib-users] Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) In-Reply-To: References: <1448832396233-46477.post@n5.nabble.com> Message-ID: <1448915908211-46481.post@n5.nabble.com> Thank you Ben for the reply. Perhaps you are referring to this one reported back in 2013: fail to import matplotlib.pyplot #2320 ? It involved a WinPython-64bit-3.3.2.2 installation on a Windows 7 64 bit machine. The thread was closed with the comment: "Closing. Already fixed in master.", but I have to confess, I didn't understand the discussion that led to this conclusion. Is there a simple set of instructions on what I need to do to fix this installation issue? Thank you, Anshul -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Error-on-import-matplotlib-pyplot-on-Anaconda3-for-Windows-10-Home-64-bit-PC-tp46477p46481.html Sent from the matplotlib - users mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon Nov 30 15:56:15 2015 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 30 Nov 2015 15:56:15 -0500 Subject: [Matplotlib-users] Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) In-Reply-To: <1448915908211-46481.post@n5.nabble.com> References: <1448832396233-46477.post@n5.nabble.com> <1448915908211-46481.post@n5.nabble.com> Message-ID: No, not that one. This issue has to do with getting the home directory of the user, I think, so it was a problem with os.path.expanduser(), IIRC. On Mon, Nov 30, 2015 at 3:38 PM, anshul6 via Matplotlib-users < matplotlib-users at python.org> wrote: > Thank you Ben for the reply. > > Perhaps you are referring to this one reported back in 2013: fail to > import matplotlib.pyplot #2320 > ? It involved a > WinPython-64bit-3.3.2.2 installation on a Windows 7 64 bit machine. > > The thread was closed with the comment: "Closing. Already fixed in > master.", but I have to confess, I didn't understand the discussion that > led to this conclusion. > > Is there a simple set of instructions on what I need to do to fix this > installation issue? > > Thank you, > Anshul > ------------------------------ > View this message in context: Re: Error on import matplotlib.pyplot (on > Anaconda3 for Windows 10 Home 64-bit PC) > > > Sent from the matplotlib - users mailing list archive > at > Nabble.com. > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anshul6 at yahoo.com Mon Nov 30 17:18:18 2015 From: anshul6 at yahoo.com (anshul6) Date: Mon, 30 Nov 2015 15:18:18 -0700 (MST) Subject: [Matplotlib-users] Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) In-Reply-To: References: <1448832396233-46477.post@n5.nabble.com> <1448915908211-46481.post@n5.nabble.com> Message-ID: <1448921898096-46484.post@n5.nabble.com> BTW, the error is not limited to just "matplotlib.pyplot". I get a similar error when importing the "seaborn" library. These are the two packages that I know of so far. Hope there is one fix for all such issues. Below is my seaborn installation procedure, and the subsequent error message triggered on import. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Error-on-import-matplotlib-pyplot-on-Anaconda3-for-Windows-10-Home-64-bit-PC-tp46477p46484.html Sent from the matplotlib - users mailing list archive at Nabble.com. From tcaswell at gmail.com Mon Nov 30 20:51:20 2015 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 01 Dec 2015 01:51:20 +0000 Subject: [Matplotlib-users] does anyone use the pdf documentation? Message-ID: Hey folks, Does anyone use the pdf version of the documentation? We are thinking of not building it as part of releases going forward. Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From jblackburne at gmail.com Mon Nov 30 21:42:03 2015 From: jblackburne at gmail.com (Jeff Blackburne) Date: Mon, 30 Nov 2015 18:42:03 -0800 Subject: [Matplotlib-users] does anyone use the pdf documentation? In-Reply-To: References: Message-ID: It is convenient in airgapped environments. Though the same purpose could be served with an all-in-one html document. Would that be easier to build? -Jeff On Mon, Nov 30, 2015 at 5:51 PM, Thomas Caswell wrote: > Hey folks, > > Does anyone use the pdf version of the documentation? We are thinking of > not building it as part of releases going forward. > > Tom > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hypnus1803 at gmail.com Sat Nov 7 12:10:21 2015 From: hypnus1803 at gmail.com (Hypnus1803) Date: Sat, 07 Nov 2015 17:10:21 -0000 Subject: [Matplotlib-users] Embed LassoSelector and Quiver Message-ID: <1446915212728-46403.post@n5.nabble.com> Hello everyone, I want to know if I could embed LassoSelector function with Quiver. More precise, I want to make a mask using LassoSelector selection. Thanks. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Embed-LassoSelector-and-Quiver-tp46403.html Sent from the matplotlib - users mailing list archive at Nabble.com. From krish22526 at gmail.com Wed Nov 11 20:05:53 2015 From: krish22526 at gmail.com (pikachu) Date: Thu, 12 Nov 2015 01:05:53 -0000 Subject: [Matplotlib-users] Axis labels along y-axis Message-ID: <1447289436151-46417.post@n5.nabble.com> I would like to have the axis labels along the y-axis for this sample. How can I do it? http://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Axis-labels-along-y-axis-tp46417.html Sent from the matplotlib - users mailing list archive at Nabble.com. From David.Aldrich at EMEA.NEC.COM Fri Nov 13 07:52:19 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Fri, 13 Nov 2015 12:52:19 -0000 Subject: [Matplotlib-users] Some beginner questions Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9FE702@EX10MBX02.EU.NEC.COM> Hi I'm new to Matplotlib and am struggling a bit. I'm using Matplotlib with the Kivy GUI framework, but that shouldn't be directly relevant. I want to show a single figure having 4 subplots, each displaying one line. My code looks like this (simplified): class CMplGraph(): pass def __init__(self, **kwargs): self.create_plot() def create_plot(self): self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = plt.subplots(nrows=2, ncols=2) self.ax0.set_title("Title_0") self.ax1.set_title("Title_1") self.ax2.set_title("Title_2") self.ax3.set_title("Title_3") plt.show() def plot(self, plotType, xCoords, yCoords): if (plotType == "PLOT_0 "): ax = self.ax0 elif (plotType == " PLOT_1"): ax = self.ax1 elif (plotType == " PLOT_2"): ax = self.ax2 elif (plotType == " PLOT_3"): ax = self.ax3 else: raise BadPlotType(plotType) # remove previous line if len(ax.lines) > 0: ax.lines.pop(0) plt.draw() time.sleep(1) # Blink line = ax.plot(xCoords, yCoords, color='blue') canvas = self.fig.canvas canvas.draw() Then my main app can call create_plot() once, followed by plot() whenever it wants to update the displayed data. This seems to work but I'm not sure I'm doing it correctly. Here are my questions: 1) Is it ok that I created axis objects? 2) Am I removing the previous line correctly? 3) I would like display to 'blink' between successive calls to plot(). So I put in a 1s sleep after removing the previous line. There should therefore be a flash before the new data is displayed. But I don't see that blink - the line updates instantaneously. Why is that? Best regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: From saikari.hakala at laposte.net Fri Nov 13 09:21:04 2015 From: saikari.hakala at laposte.net (sh77) Date: Fri, 13 Nov 2015 14:21:04 -0000 Subject: [Matplotlib-users] How to center axes intersecting at (0,0) Message-ID: <1447423314772-46427.post@n5.nabble.com> Hi, I'm new to matplotlib. I would like to do something very simple. In the figure created by the following code, I would like the axes to be centered in the figure and intersecting at point (0,0): import matplotlib.pyplot as plt plt.plot([1,2,3,4], [1,-4,9,-16], 'ro') plt.axis([-6, 6, -20, 20]) plt.title('Title') plt.show() Can you please give me the simplest lines of code to achieve this? (the hints to solutions that I have seen over the internet are amazingly complex for such a simple task) Many thanks saikari -- View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-center-axes-intersecting-at-0-0-tp46427.html Sent from the matplotlib - users mailing list archive at Nabble.com. From David.Aldrich at EMEA.NEC.COM Mon Nov 16 12:37:05 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 16 Nov 2015 17:37:05 +0000 Subject: [Matplotlib-users] Beginner questions about OO interface In-Reply-To: References: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9FF825@EX10MBX02.EU.NEC.COM> Hi Benjamin Thanks for your reply. I have looked at your book on Amazon but thought I should go for Sandro Tosi?s book initially, just to learn the basics of Matplotlib. Perhaps I can get yours later ? Best regards David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 16 November 2015 17:23 To: David Aldrich Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Beginner questions about OO interface Hello David, On Mon, Nov 16, 2015 at 5:55 AM, David Aldrich > wrote: Hi I am new to Matplotlib and am struggling a bit to differentiate between the OO and pyplot interfaces. I?m actually working with the Kivy GUI framework and trying to plot 4 subplots on a single figure, to be displayed by Kivy. Here?s a snippet of my code: def create_plot(self): self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = plt.subplots(nrows=2, ncols=2) self.ax0.set_title("A") self.ax0.grid(True, lw = 2, ls = '--', c = '.75') self.ax1.set_title("B") self.ax1.grid(True, lw = 2, ls = '--', c = '.75') self.ax2.set_title("C") self.ax2.grid(True, lw = 2, ls = '--', c = '.75') self.ax3.set_title("D") self.ax3.grid(True, lw = 2, ls = '--', c = '.75') #plt.tight_layout() plt.show() canvas = self.fig.canvas self.add_widget(canvas) What worries me is that I am calling plt methods and assigning the results to my objects. Is plt the state machine interface and not the OO interface, or is this OK? Indeed, plt is the state machine interface, and it isn't exactly the same thing to say "plt.show()" and to show a particular figure. You can call `self.fig.show()`, though. Secondly, I want to periodically update the plotted lines, so I have a plot method that does this: def plot(self, xCoords, yCoords): if len(self.ax0.lines) > 0: self.ax0.lines.pop(0) line = self.ax0.plot(xCoords, yCoords, color='blue') canvas = self.fig.canvas canvas.draw() Does that look ok? Can I just pop the existing line, or should I reuse the existing line? That would work, but it is very inefficient. Most matplotlib artist objects have some sort of "set_data()" or "set_offsets()" method that would let you update the data contained in the artist. See the following animation example: http://matplotlib.org/examples/animation/animate_decay.html Lastly, and most difficult, if I enable: plt.tight_layout() I get an exception: C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer warnings.warn("tight_layout : falling back to Agg renderer") Traceback (most recent call last): File "main.py", line 1117, in GuiApp().run() File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 801, in run self.load_kv(filename=self.kv_file) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 598, in load_kv root = Builder.load_file(rfilename) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1801, in load_file return self.load_string(data, **kwargs) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1880, in load_string self._apply_rule(widget, parser.root, parser.root) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2037, in _apply_rule self.apply(child) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1924, in apply self._apply_rule(widget, rule, rule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2035, in _apply_rule child = cls(__no_builder=True) File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, in __init__ self.create_plot() File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, in create_plot self.add_widget(canvas) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", line 211, in add_widget widget.bind( AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' Can anyone help with that please? tight_layout() isn't the issue here (well, directly). The issue is that the canvas object that you added as a widget is not a widget as far as Kivy is concerned. It doesn't subclass anything that Kivy recognizes as a widget. By its very nature, FigureCanvasAgg is completely independent of any GUI frameworks. You would need to have selected the appropriate backend for matplotlib to use prior to importing pyplot (I don't know which one Kivy is compatible with, GTK? QT? something else?). By the way, chapter 5 of my book, "Interactive Applications Using Matplotlib" goes into detail explaining the ins and outs of GUI embedding with matplotlib. While I don't cover Kivy, I do a Rosetta Stone-like explanation covering GTK, Qt4, Wx, and Tk, and I explain the general concepts. Perhaps it might be useful? http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ Cheers! Ben Root Best regards David _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users Click here to report this email as spam. -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Mon Nov 16 12:47:25 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 16 Nov 2015 17:47:25 +0000 Subject: [Matplotlib-users] Beginner questions about OO interface In-Reply-To: References: <41302A7145AC054FA7A96CFD03835A0A0B9FF0FA@EX10MBX02.EU.NEC.COM> <41302A7145AC054FA7A96CFD03835A0A0B9FF825@EX10MBX02.EU.NEC.COM> Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9FF83C@EX10MBX02.EU.NEC.COM> Hi Ben Yes, I take your point. Sometimes it?s hard to choose the right book from an online seller. I have "Mastering Matplotlib" but I think that assumes intermediate knowledge of Matplotlib, and I?m not there yet. Anyway, thanks for the advice. David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 16 November 2015 17:42 To: David Aldrich Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Beginner questions about OO interface David, I should point out that Sandro's book is fairly old and that there is a new one that replaces it: "Mastering Matplotlib". Note that neither book really goes into any details about embedding figures into GUIs. Ben On Mon, Nov 16, 2015 at 12:37 PM, David Aldrich > wrote: Hi Benjamin Thanks for your reply. I have looked at your book on Amazon but thought I should go for Sandro Tosi?s book initially, just to learn the basics of Matplotlib. Perhaps I can get yours later ? Best regards David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 16 November 2015 17:23 To: David Aldrich > Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Beginner questions about OO interface Hello David, On Mon, Nov 16, 2015 at 5:55 AM, David Aldrich > wrote: Hi I am new to Matplotlib and am struggling a bit to differentiate between the OO and pyplot interfaces. I?m actually working with the Kivy GUI framework and trying to plot 4 subplots on a single figure, to be displayed by Kivy. Here?s a snippet of my code: def create_plot(self): self.fig, ((self.ax0, self.ax1), (self.ax2, self.ax3)) = plt.subplots(nrows=2, ncols=2) self.ax0.set_title("A") self.ax0.grid(True, lw = 2, ls = '--', c = '.75') self.ax1.set_title("B") self.ax1.grid(True, lw = 2, ls = '--', c = '.75') self.ax2.set_title("C") self.ax2.grid(True, lw = 2, ls = '--', c = '.75') self.ax3.set_title("D") self.ax3.grid(True, lw = 2, ls = '--', c = '.75') #plt.tight_layout() plt.show() canvas = self.fig.canvas self.add_widget(canvas) What worries me is that I am calling plt methods and assigning the results to my objects. Is plt the state machine interface and not the OO interface, or is this OK? Indeed, plt is the state machine interface, and it isn't exactly the same thing to say "plt.show()" and to show a particular figure. You can call `self.fig.show()`, though. Secondly, I want to periodically update the plotted lines, so I have a plot method that does this: def plot(self, xCoords, yCoords): if len(self.ax0.lines) > 0: self.ax0.lines.pop(0) line = self.ax0.plot(xCoords, yCoords, color='blue') canvas = self.fig.canvas canvas.draw() Does that look ok? Can I just pop the existing line, or should I reuse the existing line? That would work, but it is very inefficient. Most matplotlib artist objects have some sort of "set_data()" or "set_offsets()" method that would let you update the data contained in the artist. See the following animation example: http://matplotlib.org/examples/animation/animate_decay.html Lastly, and most difficult, if I enable: plt.tight_layout() I get an exception: C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\matplotlib\tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer warnings.warn("tight_layout : falling back to Agg renderer") Traceback (most recent call last): File "main.py", line 1117, in GuiApp().run() File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 801, in run self.load_kv(filename=self.kv_file) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\app.py", line 598, in load_kv root = Builder.load_file(rfilename) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1801, in load_file return self.load_string(data, **kwargs) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1880, in load_string self._apply_rule(widget, parser.root, parser.root) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2037, in _apply_rule self.apply(child) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 1924, in apply self._apply_rule(widget, rule, rule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2038, in _apply_rule self._apply_rule(child, crule, rootrule) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\lang.py", line 2035, in _apply_rule child = cls(__no_builder=True) File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 127, in __init__ self.create_plot() File "C:\SVNProj\Raggio\trunk\hostconsole\gui\mygraph.py", line 224, in create_plot self.add_widget(canvas) File "C:\Kivy-1.9.0-py3.4-win32-x64\Python34\lib\site-packages\kivy\uix\boxlayout.py", line 211, in add_widget widget.bind( AttributeError: 'FigureCanvasAgg' object has no attribute 'bind' Can anyone help with that please? tight_layout() isn't the issue here (well, directly). The issue is that the canvas object that you added as a widget is not a widget as far as Kivy is concerned. It doesn't subclass anything that Kivy recognizes as a widget. By its very nature, FigureCanvasAgg is completely independent of any GUI frameworks. You would need to have selected the appropriate backend for matplotlib to use prior to importing pyplot (I don't know which one Kivy is compatible with, GTK? QT? something else?). By the way, chapter 5 of my book, "Interactive Applications Using Matplotlib" goes into detail explaining the ins and outs of GUI embedding with matplotlib. While I don't cover Kivy, I do a Rosetta Stone-like explanation covering GTK, Qt4, Wx, and Tk, and I explain the general concepts. Perhaps it might be useful? http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ Cheers! Ben Root Best regards David _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users Click here to report this email as spam. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathanconroydev at gmail.com Wed Nov 18 16:59:08 2015 From: nathanconroydev at gmail.com (Unprecedented Owl) Date: Wed, 18 Nov 2015 14:59:08 -0700 (MST) Subject: [Matplotlib-users] New Programmer Looking for Places to Help Message-ID: <1447883948946-46448.post@n5.nabble.com> Hi matplotlib community, I'm a new programmer who is familiar with Python and uses GitHub. How do you suggest I can make myself useful in this open source project? -- View this message in context: http://matplotlib.1069221.n5.nabble.com/New-Programmer-Looking-for-Places-to-Help-tp46448.html Sent from the matplotlib - users mailing list archive at Nabble.com. From Derek.Wallace at synopsys.com Fri Nov 20 03:13:48 2015 From: Derek.Wallace at synopsys.com (Derek Wallace) Date: Fri, 20 Nov 2015 08:13:48 +0000 Subject: [Matplotlib-users] Matplotlib, Python 3.5.0 and RHEL 5 Message-ID: Hi, IT are trying to install matplot lib (1.5.0) for Python 3.5.0. They have it working on RHEL6 machines and claim it doesn't/cant/wont work on RHEL 5 machines. I don't have specific information from them why or what made them come to that conclusion. However when I try running I get the following. $ /depot/Python-3.5.0/bin/python Python 3.5.0 (default, Oct 15 2015, 22:50:34) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> print(matplotlib.__version__) 1.5.0 >>> import matplotlib.pyplot as plt Traceback (most recent call last): File "", line 1, in File "/depot/Python-3.5.0/lib/python3.5/site-packages/matplotlib/pyplot.py", line 29, in import matplotlib.colorbar File "/depot/Python-3.5.0/lib/python3.5/site-packages/matplotlib/colorbar.py", line 32, in import matplotlib.artist as martist File "/depot/Python-3.5.0/lib/python3.5/site-packages/matplotlib/artist.py", line 14, in from .transforms import (Bbox, IdentityTransform, TransformedBbox, File "/depot/Python-3.5.0/lib/python3.5/site-packages/matplotlib/transforms.py", line 39, in from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox, ImportError: /depot/Python-3.5.0/lib/python3.5/site-packages/matplotlib/_path.cpython-35m-x86_64-linux-gnu.so: ELF file OS ABI invalid Can anyone tell me if RHEL 5.x is supported or not? Can anyone throw any light on the above error message. Thx Derek -------------- next part -------------- An HTML attachment was scrubbed... URL: From bhmerchant at gmail.com Thu Nov 19 19:48:16 2015 From: bhmerchant at gmail.com (bmer) Date: Thu, 19 Nov 2015 17:48:16 -0700 (MST) Subject: [Matplotlib-users] Two circles with "exponential decay" coloring, and alpha < 1, have trouble with color mixing on overlaps Message-ID: <1447980496393-46455.post@n5.nabble.com> Hi all, In order to get circles such that their coloring is radially symmetric, with center being the darkest, and exponential decay in color as one moves farther away from the center along the radius, I used imshow with clip_path using Circle patches. Here's a toy script that overlaps two such circles: https://gist.github.com/bmer/7063cc2dd09f1b80a252 As you can see if you run the script (or, if you follow this link: http://i.imgur.com/H9jEAZ3.png ), even though the alpha is set at 0.5, there doesn't seem to be proper "color mixing" occurring (we should see a result that is symmetric along the x-axis). Why is that, and what could I do to fix this issue? Kind regards, Brian -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Two-circles-with-exponential-decay-coloring-and-alpha-1-have-trouble-with-color-mixing-on-overlaps-tp46455.html Sent from the matplotlib - users mailing list archive at Nabble.com.