From ndbecker2 at gmail.com Mon Oct 2 14:03:07 2017 From: ndbecker2 at gmail.com (Neal Becker) Date: Mon, 02 Oct 2017 14:03:07 -0400 Subject: [Matplotlib-users] howto plt.subplots (projection='3d')? Message-ID: Any way to use plt.subplots for 3d? This doesn't work: fig, axs = plt.subplots(nrows=opt.rcv_paths, ncols=1, sharex=True, subplot_kw=dict(projection='3d')) ... File "/home/nbecker/.local/lib/python3.6/site- packages/matplotlib/projections/__init__.py", line 67, in get_projection_class raise ValueError("Unknown projection '%s'" % projection) ValueError: Unknown projection '3d' From ben.v.root at gmail.com Mon Oct 2 14:13:28 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 2 Oct 2017 14:13:28 -0400 Subject: [Matplotlib-users] howto plt.subplots (projection='3d')? In-Reply-To: References: Message-ID: You have to import the mplot3d toolkit first. That causes the 3d projection to get registered. On Mon, Oct 2, 2017 at 2:03 PM, Neal Becker wrote: > Any way to use plt.subplots for 3d? > > This doesn't work: > fig, axs = plt.subplots(nrows=opt.rcv_paths, ncols=1, sharex=True, > subplot_kw=dict(projection='3d')) > ... > File "/home/nbecker/.local/lib/python3.6/site- > packages/matplotlib/projections/__init__.py", line 67, in > get_projection_class > raise ValueError("Unknown projection '%s'" % projection) > ValueError: Unknown projection '3d' > > _______________________________________________ > 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 daniele at grinta.net Tue Oct 3 16:59:48 2017 From: daniele at grinta.net (Daniele Nicolodi) Date: Tue, 3 Oct 2017 14:59:48 -0600 Subject: [Matplotlib-users] How to make \mathdefault{} the default? Message-ID: Hello, when adding LaTeX symbols to labels on my figures, most often I use \mathdefault{} to make Matplotlib use the same fond for the regular text and for the LaTeX part. Is there a way to configure Matplotlib to use the regular text by default? Looking at the configuration file I haven't found anything hinting to it. Thanks. Cheers, Daniele From daniele at grinta.net Tue Oct 3 17:13:56 2017 From: daniele at grinta.net (Daniele Nicolodi) Date: Tue, 3 Oct 2017 15:13:56 -0600 Subject: [Matplotlib-users] How to make \mathdefault{} the default? In-Reply-To: References: Message-ID: On 10/3/17 2:59 PM, Daniele Nicolodi wrote: > Hello, > > when adding LaTeX symbols to labels on my figures, most often I use > \mathdefault{} to make Matplotlib use the same fond for the regular text > and for the LaTeX part. Is there a way to configure Matplotlib to use > the regular text by default? Looking at the configuration file I > haven't found anything hinting to it. After staring a bit more at the example configuration file, I can answer my own question. This does the trick: matplotlib.rcParams['mathtext.fontset'] = 'custom' I'm a bit worried by the note next to this setting in the example configuration file, though: # The following settings allow you to select the fonts in math mode. # They map from a TeX font name to a fontconfig font pattern. # These settings are only used if mathtext.fontset is 'custom'. # Note that this "custom" mode is unsupported and may go away in the # future. Why is it unsupported? I find this functionality very neat. Thanks. Cheers, Daniele From ajacobo at mail.rockefeller.edu Wed Oct 4 17:20:33 2017 From: ajacobo at mail.rockefeller.edu (Adrian Jacobo) Date: Wed, 4 Oct 2017 17:20:33 -0400 Subject: [Matplotlib-users] Finding where an annotation line ends Message-ID: <4cb57349-3551-ad41-716f-35830da0c1ef@rockefeller.edu> Hi, ?I'm using an annotation for a plot in this way: ax.annotate("", xy=(x1,y1), xycoords='data', ??????????????????????????? xytext=(x2,y2), textcoords='data', ??????????????????????????? arrowprops=dict(arrowstyle='-', patchB=None, ??????????????????????????????????????????? shrinkA=25),) Because I'm setting shrinkA to 25 pixels the line doesn't exactly end at (x2,y2). Is there an easy way to find out the end point of the line in axis coordinates? An unrelated question, Is there an easy way to use a stump (a circle) as arrowstyle? Many thanks, Adrian -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Thu Oct 5 07:01:41 2017 From: ndbecker2 at gmail.com (Neal Becker) Date: Thu, 05 Oct 2017 07:01:41 -0400 Subject: [Matplotlib-users] surface plot with masked elements? Message-ID: I need to make a surface plot where some corner elements of my 2D data are invalid, and I'd like to omit them from the plot. I've seen a couple of stackoverflow questions on the subject, but none of the answers seemed satisfactory (or I understood). It's been some years now, what is the current "best" approach to this question? From ndbecker2 at gmail.com Thu Oct 5 14:55:43 2017 From: ndbecker2 at gmail.com (Neal Becker) Date: Thu, 05 Oct 2017 14:55:43 -0400 Subject: [Matplotlib-users] surface plot with masked elements? References: Message-ID: Neal Becker wrote: > I need to make a surface plot where some corner elements of my 2D data are > invalid, and I'd like to omit them from the plot. > > I've seen a couple of stackoverflow questions on the subject, but none of > the answers seemed satisfactory (or I understood). > > It's been some years now, what is the current "best" approach to this > question? I'm trying to follow the approach used here https://stackoverflow.com/questions/11020160/plotting-a-masked-surface-plot-using-python-numpy-and-matplotlib My code looks like: lev = np.linspace(np.min(abs(H)),np.max(abs(H)),10) import matplotlib.colors as colors norml = colors.BoundaryNorm(lev, 256) ax.plot_surface(grid_x, grid_y, H_2d, cmap=cm.Blues, norm=norml) The numbers '256' and '10' in the above seem to have no particular effect. I'm thinking plot_surface is re-quantizing the colormap? From padiarushi3012 at gmail.com Sat Oct 7 15:57:22 2017 From: padiarushi3012 at gmail.com (Rushikesh Padia) Date: Sun, 8 Oct 2017 01:27:22 +0530 Subject: [Matplotlib-users] Need guidance to start Message-ID: I am computer science undergraduate. I have basic understanding of c, c++, python .I would like to do some contribution to this project. This would be my first open source project. Can anyone please guide me which part I can work and how to start. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sat Oct 7 16:44:51 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 07 Oct 2017 20:44:51 +0000 Subject: [Matplotlib-users] Need guidance to start In-Reply-To: References: Message-ID: Rushikesh, The best place to start is http://matplotlib.org/devdocs/devel/contributing.html which covers how we use git / github for development. We have a 'new contributor friendly' tag https://github.com/matplotlib/matplotlib/issues?q=is%3Aopen+is%3Aissue+label%3Anew-contributor-friendly of issues we think are good entry points for new contributors. Please ask any questions either here or on https://gitter.im/matplotlib/matplotlib Tom On Sat, Oct 7, 2017 at 3:57 PM Rushikesh Padia wrote: > I am computer science undergraduate. I have basic understanding of c, c++, > python .I would like to do some contribution to this project. This would be > my first open source project. Can anyone please guide me which part I can > work and how to start. > _______________________________________________ > 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 Sat Oct 7 19:30:11 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 07 Oct 2017 23:30:11 +0000 Subject: [Matplotlib-users] [ANN] Matplotlib 2.1 released Message-ID: We are happy to announce the release of Matplotlib 2.1. This is the second minor release in the Matplotlib 2.x series and the first release with major new features since 1.5. This release contains approximately 2 years worth of work by 275 contributors across over 950 pull requests. Highlights from this release include: - support for string categorical values - export of animations to interactive javascript widgets - major overhaul of polar plots - reproducible output for ps/eps, pdf, and svg backends - performance improvements in drawing lines and images - GUIs show a busy cursor while rendering the plot along with many other enhancements and bug fixes. The gallery, examples, and tutorials have been overhauled and consolidated: Examples: http://matplotlib.org/gallery/index.html Tutorials: http://matplotlib.org/tutorials/index.html A big thank you to everyone who contributed to this release! Wheels are available on pypi for win/mac/manylinux and for conda via conda-forge. Full whats new: http://matplotlib.org/users/whats_new.html#new-in-matplotlib-2-1 Full API changes: http://matplotlib.org/api/api_changes.html#api-changes-in-2-1-0 github stats: http://matplotlib.org/users/github_stats.html Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From maurobio at gmail.com Sun Oct 8 14:33:57 2017 From: maurobio at gmail.com (Mauro Cavalcanti) Date: Sun, 8 Oct 2017 15:33:57 -0300 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap Message-ID: Dear ALL, I have a simple dataset of longitudes/latitudes (see the attached csv file). >From such data, I want to generate a grid like this: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 2 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 which gives the number of data records in each cell of the grid, using one of the variables in the dataset ("spp") as a categorical (grouping) factor. >From this grid, I then want to create a heat map, superimposed on a Matplotlib/Basemap. I wrote some code which does what I want (see the attachments). It (mostly) works, but te problem is that the grid image is not being displayed correctly: as shown in the attached figure, it appears too small, and in the lower left corner of the map, instead of where it should be (the West coast of Africa, along the Gulf of Guinea). Thanks in advance for any assistance you can provide. Best regards, -- Dr. Mauro J. Cavalcanti E-mail: maurobio at gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- import csv import numpy as np from mpl_toolkits.basemap import Basemap from matplotlib import cm as cmap import matplotlib.pyplot as plt import warnings warnings.filterwarnings("ignore") #read input data with open('testdata.csv', 'r') as csvfile: reader = csv.reader(csvfile, delimiter=',') headers = reader.next() input_data = list(reader) #grid dimensions with one-degree resolution lat_inf, lon_inf = 0, 0 lat_sup, lon_sup = 90, 360 resolution = 1 latitude, longitude = [], [] latitude = range(lat_inf, lat_sup, resolution) longitude = range(lon_inf, lon_sup, resolution) #create output grid output_grid = [] for i in latitude: output_grid.append([]) for j in longitude: output_grid[i].append(0) #traverse the input_data evaluating the lat, lon coordinates #summing +1 in the output_grid[latitude][longitude]. for row in input_data: lat = int(row[2]) lon = int(row[3]) #sp = row[1] #check its indexes i_lat = latitude.index(lat) i_lon = longitude.index(lon) #increase counter output_grid[i_lat][i_lon] += 1 output_grid = np.array(output_grid, np.int16) #create map m = Basemap() m.drawcoastlines(linewidth=0.25) #display image im = m.imshow(output_grid.transpose(), cmap='summer', origin='lower', aspect='auto', interpolation='none') m.colorbar(im) plt.show() -------------- next part -------------- A non-text attachment was scrubbed... Name: testdata.csv Type: text/csv Size: 277 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Figure_1.png Type: image/png Size: 63619 bytes Desc: not available URL: From ben.v.root at gmail.com Mon Oct 9 10:29:31 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 9 Oct 2017 10:29:31 -0400 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: First, you shouldn't need to transpose your image... that'll effectively rotate the data by 90 degrees. Second, you didn't specify the extents of your image, so Basemap is putting everything starting at coordinate 0,0 in the default projection. If you specify the extent keyword argument to imshow as the (lon1, lat1, lon2, lat2) tuple for the lower-left and upper right corners, you won't even need the origin='lower', and you definitely won't need the transpose. Cheers! Ben Root On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti wrote: > Dear ALL, > > I have a simple dataset of longitudes/latitudes (see the attached csv > file). > > From such data, I want to generate a grid like this: > > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 1 0 0 0 0 0 0 > 0 0 0 0 0 0 1 1 2 0 0 0 0 > 0 0 0 0 0 1 1 1 1 0 0 0 0 > 0 0 0 1 0 1 0 0 0 0 0 0 0 > 0 0 0 2 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 1 3 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 1 0 0 0 > 0 0 0 0 0 0 0 0 0 1 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 1 0 0 > 0 0 0 0 0 0 0 0 0 0 1 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > > which gives the number of data records in each cell of the grid, using one > of the variables in the dataset ("spp") as a categorical (grouping) factor. > > From this grid, I then want to create a heat map, superimposed on a > Matplotlib/Basemap. > > I wrote some code which does what I want (see the attachments). > > It (mostly) works, but te problem is that the grid image is not being > displayed correctly: as shown in the attached figure, it appears too small, > and in the lower left corner of the map, instead of where it should be (the > West coast of Africa, along the Gulf of Guinea). > > Thanks in advance for any assistance you can provide. > > Best regards, > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > > _______________________________________________ > 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 strozzi2 at llnl.gov Mon Oct 9 12:23:16 2017 From: strozzi2 at llnl.gov (Strozzi, David J.) Date: Mon, 9 Oct 2017 16:23:16 +0000 Subject: [Matplotlib-users] Windows7: figure window "not responding" In-Reply-To: References: Message-ID: Hope this appears in the thread. I still haven?t solved this issue, trying to bump this to the top of someone?s stack. No one responded to this message. Any help appreciated. Thanks. Dave From: Matplotlib-users [mailto:matplotlib-users-bounces+strozzi2=llnl.gov at python.org] On Behalf Of Strozzi, David J. Sent: Monday, August 28, 2017 1:48 PM To: Thomas Caswell ; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" Sorry for the delay. Life, work, etc. intervene. I tried tk backend, failed but in a different way. Seems to get ?farther? in that I can get a plot to render. * Versions (all very recent from Anaconda): Python: 3.6.2 ipython: 6.1.0 matplotlib: 2.0.2 * My emacs startup has (elpy-use-ipython). * With backend ?TkAgg?: plt.ion() figure(1) --> window appears, with buttons on bottom (doesn?t happen with ?Qt5Agg? backend. ipyton prompt works. But, if I try interacting with the figure window, I get ?not responding? in title, and windows? spinning shell. If I close the figure window by clicking on the X in upper right, windows says ?app not responding.? Dialog box w/ End Process or Cancel. End process kills figure and ipython session. plt.ioff() instead: figure(1) plot(1,1) show() I get a figure window with a plot, but if I interact with it I get ?not responding.? ipython prompt seems fine. I can close window from prompt close(1) and ipython fine. Help appreciated! I hopefully won?t wait so long to respond. Thanks, Dave From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: Saturday, August 19, 2017 2:32 PM To: Strozzi, David J. >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" That is at least all consistent! The issue as that for what ever reason the input hook is not being set up correctly (which is what lets the GUI event loop spin and process events while the terminal waits for you to type). With `plt.ion()` the terminal is blocking the process waiting for you to type (which is why the window is not responding), with `plt.ioff()` when you do `plt.show()` the GUI event loop is blocking the process (which is why it works, but you don't get the next prompt back until you close the plot window). Again, see https://github.com/matplotlib/matplotlib/pull/4779 for a longer pass at explaining how this all works (and I would appreciate feed back about where it does not make sense!). Try using `tkagg` as the backend, the integration between python and tk in a bit tighter (because it is done in the cpython source). Which version of IPython and matplotlib are you using (and are you sure that elpy is using the versions you think it is?)? are you using `(elpy-use-ipython)` or just hacking the python executable path? You are siting at a very interesting intersection of technology here (emacs + python + GUI + windows). It might make sense to ask either on the elpy mailing list or the ipython mailing list. Tom On Sat, Aug 19, 2017 at 3:28 PM Strozzi, David J. > wrote: Hi, * Just subscribed to list. * Backend: mpl.get_backend() = ?Qt5Agg?. I am not committed to this if another one will work. * ?If you get up a window:? I start ipython within emacs (the GNU win32 build, not cygwin), and do figure(1), a figure window appears, but nothing renders, and window title bar says ?Not responding.? If I plot something, it doesn?t appear. fig is not defined, by default. I can do fig=gcf(). Then fig.canvas.flush_events() has an interesting effect ? the plot appears, but then window title still says ?not responding? and when I hover the mouse over the figure window it becomes Windows? spinning blue circle (the busy symbol, like Mac?s spinning beachball). ?control? is returned to ipython. I can continue to execute commands there. * At this point, plt.ioff() doesn?t seem to do anything. plt.show() does ? ?not responding? disappears, the figure window works like normal. Buttons on it work. But the ipython window is ?frozen? no In[] prompt. OK so this seems like a lot of information. Maybe we can make progress? Dave From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: Saturday, August 19, 2017 10:54 AM To: Strozzi, David J. >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" David, Please subscribe to the mailing list so you can post un-moderated. Which backend are you using? If you get a window up and then do `fig.canvas.flush_events()` will it update? If you do `plt.ioff()` and then `plt.show()` does it work? Tom On Sat, Aug 19, 2017 at 12:40 PM Strozzi, David J. > wrote: Thanks for the respone. Sadly, I can?t get anything useful out of the doc. And %matplotlib doesn?t help, same effect. This is very frustrating. I don?t know how to debug this. It?s just a ?black box?, I do what I?m ?supposed to?, doesn?t work. Help appreciated! Dave From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: Saturday, August 05, 2017 10:36 AM To: Strozzi, David J. >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" I do exactly this as well (but on linux)! The symptoms your are describing sounds like the GUI event loop is not being spun behind the scenes (see https://github.com/matplotlib/matplotlib/pull/4779 for some draft text at explaining how all of that works). Have you tried doing `%matplotlib` is IPython? Tom On Sat, Aug 5, 2017 at 12:39 PM Strozzi, David J. > wrote: This problem has been driving me nuts, posted it elsewhere, so far no one's been able to help. I am running Python 3.6.1 from Anaconda (all packages updated to latest and greatest) on Windows 7. ipython and mpl figure windows work fine from a console, or spyder. The problem is when I try running ipython within emacs using elpy. To back up, the workflow I'm shooting for is using emacs as my IDE, and running python within emacs. I've done this for many years with the Yorick interpreter, and it's quite addictive. I get the same problem whether I use the GNU windows build of emacs, or emacs -nw (terminal, no X) from cygwin (ver 25.2 both cases). elpy seems to be a good Python package for emacs, and nominally supports using ipython. OK, so - I can use ipython + emacs + elpy. The only problem is matplotlib figures. When I do figure(), a figure window appears, but is not fully rendered (e.g. no buttons), and the window title says "Not responding". If I do a plot(), nothing is plotted. Playing with ion() and show() doesn't help. I've posted this on the elpy github, various stackexchange forums, no one has had any ideas yet. Any help is greatly appreciated! Dave _______________________________________________ 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 thibault.marin.us at ieee.org Mon Oct 9 12:53:56 2017 From: thibault.marin.us at ieee.org (Thibault Marin) Date: Mon, 09 Oct 2017 11:53:56 -0500 Subject: [Matplotlib-users] Windows7: figure window "not responding" In-Reply-To: References: Message-ID: <87tvz8b6u3.fsf@dell-desktop.WORKGROUP> Hi, I thought I replied to that, but I probably failed for some reason. Here is my (slightly edited) reply, I hope it helps. ---- Hi, Sorry for breaking the thread, I have just subscribed to the list and I don't know how to respond to a message that predates my subscription. I hope this messages makes its way. I believe I have a similar setup (Windows + emacs + Qt5Agg, python 3.5 and matplotlib 2+). I also see freezes when starting ipython from within emacs. The way I work around that is by using org-mode and ob-ipython (https://github.com/gregsexton/ob-ipython). To work with matplotlib, I do the following: 1 - Open my org file, which starts with something like: ,---- | #+PROPERTY: header-args :eval no-export :session Python | | #+NAME: py-startup-0 | #+BEGIN_SRC ipython :results silent :exports none | # %% Standard imports | # General | import os | import sys | import re | import matplotlib as mpl | mpl.use('Qt5Agg') | #+END_SRC `---- 2 - Execute the source block (move point at the beginning of the "BEGIN_SRC line" and C-c C-c) I then get a warning about the interpreter which I ignore. Note that it sometimes hangs at that point, in which case I use C-g. 3 - The *Python* buffer then contains the ipython session, in which I can use matplotlib: I get not freezes and calls do not block the ipython instance. Note that I have to run `plt.ion()` once to get matplotlib figures to show up. Important note: I often get an error on the first command I type in the *Python* shell, so I typically go to the *Python* buffer, press enter and ignore the error I may get (I am guessing some line return is missing in some previous command sent during the setup). 4 - I usually write most of my code in org-mode anyway, but after running the source block I can open any .py file and work with it ignoring the org-mode part. For completeness, my emacs init file contains the following: ,---- | (when (eq system-type 'windows-nt) | (progn | (setq python-shell-interpreter-args "--simple-prompt -i") | (setq ob-ipython-command "ipython"))) `---- I hope this helps. thibault Strozzi, David J. writes: > Hope this appears in the thread. I still haven?t solved this issue, trying to bump this to the top of someone?s stack. No one responded to this message. > > Any help appreciated. Thanks. > > Dave > > From: Matplotlib-users [mailto:matplotlib-users-bounces+strozzi2=llnl.gov at python.org] On Behalf Of Strozzi, David J. > Sent: Monday, August 28, 2017 1:48 PM > To: Thomas Caswell ; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > Sorry for the delay. Life, work, etc. intervene. I tried tk backend, failed but in a different way. Seems to get ?farther? in that I can get a plot to render. > > * Versions (all very recent from Anaconda): Python: 3.6.2 ipython: 6.1.0 matplotlib: 2.0.2 > > * My emacs startup has (elpy-use-ipython). > > * With backend ?TkAgg?: > > plt.ion() > figure(1) --> window appears, with buttons on bottom (doesn?t happen with ?Qt5Agg? backend. ipyton prompt works. But, if I try interacting with the figure window, I get ?not responding? in title, and windows? spinning shell. If I close the figure window by clicking on the X in upper right, windows says ?app not responding.? Dialog box w/ End Process or Cancel. End process kills figure and ipython session. > > plt.ioff() instead: > figure(1) > plot(1,1) > show() > I get a figure window with a plot, but if I interact with it I get ?not responding.? ipython prompt seems fine. I can close window from prompt close(1) and ipython fine. > > Help appreciated! I hopefully won?t wait so long to respond. > > Thanks, > Dave > > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > Sent: Saturday, August 19, 2017 2:32 PM > To: Strozzi, David J. >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > That is at least all consistent! The issue as that for what ever reason the input hook is not being set up correctly (which is what lets the GUI event loop spin and process events while the terminal waits for you to type). With `plt.ion()` the terminal is blocking the process waiting for you to type (which is why the window is not responding), with `plt.ioff()` when you do `plt.show()` the GUI event loop is blocking the process (which is why it works, but you don't get the next prompt back until you close the plot window). Again, see https://github.com/matplotlib/matplotlib/pull/4779 for a longer pass at explaining how this all works (and I would appreciate feed back about where it does not make sense!). > > Try using `tkagg` as the backend, the integration between python and tk in a bit tighter (because it is done in the cpython source). > > Which version of IPython and matplotlib are you using (and are you sure that elpy is using the versions you think it is?)? > > are you using `(elpy-use-ipython)` or just hacking the python executable path? > > You are siting at a very interesting intersection of technology here (emacs + python + GUI + windows). It might make sense to ask either on the elpy mailing list or the ipython mailing list. > > Tom > > On Sat, Aug 19, 2017 at 3:28 PM Strozzi, David J. > wrote: > Hi, > > * Just subscribed to list. > > * Backend: mpl.get_backend() = ?Qt5Agg?. I am not committed to this if another one will work. > > * ?If you get up a window:? I start ipython within emacs (the GNU win32 build, not cygwin), and do figure(1), a figure window appears, but nothing renders, and window title bar says ?Not responding.? If I plot something, it doesn?t appear. > > fig is not defined, by default. I can do fig=gcf(). Then fig.canvas.flush_events() has an interesting effect ? the plot appears, but then window title still says ?not responding? and when I hover the mouse over the figure window it becomes Windows? spinning blue circle (the busy symbol, like Mac?s spinning beachball). > > ?control? is returned to ipython. I can continue to execute commands there. > > * At this point, plt.ioff() doesn?t seem to do anything. plt.show() does ? ?not responding? disappears, the figure window works like normal. Buttons on it work. But the ipython window is ?frozen? no In[] prompt. > > OK so this seems like a lot of information. Maybe we can make progress? > > Dave > > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > Sent: Saturday, August 19, 2017 10:54 AM > > To: Strozzi, David J. >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > David, > > Please subscribe to the mailing list so you can post un-moderated. > > Which backend are you using? > > If you get a window up and then do `fig.canvas.flush_events()` will it update? > > If you do `plt.ioff()` and then `plt.show()` does it work? > > Tom > > > On Sat, Aug 19, 2017 at 12:40 PM Strozzi, David J. > wrote: > Thanks for the respone. Sadly, I can?t get anything useful out of the doc. And %matplotlib doesn?t help, same effect. > > This is very frustrating. I don?t know how to debug this. It?s just a ?black box?, I do what I?m ?supposed to?, doesn?t work. > > Help appreciated! > Dave > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > Sent: Saturday, August 05, 2017 10:36 AM > To: Strozzi, David J. >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > I do exactly this as well (but on linux)! > > The symptoms your are describing sounds like the GUI event loop is not being spun behind the scenes (see https://github.com/matplotlib/matplotlib/pull/4779 for some draft text at explaining how all of that works). Have you tried doing `%matplotlib` is IPython? > > Tom > > On Sat, Aug 5, 2017 at 12:39 PM Strozzi, David J. > wrote: > > This problem has been driving me nuts, posted it elsewhere, so far no one's been able to help. I am running Python 3.6.1 from Anaconda (all packages updated to latest and greatest) on Windows 7. ipython and mpl figure windows work fine from a console, or spyder. The problem is when I try running ipython within emacs using elpy. > > > > To back up, the workflow I'm shooting for is using emacs as my IDE, and running python within emacs. I've done this for many years with the Yorick interpreter, and it's quite addictive. I get the same problem whether I use the GNU windows build of emacs, or emacs -nw (terminal, no X) from cygwin (ver 25.2 both cases). elpy seems to be a good Python package for emacs, and nominally supports using ipython. > > > > OK, so - I can use ipython + emacs + elpy. The only problem is matplotlib figures. When I do figure(), a figure window appears, but is not fully rendered (e.g. no buttons), and the window title says "Not responding". If I do a plot(), nothing is plotted. Playing with ion() and show() doesn't help. > > > > I've posted this on the elpy github, various stackexchange forums, no one has had any ideas yet. > > > > Any help is greatly appreciated! > > Dave > _______________________________________________ > 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 strozzi2 at llnl.gov Mon Oct 9 13:07:40 2017 From: strozzi2 at llnl.gov (Strozzi, David J.) Date: Mon, 9 Oct 2017 17:07:40 +0000 Subject: [Matplotlib-users] Windows7: figure window "not responding" In-Reply-To: <87tvz8b6u3.fsf@dell-desktop.WORKGROUP> References: <87tvz8b6u3.fsf@dell-desktop.WORKGROUP> Message-ID: Hi, Thanks, I did get this response, but consider it too 'convoluted' or 'non-standard'. I think this workflow of running ipython inside emacs should "just work" with some set of standard tools, like elpy + ipython + matplotlib, and not need one to "roll their own". Of course Windows may be a pretty non-standard misfit but such is life! Dave -----Original Message----- From: Thibault Marin [mailto:thibault.marin.us at ieee.org] Sent: Monday, October 09, 2017 9:54 AM To: Strozzi, David J. Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" Hi, I thought I replied to that, but I probably failed for some reason. Here is my (slightly edited) reply, I hope it helps. ---- Hi, Sorry for breaking the thread, I have just subscribed to the list and I don't know how to respond to a message that predates my subscription. I hope this messages makes its way. I believe I have a similar setup (Windows + emacs + Qt5Agg, python 3.5 and matplotlib 2+). I also see freezes when starting ipython from within emacs. The way I work around that is by using org-mode and ob-ipython (https://github.com/gregsexton/ob-ipython). To work with matplotlib, I do the following: 1 - Open my org file, which starts with something like: ,---- | #+PROPERTY: header-args :eval no-export :session Python | | #+NAME: py-startup-0 | #+BEGIN_SRC ipython :results silent :exports none # %% Standard | imports # General import os import sys import re import matplotlib as | mpl | mpl.use('Qt5Agg') | #+END_SRC `---- 2 - Execute the source block (move point at the beginning of the "BEGIN_SRC line" and C-c C-c) I then get a warning about the interpreter which I ignore. Note that it sometimes hangs at that point, in which case I use C-g. 3 - The *Python* buffer then contains the ipython session, in which I can use matplotlib: I get not freezes and calls do not block the ipython instance. Note that I have to run `plt.ion()` once to get matplotlib figures to show up. Important note: I often get an error on the first command I type in the *Python* shell, so I typically go to the *Python* buffer, press enter and ignore the error I may get (I am guessing some line return is missing in some previous command sent during the setup). 4 - I usually write most of my code in org-mode anyway, but after running the source block I can open any .py file and work with it ignoring the org-mode part. For completeness, my emacs init file contains the following: ,---- | (when (eq system-type 'windows-nt) | (progn | (setq python-shell-interpreter-args "--simple-prompt -i") | (setq ob-ipython-command "ipython"))) `---- I hope this helps. thibault Strozzi, David J. writes: > Hope this appears in the thread. I still haven?t solved this issue, trying to bump this to the top of someone?s stack. No one responded to this message. > > Any help appreciated. Thanks. > > Dave > > From: Matplotlib-users [mailto:matplotlib-users-bounces+strozzi2=llnl.gov at python.org] On Behalf Of Strozzi, David J. > Sent: Monday, August 28, 2017 1:48 PM > To: Thomas Caswell ; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > Sorry for the delay. Life, work, etc. intervene. I tried tk backend, failed but in a different way. Seems to get ?farther? in that I can get a plot to render. > > * Versions (all very recent from Anaconda): Python: 3.6.2 ipython: > 6.1.0 matplotlib: 2.0.2 > > * My emacs startup has (elpy-use-ipython). > > * With backend ?TkAgg?: > > plt.ion() > figure(1) --> window appears, with buttons on bottom (doesn?t happen with ?Qt5Agg? backend. ipyton prompt works. But, if I try interacting with the figure window, I get ?not responding? in title, and windows? spinning shell. If I close the figure window by clicking on the X in upper right, windows says ?app not responding.? Dialog box w/ End Process or Cancel. End process kills figure and ipython session. > > plt.ioff() instead: > figure(1) > plot(1,1) > show() > I get a figure window with a plot, but if I interact with it I get ?not responding.? ipython prompt seems fine. I can close window from prompt close(1) and ipython fine. > > Help appreciated! I hopefully won?t wait so long to respond. > > Thanks, > Dave > > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > Sent: Saturday, August 19, 2017 2:32 PM > To: Strozzi, David J. >; > matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > That is at least all consistent! The issue as that for what ever reason the input hook is not being set up correctly (which is what lets the GUI event loop spin and process events while the terminal waits for you to type). With `plt.ion()` the terminal is blocking the process waiting for you to type (which is why the window is not responding), with `plt.ioff()` when you do `plt.show()` the GUI event loop is blocking the process (which is why it works, but you don't get the next prompt back until you close the plot window). Again, see https://github.com/matplotlib/matplotlib/pull/4779 for a longer pass at explaining how this all works (and I would appreciate feed back about where it does not make sense!). > > Try using `tkagg` as the backend, the integration between python and tk in a bit tighter (because it is done in the cpython source). > > Which version of IPython and matplotlib are you using (and are you sure that elpy is using the versions you think it is?)? > > are you using `(elpy-use-ipython)` or just hacking the python executable path? > > You are siting at a very interesting intersection of technology here (emacs + python + GUI + windows). It might make sense to ask either on the elpy mailing list or the ipython mailing list. > > Tom > > On Sat, Aug 19, 2017 at 3:28 PM Strozzi, David J. > wrote: > Hi, > > * Just subscribed to list. > > * Backend: mpl.get_backend() = ?Qt5Agg?. I am not committed to this if another one will work. > > * ?If you get up a window:? I start ipython within emacs (the GNU win32 build, not cygwin), and do figure(1), a figure window appears, but nothing renders, and window title bar says ?Not responding.? If I plot something, it doesn?t appear. > > fig is not defined, by default. I can do fig=gcf(). Then fig.canvas.flush_events() has an interesting effect ? the plot appears, but then window title still says ?not responding? and when I hover the mouse over the figure window it becomes Windows? spinning blue circle (the busy symbol, like Mac?s spinning beachball). > > ?control? is returned to ipython. I can continue to execute commands there. > > * At this point, plt.ioff() doesn?t seem to do anything. plt.show() does ? ?not responding? disappears, the figure window works like normal. Buttons on it work. But the ipython window is ?frozen? no In[] prompt. > > OK so this seems like a lot of information. Maybe we can make progress? > > Dave > > > From: Thomas Caswell > [mailto:tcaswell at gmail.com] > Sent: Saturday, August 19, 2017 10:54 AM > > To: Strozzi, David J. >; > matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > David, > > Please subscribe to the mailing list so you can post un-moderated. > > Which backend are you using? > > If you get a window up and then do `fig.canvas.flush_events()` will it update? > > If you do `plt.ioff()` and then `plt.show()` does it work? > > Tom > > > On Sat, Aug 19, 2017 at 12:40 PM Strozzi, David J. > wrote: > Thanks for the respone. Sadly, I can?t get anything useful out of the doc. And %matplotlib doesn?t help, same effect. > > This is very frustrating. I don?t know how to debug this. It?s just a ?black box?, I do what I?m ?supposed to?, doesn?t work. > > Help appreciated! > Dave > > From: Thomas Caswell > [mailto:tcaswell at gmail.com] > Sent: Saturday, August 05, 2017 10:36 AM > To: Strozzi, David J. >; > matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > I do exactly this as well (but on linux)! > > The symptoms your are describing sounds like the GUI event loop is not being spun behind the scenes (see https://github.com/matplotlib/matplotlib/pull/4779 for some draft text at explaining how all of that works). Have you tried doing `%matplotlib` is IPython? > > Tom > > On Sat, Aug 5, 2017 at 12:39 PM Strozzi, David J. > wrote: > > This problem has been driving me nuts, posted it elsewhere, so far no one's been able to help. I am running Python 3.6.1 from Anaconda (all packages updated to latest and greatest) on Windows 7. ipython and mpl figure windows work fine from a console, or spyder. The problem is when I try running ipython within emacs using elpy. > > > > To back up, the workflow I'm shooting for is using emacs as my IDE, and running python within emacs. I've done this for many years with the Yorick interpreter, and it's quite addictive. I get the same problem whether I use the GNU windows build of emacs, or emacs -nw (terminal, no X) from cygwin (ver 25.2 both cases). elpy seems to be a good Python package for emacs, and nominally supports using ipython. > > > > OK, so - I can use ipython + emacs + elpy. The only problem is matplotlib figures. When I do figure(), a figure window appears, but is not fully rendered (e.g. no buttons), and the window title says "Not responding". If I do a plot(), nothing is plotted. Playing with ion() and show() doesn't help. > > > > I've posted this on the elpy github, various stackexchange forums, no one has had any ideas yet. > > > > Any help is greatly appreciated! > > Dave > _______________________________________________ > 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 ben.v.root at gmail.com Mon Oct 9 13:20:30 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 9 Oct 2017 13:20:30 -0400 Subject: [Matplotlib-users] Windows7: figure window "not responding" In-Reply-To: References: <87tvz8b6u3.fsf@dell-desktop.WORKGROUP> Message-ID: Just some thoughts... have you roped in any ipython devs into this discussion? Can you confirm that doing similar things, but outside of emacs, works as expected? Can you confirm that just simply using ipython within emacs, but without matplotlib, also works as expected? Also, now that I think of it, could you also re-confirm exactly which versions of matplotlib, emacs, and ipython you are using, and where your matplotlib and ipython were installed from? Just trying to narrow down the possible sources of issues. Cheers! Ben Root On Mon, Oct 9, 2017 at 1:07 PM, Strozzi, David J. wrote: > Hi, > > Thanks, I did get this response, but consider it too 'convoluted' or > 'non-standard'. I think this workflow of running ipython inside emacs > should "just work" with some set of standard tools, like elpy + ipython + > matplotlib, and not need one to "roll their own". Of course Windows may be > a pretty non-standard misfit but such is life! > > Dave > > -----Original Message----- > From: Thibault Marin [mailto:thibault.marin.us at ieee.org] > Sent: Monday, October 09, 2017 9:54 AM > To: Strozzi, David J. > Cc: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > Hi, I thought I replied to that, but I probably failed for some reason. > Here is my (slightly edited) reply, I hope it helps. > > ---- > > Hi, > > Sorry for breaking the thread, I have just subscribed to the list and I > don't know how to respond to a message that predates my subscription. I > hope this messages makes its way. > > I believe I have a similar setup (Windows + emacs + Qt5Agg, python 3.5 and > matplotlib 2+). I also see freezes when starting ipython from within emacs. > > The way I work around that is by using org-mode and ob-ipython ( > https://github.com/gregsexton/ob-ipython). > > To work with matplotlib, I do the following: > > 1 - Open my org file, which starts with something like: > ,---- > | #+PROPERTY: header-args :eval no-export :session Python > | > | #+NAME: py-startup-0 > | #+BEGIN_SRC ipython :results silent :exports none # %% Standard > | imports # General import os import sys import re import matplotlib as > | mpl > | mpl.use('Qt5Agg') > | #+END_SRC > `---- > > 2 - Execute the source block (move point at the beginning of the > "BEGIN_SRC line" and C-c C-c) > > I then get a warning about the interpreter which I ignore. Note that it > sometimes hangs at that point, in which case I use C-g. > > 3 - The *Python* buffer then contains the ipython session, in which I can > use matplotlib: I get not freezes and calls do not block the ipython > instance. Note that I have to run `plt.ion()` once to get matplotlib > figures to show up. Important note: I often get an error on the first > command I type in the *Python* shell, so I typically go to the *Python* > buffer, press enter and ignore the error I may get (I am guessing some line > return is missing in some previous command sent during the setup). > > 4 - I usually write most of my code in org-mode anyway, but after running > the source block I can open any .py file and work with it ignoring the > org-mode part. > > For completeness, my emacs init file contains the following: > ,---- > | (when (eq system-type 'windows-nt) > | (progn > | (setq python-shell-interpreter-args "--simple-prompt -i") > | (setq ob-ipython-command "ipython"))) > `---- > > I hope this helps. > > thibault > > Strozzi, David J. writes: > > > Hope this appears in the thread. I still haven?t solved this issue, > trying to bump this to the top of someone?s stack. No one responded to > this message. > > > > Any help appreciated. Thanks. > > > > Dave > > > > From: Matplotlib-users [mailto:matplotlib-users-bounces+strozzi2= > llnl.gov at python.org] On Behalf Of Strozzi, David J. > > Sent: Monday, August 28, 2017 1:48 PM > > To: Thomas Caswell ; matplotlib-users at python.org > > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > > > Sorry for the delay. Life, work, etc. intervene. I tried tk backend, > failed but in a different way. Seems to get ?farther? in that I can get a > plot to render. > > > > * Versions (all very recent from Anaconda): Python: 3.6.2 ipython: > > 6.1.0 matplotlib: 2.0.2 > > > > * My emacs startup has (elpy-use-ipython). > > > > * With backend ?TkAgg?: > > > > plt.ion() > > figure(1) --> window appears, with buttons on bottom (doesn?t happen > with ?Qt5Agg? backend. ipyton prompt works. But, if I try interacting > with the figure window, I get ?not responding? in title, and windows? > spinning shell. If I close the figure window by clicking on the X in upper > right, windows says ?app not responding.? Dialog box w/ End Process or > Cancel. End process kills figure and ipython session. > > > > plt.ioff() instead: > > figure(1) > > plot(1,1) > > show() > > I get a figure window with a plot, but if I interact with it I get ?not > responding.? ipython prompt seems fine. I can close window from prompt > close(1) and ipython fine. > > > > Help appreciated! I hopefully won?t wait so long to respond. > > > > Thanks, > > Dave > > > > > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > > Sent: Saturday, August 19, 2017 2:32 PM > > To: Strozzi, David J. >; > > matplotlib-users at python.org > > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > > > That is at least all consistent! The issue as that for what ever reason > the input hook is not being set up correctly (which is what lets the GUI > event loop spin and process events while the terminal waits for you to > type). With `plt.ion()` the terminal is blocking the process waiting for > you to type (which is why the window is not responding), with `plt.ioff()` > when you do `plt.show()` the GUI event loop is blocking the process (which > is why it works, but you don't get the next prompt back until you close the > plot window). Again, see https://github.com/matplotlib/ > matplotlib/pull/4779 for a longer pass at explaining how this all works > (and I would appreciate feed back about where it does not make sense!). > > > > Try using `tkagg` as the backend, the integration between python and tk > in a bit tighter (because it is done in the cpython source). > > > > Which version of IPython and matplotlib are you using (and are you sure > that elpy is using the versions you think it is?)? > > > > are you using `(elpy-use-ipython)` or just hacking the python executable > path? > > > > You are siting at a very interesting intersection of technology here > (emacs + python + GUI + windows). It might make sense to ask either on the > elpy mailing list or the ipython mailing list. > > > > Tom > > > > On Sat, Aug 19, 2017 at 3:28 PM Strozzi, David J. > wrote: > > Hi, > > > > * Just subscribed to list. > > > > * Backend: mpl.get_backend() = ?Qt5Agg?. I am not committed to this if > another one will work. > > > > * ?If you get up a window:? I start ipython within emacs (the GNU win32 > build, not cygwin), and do figure(1), a figure window appears, but nothing > renders, and window title bar says ?Not responding.? If I plot something, > it doesn?t appear. > > > > fig is not defined, by default. I can do fig=gcf(). Then > fig.canvas.flush_events() has an interesting effect ? the plot appears, but > then window title still says ?not responding? and when I hover the mouse > over the figure window it becomes Windows? spinning blue circle (the busy > symbol, like Mac?s spinning beachball). > > > > ?control? is returned to ipython. I can continue to execute commands > there. > > > > * At this point, plt.ioff() doesn?t seem to do anything. plt.show() > does ? ?not responding? disappears, the figure window works like normal. > Buttons on it work. But the ipython window is ?frozen? no In[] prompt. > > > > OK so this seems like a lot of information. Maybe we can make progress? > > > > Dave > > > > > > From: Thomas Caswell > > [mailto:tcaswell at gmail.com] > > Sent: Saturday, August 19, 2017 10:54 AM > > > > To: Strozzi, David J. >; > > matplotlib-users at python.org > > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > > > David, > > > > Please subscribe to the mailing list so you can post un-moderated. > > > > Which backend are you using? > > > > If you get a window up and then do `fig.canvas.flush_events()` will it > update? > > > > If you do `plt.ioff()` and then `plt.show()` does it work? > > > > Tom > > > > > > On Sat, Aug 19, 2017 at 12:40 PM Strozzi, David J. > wrote: > > Thanks for the respone. Sadly, I can?t get anything useful out of the > doc. And %matplotlib doesn?t help, same effect. > > > > This is very frustrating. I don?t know how to debug this. It?s just a > ?black box?, I do what I?m ?supposed to?, doesn?t work. > > > > Help appreciated! > > Dave > > > > From: Thomas Caswell > > [mailto:tcaswell at gmail.com] > > Sent: Saturday, August 05, 2017 10:36 AM > > To: Strozzi, David J. >; > > matplotlib-users at python.org > > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > > > I do exactly this as well (but on linux)! > > > > The symptoms your are describing sounds like the GUI event loop is not > being spun behind the scenes (see https://github.com/matplotlib/ > matplotlib/pull/4779 for some draft text at explaining how all of that > works). Have you tried doing `%matplotlib` is IPython? > > > > Tom > > > > On Sat, Aug 5, 2017 at 12:39 PM Strozzi, David J. > wrote: > > > > This problem has been driving me nuts, posted it elsewhere, so far no > one's been able to help. I am running Python 3.6.1 from Anaconda (all > packages updated to latest and greatest) on Windows 7. ipython and mpl > figure windows work fine from a console, or spyder. The problem is when I > try running ipython within emacs using elpy. > > > > > > > > To back up, the workflow I'm shooting for is using emacs as my IDE, and > running python within emacs. I've done this for many years with the Yorick > interpreter, and it's quite addictive. I get the same problem whether I > use the GNU windows build of emacs, or emacs -nw (terminal, no X) from > cygwin (ver 25.2 both cases). elpy seems to be a good Python package for > emacs, and nominally supports using ipython. > > > > > > > > OK, so - I can use ipython + emacs + elpy. The only problem is > matplotlib figures. When I do figure(), a figure window appears, but is > not fully rendered (e.g. no buttons), and the window title says "Not > responding". If I do a plot(), nothing is plotted. Playing with ion() and > show() doesn't help. > > > > > > > > I've posted this on the elpy github, various stackexchange forums, no > one has had any ideas yet. > > > > > > > > Any help is greatly appreciated! > > > > Dave > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From strozzi2 at llnl.gov Mon Oct 9 14:14:21 2017 From: strozzi2 at llnl.gov (Strozzi, David J.) Date: Mon, 9 Oct 2017 18:14:21 +0000 Subject: [Matplotlib-users] Windows7: figure window "not responding" In-Reply-To: References: <87tvz8b6u3.fsf@dell-desktop.WORKGROUP> Message-ID: Haven?t roped in ipython devs yet, maybe I should. Everything works as expected outside of emacs, either an ipython prompt from a console, or running Spyder GUI. Ipython works fine inside emacs, as long as I don?t do any matplotlib. Emacs version: GNU Emacs 25.2.1 (x86_64-w64-mingw32) of 2017-04-24 ipython: 6.1.0 with python 3.6.2, Matplotlib 2.0.2, all from Conda. I updated within the last few weeks. I am happy to update anything, change backend, etc. if it fixes the problem. Thanks! From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: Monday, October 09, 2017 10:21 AM To: Strozzi, David J. Cc: thibault.marin.us at ieee.org; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" Just some thoughts... have you roped in any ipython devs into this discussion? Can you confirm that doing similar things, but outside of emacs, works as expected? Can you confirm that just simply using ipython within emacs, but without matplotlib, also works as expected? Also, now that I think of it, could you also re-confirm exactly which versions of matplotlib, emacs, and ipython you are using, and where your matplotlib and ipython were installed from? Just trying to narrow down the possible sources of issues. Cheers! Ben Root On Mon, Oct 9, 2017 at 1:07 PM, Strozzi, David J. > wrote: Hi, Thanks, I did get this response, but consider it too 'convoluted' or 'non-standard'. I think this workflow of running ipython inside emacs should "just work" with some set of standard tools, like elpy + ipython + matplotlib, and not need one to "roll their own". Of course Windows may be a pretty non-standard misfit but such is life! Dave -----Original Message----- From: Thibault Marin [mailto:thibault.marin.us at ieee.org] Sent: Monday, October 09, 2017 9:54 AM To: Strozzi, David J. > Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" Hi, I thought I replied to that, but I probably failed for some reason. Here is my (slightly edited) reply, I hope it helps. ---- Hi, Sorry for breaking the thread, I have just subscribed to the list and I don't know how to respond to a message that predates my subscription. I hope this messages makes its way. I believe I have a similar setup (Windows + emacs + Qt5Agg, python 3.5 and matplotlib 2+). I also see freezes when starting ipython from within emacs. The way I work around that is by using org-mode and ob-ipython (https://github.com/gregsexton/ob-ipython). To work with matplotlib, I do the following: 1 - Open my org file, which starts with something like: ,---- | #+PROPERTY: header-args :eval no-export :session Python | | #+NAME: py-startup-0 | #+BEGIN_SRC ipython :results silent :exports none # %% Standard | imports # General import os import sys import re import matplotlib as | mpl | mpl.use('Qt5Agg') | #+END_SRC `---- 2 - Execute the source block (move point at the beginning of the "BEGIN_SRC line" and C-c C-c) I then get a warning about the interpreter which I ignore. Note that it sometimes hangs at that point, in which case I use C-g. 3 - The *Python* buffer then contains the ipython session, in which I can use matplotlib: I get not freezes and calls do not block the ipython instance. Note that I have to run `plt.ion()` once to get matplotlib figures to show up. Important note: I often get an error on the first command I type in the *Python* shell, so I typically go to the *Python* buffer, press enter and ignore the error I may get (I am guessing some line return is missing in some previous command sent during the setup). 4 - I usually write most of my code in org-mode anyway, but after running the source block I can open any .py file and work with it ignoring the org-mode part. For completeness, my emacs init file contains the following: ,---- | (when (eq system-type 'windows-nt) | (progn | (setq python-shell-interpreter-args "--simple-prompt -i") | (setq ob-ipython-command "ipython"))) `---- I hope this helps. thibault Strozzi, David J. writes: > Hope this appears in the thread. I still haven?t solved this issue, trying to bump this to the top of someone?s stack. No one responded to this message. > > Any help appreciated. Thanks. > > Dave > > From: Matplotlib-users [mailto:matplotlib-users-bounces+strozzi2=llnl.gov at python.org] On Behalf Of Strozzi, David J. > Sent: Monday, August 28, 2017 1:48 PM > To: Thomas Caswell >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > Sorry for the delay. Life, work, etc. intervene. I tried tk backend, failed but in a different way. Seems to get ?farther? in that I can get a plot to render. > > * Versions (all very recent from Anaconda): Python: 3.6.2 ipython: > 6.1.0 matplotlib: 2.0.2 > > * My emacs startup has (elpy-use-ipython). > > * With backend ?TkAgg?: > > plt.ion() > figure(1) --> window appears, with buttons on bottom (doesn?t happen with ?Qt5Agg? backend. ipyton prompt works. But, if I try interacting with the figure window, I get ?not responding? in title, and windows? spinning shell. If I close the figure window by clicking on the X in upper right, windows says ?app not responding.? Dialog box w/ End Process or Cancel. End process kills figure and ipython session. > > plt.ioff() instead: > figure(1) > plot(1,1) > show() > I get a figure window with a plot, but if I interact with it I get ?not responding.? ipython prompt seems fine. I can close window from prompt close(1) and ipython fine. > > Help appreciated! I hopefully won?t wait so long to respond. > > Thanks, > Dave > > > From: Thomas Caswell [mailto:tcaswell at gmail.com] > Sent: Saturday, August 19, 2017 2:32 PM > To: Strozzi, David J. >>; > matplotlib-users at python.org> > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > That is at least all consistent! The issue as that for what ever reason the input hook is not being set up correctly (which is what lets the GUI event loop spin and process events while the terminal waits for you to type). With `plt.ion()` the terminal is blocking the process waiting for you to type (which is why the window is not responding), with `plt.ioff()` when you do `plt.show()` the GUI event loop is blocking the process (which is why it works, but you don't get the next prompt back until you close the plot window). Again, see https://github.com/matplotlib/matplotlib/pull/4779 for a longer pass at explaining how this all works (and I would appreciate feed back about where it does not make sense!). > > Try using `tkagg` as the backend, the integration between python and tk in a bit tighter (because it is done in the cpython source). > > Which version of IPython and matplotlib are you using (and are you sure that elpy is using the versions you think it is?)? > > are you using `(elpy-use-ipython)` or just hacking the python executable path? > > You are siting at a very interesting intersection of technology here (emacs + python + GUI + windows). It might make sense to ask either on the elpy mailing list or the ipython mailing list. > > Tom > > On Sat, Aug 19, 2017 at 3:28 PM Strozzi, David J. >> wrote: > Hi, > > * Just subscribed to list. > > * Backend: mpl.get_backend() = ?Qt5Agg?. I am not committed to this if another one will work. > > * ?If you get up a window:? I start ipython within emacs (the GNU win32 build, not cygwin), and do figure(1), a figure window appears, but nothing renders, and window title bar says ?Not responding.? If I plot something, it doesn?t appear. > > fig is not defined, by default. I can do fig=gcf(). Then fig.canvas.flush_events() has an interesting effect ? the plot appears, but then window title still says ?not responding? and when I hover the mouse over the figure window it becomes Windows? spinning blue circle (the busy symbol, like Mac?s spinning beachball). > > ?control? is returned to ipython. I can continue to execute commands there. > > * At this point, plt.ioff() doesn?t seem to do anything. plt.show() does ? ?not responding? disappears, the figure window works like normal. Buttons on it work. But the ipython window is ?frozen? no In[] prompt. > > OK so this seems like a lot of information. Maybe we can make progress? > > Dave > > > From: Thomas Caswell > [mailto:tcaswell at gmail.com>] > Sent: Saturday, August 19, 2017 10:54 AM > > To: Strozzi, David J. >>; > matplotlib-users at python.org> > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > David, > > Please subscribe to the mailing list so you can post un-moderated. > > Which backend are you using? > > If you get a window up and then do `fig.canvas.flush_events()` will it update? > > If you do `plt.ioff()` and then `plt.show()` does it work? > > Tom > > > On Sat, Aug 19, 2017 at 12:40 PM Strozzi, David J. >> wrote: > Thanks for the respone. Sadly, I can?t get anything useful out of the doc. And %matplotlib doesn?t help, same effect. > > This is very frustrating. I don?t know how to debug this. It?s just a ?black box?, I do what I?m ?supposed to?, doesn?t work. > > Help appreciated! > Dave > > From: Thomas Caswell > [mailto:tcaswell at gmail.com>] > Sent: Saturday, August 05, 2017 10:36 AM > To: Strozzi, David J. >>; > matplotlib-users at python.org> > Subject: Re: [Matplotlib-users] Windows7: figure window "not responding" > > I do exactly this as well (but on linux)! > > The symptoms your are describing sounds like the GUI event loop is not being spun behind the scenes (see https://github.com/matplotlib/matplotlib/pull/4779 for some draft text at explaining how all of that works). Have you tried doing `%matplotlib` is IPython? > > Tom > > On Sat, Aug 5, 2017 at 12:39 PM Strozzi, David J. >> wrote: > > This problem has been driving me nuts, posted it elsewhere, so far no one's been able to help. I am running Python 3.6.1 from Anaconda (all packages updated to latest and greatest) on Windows 7. ipython and mpl figure windows work fine from a console, or spyder. The problem is when I try running ipython within emacs using elpy. > > > > To back up, the workflow I'm shooting for is using emacs as my IDE, and running python within emacs. I've done this for many years with the Yorick interpreter, and it's quite addictive. I get the same problem whether I use the GNU windows build of emacs, or emacs -nw (terminal, no X) from cygwin (ver 25.2 both cases). elpy seems to be a good Python package for emacs, and nominally supports using ipython. > > > > OK, so - I can use ipython + emacs + elpy. The only problem is matplotlib figures. When I do figure(), a figure window appears, but is not fully rendered (e.g. no buttons), and the window title says "Not responding". If I do a plot(), nothing is plotted. Playing with ion() and show() doesn't help. > > > > I've posted this on the elpy github, various stackexchange forums, no one has had any ideas yet. > > > > Any help is greatly appreciated! > > Dave > _______________________________________________ > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From maurobio at gmail.com Mon Oct 9 19:54:40 2017 From: maurobio at gmail.com (Mauro Cavalcanti) Date: Mon, 9 Oct 2017 20:54:40 -0300 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: Hi, Thanks for you reply and suggestions. I changed the imshow call to: im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, lon_sup, lat_sup), aspect='auto', interpolation='none') However, the figure is stil wrong (see attachment). Maybe if instead of imshow, should I use meshgrid/pcolormesh? Best regards, 2017-10-09 11:29 GMT-03:00 Benjamin Root : > First, you shouldn't need to transpose your image... that'll effectively > rotate the data by 90 degrees. Second, you didn't specify the extents of > your image, so Basemap is putting everything starting at coordinate 0,0 in > the default projection. > > If you specify the extent keyword argument to imshow as the (lon1, lat1, > lon2, lat2) tuple for the lower-left and upper right corners, you won't > even need the origin='lower', and you definitely won't need the transpose. > > Cheers! > Ben Root > > > On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti > wrote: > >> Dear ALL, >> >> I have a simple dataset of longitudes/latitudes (see the attached csv >> file). >> >> From such data, I want to generate a grid like this: >> >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 1 0 0 0 0 0 0 >> 0 0 0 0 0 0 1 1 2 0 0 0 0 >> 0 0 0 0 0 1 1 1 1 0 0 0 0 >> 0 0 0 1 0 1 0 0 0 0 0 0 0 >> 0 0 0 2 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 1 3 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 1 0 0 0 >> 0 0 0 0 0 0 0 0 0 1 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 1 0 0 >> 0 0 0 0 0 0 0 0 0 0 1 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 >> >> which gives the number of data records in each cell of the grid, using >> one of the variables in the dataset ("spp") as a categorical (grouping) >> factor. >> >> From this grid, I then want to create a heat map, superimposed on a >> Matplotlib/Basemap. >> >> I wrote some code which does what I want (see the attachments). >> >> It (mostly) works, but te problem is that the grid image is not being >> displayed correctly: as shown in the attached figure, it appears too small, >> and in the lower left corner of the map, instead of where it should be (the >> West coast of Africa, along the Gulf of Guinea). >> >> Thanks in advance for any assistance you can provide. >> >> Best regards, >> >> -- >> Dr. Mauro J. Cavalcanti >> E-mail: maurobio at gmail.com >> Web: http://sites.google.com/site/maurobio >> "Life is complex. It consists of real and imaginary parts." >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > -- Dr. Mauro J. Cavalcanti E-mail: maurobio at gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Figure_1.png Type: image/png Size: 47105 bytes Desc: not available URL: From Stuart_Mentzer at objexx.com Mon Oct 9 23:32:02 2017 From: Stuart_Mentzer at objexx.com (Stuart Mentzer) Date: Mon, 9 Oct 2017 20:32:02 -0700 (MST) Subject: [Matplotlib-users] Unzoom problem in 2.1.0 Message-ID: <1507606322709-0.post@n5.nabble.com> Hello, I have a Pyside application (using Qt4Agg backend) that does line and spectral/contour plots. After updating to 2.1.0 "unzooming" via the back toolbar button or right-click won't always return to the "home" view. It is not consistent but the problem appears regularly. It is as though the zoom stack is losing entries off the end. My attempts to reproduce this in a small (non-Pyside) pyplot example that I could submit as a bug haven't been successful yet. I'm wondering if anyone else is seeing this or has an idea on how best to isolate the problem. Thanks, Stuart -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From a.h.jaffe at gmail.com Tue Oct 10 10:40:00 2017 From: a.h.jaffe at gmail.com (Andrew Jaffe) Date: Tue, 10 Oct 2017 15:40:00 +0100 Subject: [Matplotlib-users] ax.bar edgecolor fails for scalar color? Message-ID: Hi, I've been working through Ben Root's excellent Anatomy of Matplotlib tutorial at https://github.com/matplotlib/AnatomyOfMatplotlib/. In the course of this (exercise 2.1 in particular), I've noticed that the `edgecolor` argument to `ax.bar(...)` doesn't work as advertised: > edgecolor : scalar or array-like, optional > the colors of the bar edges However, it doesn't seem to work as a scalar: in that case it only applies to the first bar; instead you need to supply `(color,)*len(x)` or similar. It fails the same way whether or not we use something like `plt.style.use('classic')` or `mpl.rcParams['patch.force_edgecolor'] = True` Is this a bug, something weird in my setup, or am I missing something? Andrew From ben.v.root at gmail.com Tue Oct 10 10:50:15 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 10:50:15 -0400 Subject: [Matplotlib-users] ax.bar edgecolor fails for scalar color? In-Reply-To: References: Message-ID: Yeah, I think we ran into that during the live tutorial. IIRC, the `color` keyword argument was overriding the `edgecolor` keyword argument. On Tue, Oct 10, 2017 at 10:40 AM, Andrew Jaffe wrote: > Hi, > > I've been working through Ben Root's excellent Anatomy of Matplotlib > tutorial at https://github.com/matplotlib/AnatomyOfMatplotlib/. > > In the course of this (exercise 2.1 in particular), I've noticed that the > `edgecolor` argument to `ax.bar(...)` doesn't work as advertised: > > > edgecolor : scalar or array-like, optional > > the colors of the bar edges > > However, it doesn't seem to work as a scalar: in that case it only applies > to the first bar; instead you need to supply `(color,)*len(x)` or similar. > > It fails the same way whether or not we use something like > `plt.style.use('classic')` or `mpl.rcParams['patch.force_edgecolor'] = > True` > > Is this a bug, something weird in my setup, or am I missing something? > > Andrew > > _______________________________________________ > 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 Tue Oct 10 10:52:34 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 10:52:34 -0400 Subject: [Matplotlib-users] ax.bar edgecolor fails for scalar color? In-Reply-To: References: Message-ID: Actually, to be honest, I can't remember what the solution was. CC'ing Thomas because I think he figured it out later on during the tutorial. Ben On Tue, Oct 10, 2017 at 10:50 AM, Benjamin Root wrote: > Yeah, I think we ran into that during the live tutorial. IIRC, the `color` > keyword argument was overriding the `edgecolor` keyword argument. > > On Tue, Oct 10, 2017 at 10:40 AM, Andrew Jaffe > wrote: > >> Hi, >> >> I've been working through Ben Root's excellent Anatomy of Matplotlib >> tutorial at https://github.com/matplotlib/AnatomyOfMatplotlib/. >> >> In the course of this (exercise 2.1 in particular), I've noticed that the >> `edgecolor` argument to `ax.bar(...)` doesn't work as advertised: >> >> > edgecolor : scalar or array-like, optional >> > the colors of the bar edges >> >> However, it doesn't seem to work as a scalar: in that case it only >> applies to the first bar; instead you need to supply `(color,)*len(x)` or >> similar. >> >> It fails the same way whether or not we use something like >> `plt.style.use('classic')` or `mpl.rcParams['patch.force_edgecolor'] = >> True` >> >> Is this a bug, something weird in my setup, or am I missing something? >> >> Andrew >> >> _______________________________________________ >> 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 Tue Oct 10 11:02:32 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 11:02:32 -0400 Subject: [Matplotlib-users] Unzoom problem in 2.1.0 In-Reply-To: <1507606322709-0.post@n5.nabble.com> References: <1507606322709-0.post@n5.nabble.com> Message-ID: Stuart, right clicks? Did you add a callback for handling right-clicks? I don't think matplotlib does anything (unless you are talking about using the right mouse button to create an "unzoom" box?) Ben Root On Mon, Oct 9, 2017 at 11:32 PM, Stuart Mentzer wrote: > Hello, > > I have a Pyside application (using Qt4Agg backend) that does line and > spectral/contour plots. > After updating to 2.1.0 "unzooming" via the back toolbar button or > right-click won't always > return to the "home" view. It is not consistent but the problem appears > regularly. It is as > though the zoom stack is losing entries off the end. > > My attempts to reproduce this in a small (non-Pyside) pyplot example that I > could submit > as a bug haven't been successful yet. I'm wondering if anyone else is > seeing > this or has an > idea on how best to isolate the problem. > > Thanks, > Stuart > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > 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 Tue Oct 10 11:20:04 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 11:20:04 -0400 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: Ah, the problem was that by default, the limits for a Basemap goes from -180 to 180, and -90 to 90. If you do: m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, urcrnrlon=lon_sup) Then things line up correctly, and you don't need the origin keyword argument, the transpose, or even the extent argument. In fact, there might even be a bug, as I would have expected specifying the extent should have worked regardless of the original bounds. Might need to look into that. Cheers! Ben Root On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti wrote: > Hi, > > Thanks for you reply and suggestions. > > I changed the imshow call to: > > im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, > lon_sup, lat_sup), aspect='auto', interpolation='none') > > However, the figure is stil wrong (see attachment). > > Maybe if instead of imshow, should I use meshgrid/pcolormesh? > > Best regards, > > 2017-10-09 11:29 GMT-03:00 Benjamin Root : > >> First, you shouldn't need to transpose your image... that'll effectively >> rotate the data by 90 degrees. Second, you didn't specify the extents of >> your image, so Basemap is putting everything starting at coordinate 0,0 in >> the default projection. >> >> If you specify the extent keyword argument to imshow as the (lon1, lat1, >> lon2, lat2) tuple for the lower-left and upper right corners, you won't >> even need the origin='lower', and you definitely won't need the transpose. >> >> Cheers! >> Ben Root >> >> >> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti >> wrote: >> >>> Dear ALL, >>> >>> I have a simple dataset of longitudes/latitudes (see the attached csv >>> file). >>> >>> From such data, I want to generate a grid like this: >>> >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 1 0 0 0 0 0 0 >>> 0 0 0 0 0 0 1 1 2 0 0 0 0 >>> 0 0 0 0 0 1 1 1 1 0 0 0 0 >>> 0 0 0 1 0 1 0 0 0 0 0 0 0 >>> 0 0 0 2 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 1 3 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>> >>> which gives the number of data records in each cell of the grid, using >>> one of the variables in the dataset ("spp") as a categorical (grouping) >>> factor. >>> >>> From this grid, I then want to create a heat map, superimposed on a >>> Matplotlib/Basemap. >>> >>> I wrote some code which does what I want (see the attachments). >>> >>> It (mostly) works, but te problem is that the grid image is not being >>> displayed correctly: as shown in the attached figure, it appears too small, >>> and in the lower left corner of the map, instead of where it should be (the >>> West coast of Africa, along the Gulf of Guinea). >>> >>> Thanks in advance for any assistance you can provide. >>> >>> Best regards, >>> >>> -- >>> Dr. Mauro J. Cavalcanti >>> E-mail: maurobio at gmail.com >>> Web: http://sites.google.com/site/maurobio >>> "Life is complex. It consists of real and imaginary parts." >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >>> >> > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.francis.corcoran at gmail.com Tue Oct 10 14:08:50 2017 From: michael.francis.corcoran at gmail.com (mfacorcoran) Date: Tue, 10 Oct 2017 11:08:50 -0700 (MST) Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 Message-ID: <1507658930741-0.post@n5.nabble.com> I've recently updated matplotlib to 2.1.0 and now when I try to import matplotlib/pylab I get the following error that cbook cannot be imported: % python Python 2.7.14 (default, Sep 22 2017, 00:05:22) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin Type "help", "copyright", "credits" or "license" for more information. Importing pyfits Could not import pylab Traceback (most recent call last): File "/Users/corcoran/.pythonrc", line 34, in import matplotlib File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in from . import cbook ImportError: cannot import name cbook any ideas what might be going on? Mike -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From pmhobson at gmail.com Tue Oct 10 14:12:00 2017 From: pmhobson at gmail.com (Paul Hobson) Date: Tue, 10 Oct 2017 11:12:00 -0700 Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: <1507658930741-0.post@n5.nabble.com> References: <1507658930741-0.post@n5.nabble.com> Message-ID: Were you in the matplotlib source directory when you launched your python interpreter? -p On Tue, Oct 10, 2017 at 11:08 AM, mfacorcoran < michael.francis.corcoran at gmail.com> wrote: > I've recently updated matplotlib to 2.1.0 and now when I try to import > matplotlib/pylab I get the following error that cbook cannot be imported: > > % python > Python 2.7.14 (default, Sep 22 2017, 00:05:22) > [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > Importing pyfits > Could not import pylab > Traceback (most recent call last): > File "/Users/corcoran/.pythonrc", line 34, in > import matplotlib > File > "/opt/local/Library/Frameworks/Python.framework/ > Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", > line 124, in > from . import cbook > ImportError: cannot import name cbook > > any ideas what might be going on? > > Mike > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > 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 michael.francis.corcoran at gmail.com Tue Oct 10 14:20:48 2017 From: michael.francis.corcoran at gmail.com (mfacorcoran) Date: Tue, 10 Oct 2017 11:20:48 -0700 (MST) Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: References: <1507658930741-0.post@n5.nabble.com> Message-ID: <1507659648138-0.post@n5.nabble.com> I don't think so. I re-tried it from my home directory and got the same error... cheers Mike -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From ben.v.root at gmail.com Tue Oct 10 14:41:07 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 14:41:07 -0400 Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: <1507659648138-0.post@n5.nabble.com> References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> Message-ID: How did you install matplotlib? On Tue, Oct 10, 2017 at 2:20 PM, mfacorcoran < michael.francis.corcoran at gmail.com> wrote: > I don't think so. I re-tried it from my home directory and got the same > error... > > cheers > > Mike > > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > 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 michael.francis.corcoran at gmail.com Tue Oct 10 14:49:49 2017 From: michael.francis.corcoran at gmail.com (mfacorcoran) Date: Tue, 10 Oct 2017 11:49:49 -0700 (MST) Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> Message-ID: <1507661389563-0.post@n5.nabble.com> using macports. I'm on a macbook pro running 10.11.6. I've used matplotlib for the past 2-3 years; this is the first time I had this issue -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From ben.v.root at gmail.com Tue Oct 10 14:52:26 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 14:52:26 -0400 Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: <1507661389563-0.post@n5.nabble.com> References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> <1507661389563-0.post@n5.nabble.com> Message-ID: Then exactly which version of the matplotlib package did you install from MacPorts? Just today, we had another bug report from another user using MacPorts and python 2.7 that turned out to be a packaging error on their part. On Tue, Oct 10, 2017 at 2:49 PM, mfacorcoran < michael.francis.corcoran at gmail.com> wrote: > using macports. I'm on a macbook pro running 10.11.6. I've used > matplotlib > for the past 2-3 years; this is the first time I had this issue > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > 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 maurobio at gmail.com Tue Oct 10 14:57:01 2017 From: maurobio at gmail.com (Mauro Cavalcanti) Date: Tue, 10 Oct 2017 15:57:01 -0300 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: Dear Ben, Thanks a lot again for your help and patience. After modifying the call to Basemap according to your suggestion: m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, urcrnrlon=lon_sup) the grid is correctly displayed where it belongs (thr west coast of Africa). But now I got a map centered at the Pacific basin, with the grid appearing on the lower left corner of it! In fact, See the attached image. I would like a conventional map centered around the Atlantic basin (ie., with center coordinates at lat_0=0 and long_0=0). After using the superb Matplotlib for almost a decade (in the beginning, I even got some help here from the legendary John Hunter!), I nonetheless feel somewhat ashamed of having found a potential bug in the library... All the best, 2017-10-10 12:20 GMT-03:00 Benjamin Root : > Ah, the problem was that by default, the limits for a Basemap goes from > -180 to 180, and -90 to 90. If you do: > > m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, > urcrnrlat=lat_sup, urcrnrlon=lon_sup) > > Then things line up correctly, and you don't need the origin keyword > argument, the transpose, or even the extent argument. > > In fact, there might even be a bug, as I would have expected specifying > the extent should have worked regardless of the original bounds. Might need > to look into that. > > Cheers! > Ben Root > > > On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti > wrote: > >> Hi, >> >> Thanks for you reply and suggestions. >> >> I changed the imshow call to: >> >> im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, >> lon_sup, lat_sup), aspect='auto', interpolation='none') >> >> However, the figure is stil wrong (see attachment). >> >> Maybe if instead of imshow, should I use meshgrid/pcolormesh? >> >> Best regards, >> >> 2017-10-09 11:29 GMT-03:00 Benjamin Root : >> >>> First, you shouldn't need to transpose your image... that'll effectively >>> rotate the data by 90 degrees. Second, you didn't specify the extents of >>> your image, so Basemap is putting everything starting at coordinate 0,0 in >>> the default projection. >>> >>> If you specify the extent keyword argument to imshow as the (lon1, lat1, >>> lon2, lat2) tuple for the lower-left and upper right corners, you won't >>> even need the origin='lower', and you definitely won't need the transpose. >>> >>> Cheers! >>> Ben Root >>> >>> >>> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti >>> wrote: >>> >>>> Dear ALL, >>>> >>>> I have a simple dataset of longitudes/latitudes (see the attached csv >>>> file). >>>> >>>> From such data, I want to generate a grid like this: >>>> >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 1 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 1 1 2 0 0 0 0 >>>> 0 0 0 0 0 1 1 1 1 0 0 0 0 >>>> 0 0 0 1 0 1 0 0 0 0 0 0 0 >>>> 0 0 0 2 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 1 3 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>> >>>> which gives the number of data records in each cell of the grid, using >>>> one of the variables in the dataset ("spp") as a categorical (grouping) >>>> factor. >>>> >>>> From this grid, I then want to create a heat map, superimposed on a >>>> Matplotlib/Basemap. >>>> >>>> I wrote some code which does what I want (see the attachments). >>>> >>>> It (mostly) works, but te problem is that the grid image is not being >>>> displayed correctly: as shown in the attached figure, it appears too small, >>>> and in the lower left corner of the map, instead of where it should be (the >>>> West coast of Africa, along the Gulf of Guinea). >>>> >>>> Thanks in advance for any assistance you can provide. >>>> >>>> Best regards, >>>> >>>> -- >>>> Dr. Mauro J. Cavalcanti >>>> E-mail: maurobio at gmail.com >>>> Web: http://sites.google.com/site/maurobio >>>> "Life is complex. It consists of real and imaginary parts." >>>> >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Matplotlib-users at python.org >>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>> >>>> >>> >> >> >> -- >> Dr. Mauro J. Cavalcanti >> E-mail: maurobio at gmail.com >> Web: http://sites.google.com/site/maurobio >> "Life is complex. It consists of real and imaginary parts." >> > > -- Dr. Mauro J. Cavalcanti E-mail: maurobio at gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Figure_1.png Type: image/png Size: 69775 bytes Desc: not available URL: From michael.francis.corcoran at gmail.com Tue Oct 10 15:06:44 2017 From: michael.francis.corcoran at gmail.com (mfacorcoran) Date: Tue, 10 Oct 2017 12:06:44 -0700 (MST) Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> <1507661389563-0.post@n5.nabble.com> Message-ID: <1507662404822-0.post@n5.nabble.com> This is the python 2.7 version: py27-matplotlib 2.1.0 I also checked the python3 version - that seems to work ok (btw) -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From ben.v.root at gmail.com Tue Oct 10 16:25:12 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 16:25:12 -0400 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: So, the problem here is that what you are asking for is in conflict with the settings. You are giving bounding box that starts at llcrnrlon=lon_inf and goes to urcrnrlon=lon_sup, and that is the extent of the data you are providing, too. But you want to view it in a different bounds. It is possible to get what you want, but it starts to get tricky at this point. Before venturing further, I should point out to you that Basemap is effectively deprecated. Its support will be terminated in 2020. The CartoPy project, also built on top of matplotlib, is a far superior library, and I think would be much easier for you to use. It doesn't do everything that basemap does yet, but the things that it does do, it does better. I suggest checking it out before we go any further here. Cheers! Ben Root On Tue, Oct 10, 2017 at 2:57 PM, Mauro Cavalcanti wrote: > Dear Ben, > > Thanks a lot again for your help and patience. > > After modifying the call to Basemap according to your suggestion: > > m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, > urcrnrlon=lon_sup) > > the grid is correctly displayed where it belongs (thr west coast of > Africa). But now I got a map centered at the Pacific basin, with the grid > appearing on the lower left corner of it! In fact, See the attached image. > I would like a conventional map centered around the Atlantic basin (ie., > with center coordinates at lat_0=0 and long_0=0). > > After using the superb Matplotlib for almost a decade (in the beginning, I > even got some help here from the legendary John Hunter!), I nonetheless > feel somewhat ashamed of having found a potential bug in the library... > > All the best, > > 2017-10-10 12:20 GMT-03:00 Benjamin Root : > >> Ah, the problem was that by default, the limits for a Basemap goes from >> -180 to 180, and -90 to 90. If you do: >> >> m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, >> urcrnrlat=lat_sup, urcrnrlon=lon_sup) >> >> Then things line up correctly, and you don't need the origin keyword >> argument, the transpose, or even the extent argument. >> >> In fact, there might even be a bug, as I would have expected specifying >> the extent should have worked regardless of the original bounds. Might need >> to look into that. >> >> Cheers! >> Ben Root >> >> >> On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti >> wrote: >> >>> Hi, >>> >>> Thanks for you reply and suggestions. >>> >>> I changed the imshow call to: >>> >>> im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, >>> lon_sup, lat_sup), aspect='auto', interpolation='none') >>> >>> However, the figure is stil wrong (see attachment). >>> >>> Maybe if instead of imshow, should I use meshgrid/pcolormesh? >>> >>> Best regards, >>> >>> 2017-10-09 11:29 GMT-03:00 Benjamin Root : >>> >>>> First, you shouldn't need to transpose your image... that'll >>>> effectively rotate the data by 90 degrees. Second, you didn't specify the >>>> extents of your image, so Basemap is putting everything starting at >>>> coordinate 0,0 in the default projection. >>>> >>>> If you specify the extent keyword argument to imshow as the (lon1, >>>> lat1, lon2, lat2) tuple for the lower-left and upper right corners, you >>>> won't even need the origin='lower', and you definitely won't need the >>>> transpose. >>>> >>>> Cheers! >>>> Ben Root >>>> >>>> >>>> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti >>>> wrote: >>>> >>>>> Dear ALL, >>>>> >>>>> I have a simple dataset of longitudes/latitudes (see the attached csv >>>>> file). >>>>> >>>>> From such data, I want to generate a grid like this: >>>>> >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 1 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 1 1 2 0 0 0 0 >>>>> 0 0 0 0 0 1 1 1 1 0 0 0 0 >>>>> 0 0 0 1 0 1 0 0 0 0 0 0 0 >>>>> 0 0 0 2 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 1 3 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>> >>>>> which gives the number of data records in each cell of the grid, using >>>>> one of the variables in the dataset ("spp") as a categorical (grouping) >>>>> factor. >>>>> >>>>> From this grid, I then want to create a heat map, superimposed on a >>>>> Matplotlib/Basemap. >>>>> >>>>> I wrote some code which does what I want (see the attachments). >>>>> >>>>> It (mostly) works, but te problem is that the grid image is not being >>>>> displayed correctly: as shown in the attached figure, it appears too small, >>>>> and in the lower left corner of the map, instead of where it should be (the >>>>> West coast of Africa, along the Gulf of Guinea). >>>>> >>>>> Thanks in advance for any assistance you can provide. >>>>> >>>>> Best regards, >>>>> >>>>> -- >>>>> Dr. Mauro J. Cavalcanti >>>>> E-mail: maurobio at gmail.com >>>>> Web: http://sites.google.com/site/maurobio >>>>> "Life is complex. It consists of real and imaginary parts." >>>>> >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Matplotlib-users at python.org >>>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>>> >>>>> >>>> >>> >>> >>> -- >>> Dr. Mauro J. Cavalcanti >>> E-mail: maurobio at gmail.com >>> Web: http://sites.google.com/site/maurobio >>> "Life is complex. It consists of real and imaginary parts." >>> >> >> > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Tue Oct 10 16:28:18 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 10 Oct 2017 16:28:18 -0400 Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: <1507662404822-0.post@n5.nabble.com> References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> <1507661389563-0.post@n5.nabble.com> <1507662404822-0.post@n5.nabble.com> Message-ID: Check to see if you have the latest package from macports, the version the other user had was 2.1.0_1, which indicates that there was at least a bugfix in their packaging. That _1 release did have another bug, where the backports package wasn't specified as a dependency in py27. Ben Root On Tue, Oct 10, 2017 at 3:06 PM, mfacorcoran < michael.francis.corcoran at gmail.com> wrote: > This is the python 2.7 version: py27-matplotlib 2.1.0 > > I also checked the python3 version - that seems to work ok (btw) > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > 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 michael.francis.corcoran at gmail.com Tue Oct 10 16:40:15 2017 From: michael.francis.corcoran at gmail.com (mfacorcoran) Date: Tue, 10 Oct 2017 13:40:15 -0700 (MST) Subject: [Matplotlib-users] can't import cbook/matplotlib v. 2.1.0 In-Reply-To: References: <1507658930741-0.post@n5.nabble.com> <1507659648138-0.post@n5.nabble.com> <1507661389563-0.post@n5.nabble.com> <1507662404822-0.post@n5.nabble.com> Message-ID: <1507668015883-0.post@n5.nabble.com> I have py27-matplotlib @2.1.0_1+cairo+tkinter (active) installed I just went back to the 2.0.2 version via: % sudo port activate py27-matplotlib @2.0.2_0+cairo+tkinter and that seems to have resolved the issue. So it looks like there's something strange with the port of py27-matplotlib @2.1.0_1+cairo+tkinter Mike -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From maurobio at gmail.com Tue Oct 10 19:04:17 2017 From: maurobio at gmail.com (Mauro Cavalcanti) Date: Tue, 10 Oct 2017 20:04:17 -0300 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: Dear Ben, Sure, I am aware of Cartopy and have been following its development. However, I am afraid it is not yet mature enough for the kind of application I have been working on (a PyQt-based multiplatform desktop application for mapping biodiversity data). Documentation is also not as good as that already available for Matplotlib/Basemap. But I surely intend to take the time to eventually port my application to Cartopy! That said, I will be very grateful if you can help me with the 'tricky' part of my problem. I have also another test version using meshgrid instead of imshow. It looks promising because only the gridded data is displayed on the map (while imshow covers the whole map). However, as the attached image show, I have to fiddle with the grid limits when creating the mesh, and even so the grid is not yet plotted in the correct position. With warmest regards, 2017-10-10 17:25 GMT-03:00 Benjamin Root : > So, the problem here is that what you are asking for is in conflict with > the settings. You are giving bounding box that starts at llcrnrlon=lon_inf > and goes to urcrnrlon=lon_sup, and that is the extent of the data you are > providing, too. But you want to view it in a different bounds. It is > possible to get what you want, but it starts to get tricky at this point. > > Before venturing further, I should point out to you that Basemap is > effectively deprecated. Its support will be terminated in 2020. The CartoPy > project, also built on top of matplotlib, is a far superior library, and I > think would be much easier for you to use. It doesn't do everything that > basemap does yet, but the things that it does do, it does better. I suggest > checking it out before we go any further here. > > Cheers! > Ben Root > > > On Tue, Oct 10, 2017 at 2:57 PM, Mauro Cavalcanti > wrote: > >> Dear Ben, >> >> Thanks a lot again for your help and patience. >> >> After modifying the call to Basemap according to your suggestion: >> >> m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, >> urcrnrlon=lon_sup) >> >> the grid is correctly displayed where it belongs (thr west coast of >> Africa). But now I got a map centered at the Pacific basin, with the grid >> appearing on the lower left corner of it! In fact, See the attached image. >> I would like a conventional map centered around the Atlantic basin (ie., >> with center coordinates at lat_0=0 and long_0=0). >> >> After using the superb Matplotlib for almost a decade (in the beginning, >> I even got some help here from the legendary John Hunter!), I nonetheless >> feel somewhat ashamed of having found a potential bug in the library... >> >> All the best, >> >> 2017-10-10 12:20 GMT-03:00 Benjamin Root : >> >>> Ah, the problem was that by default, the limits for a Basemap goes from >>> -180 to 180, and -90 to 90. If you do: >>> >>> m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, >>> urcrnrlat=lat_sup, urcrnrlon=lon_sup) >>> >>> Then things line up correctly, and you don't need the origin keyword >>> argument, the transpose, or even the extent argument. >>> >>> In fact, there might even be a bug, as I would have expected specifying >>> the extent should have worked regardless of the original bounds. Might need >>> to look into that. >>> >>> Cheers! >>> Ben Root >>> >>> >>> On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti >>> wrote: >>> >>>> Hi, >>>> >>>> Thanks for you reply and suggestions. >>>> >>>> I changed the imshow call to: >>>> >>>> im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, >>>> lon_sup, lat_sup), aspect='auto', interpolation='none') >>>> >>>> However, the figure is stil wrong (see attachment). >>>> >>>> Maybe if instead of imshow, should I use meshgrid/pcolormesh? >>>> >>>> Best regards, >>>> >>>> 2017-10-09 11:29 GMT-03:00 Benjamin Root : >>>> >>>>> First, you shouldn't need to transpose your image... that'll >>>>> effectively rotate the data by 90 degrees. Second, you didn't specify the >>>>> extents of your image, so Basemap is putting everything starting at >>>>> coordinate 0,0 in the default projection. >>>>> >>>>> If you specify the extent keyword argument to imshow as the (lon1, >>>>> lat1, lon2, lat2) tuple for the lower-left and upper right corners, you >>>>> won't even need the origin='lower', and you definitely won't need the >>>>> transpose. >>>>> >>>>> Cheers! >>>>> Ben Root >>>>> >>>>> >>>>> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti >>>>> wrote: >>>>> >>>>>> Dear ALL, >>>>>> >>>>>> I have a simple dataset of longitudes/latitudes (see the attached csv >>>>>> file). >>>>>> >>>>>> From such data, I want to generate a grid like this: >>>>>> >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 1 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 1 1 2 0 0 0 0 >>>>>> 0 0 0 0 0 1 1 1 1 0 0 0 0 >>>>>> 0 0 0 1 0 1 0 0 0 0 0 0 0 >>>>>> 0 0 0 2 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 1 3 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>> >>>>>> which gives the number of data records in each cell of the grid, >>>>>> using one of the variables in the dataset ("spp") as a categorical >>>>>> (grouping) factor. >>>>>> >>>>>> From this grid, I then want to create a heat map, superimposed on a >>>>>> Matplotlib/Basemap. >>>>>> >>>>>> I wrote some code which does what I want (see the attachments). >>>>>> >>>>>> It (mostly) works, but te problem is that the grid image is not being >>>>>> displayed correctly: as shown in the attached figure, it appears too small, >>>>>> and in the lower left corner of the map, instead of where it should be (the >>>>>> West coast of Africa, along the Gulf of Guinea). >>>>>> >>>>>> Thanks in advance for any assistance you can provide. >>>>>> >>>>>> Best regards, >>>>>> >>>>>> -- >>>>>> Dr. Mauro J. Cavalcanti >>>>>> E-mail: maurobio at gmail.com >>>>>> Web: http://sites.google.com/site/maurobio >>>>>> "Life is complex. It consists of real and imaginary parts." >>>>>> >>>>>> _______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Matplotlib-users at python.org >>>>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> Dr. Mauro J. Cavalcanti >>>> E-mail: maurobio at gmail.com >>>> Web: http://sites.google.com/site/maurobio >>>> "Life is complex. It consists of real and imaginary parts." >>>> >>> >>> >> >> >> -- >> Dr. Mauro J. Cavalcanti >> E-mail: maurobio at gmail.com >> Web: http://sites.google.com/site/maurobio >> "Life is complex. It consists of real and imaginary parts." >> > > -- Dr. Mauro J. Cavalcanti E-mail: maurobio at gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- import csv import numpy as np from mpl_toolkits.basemap import Basemap from matplotlib import cm as cmap import matplotlib.pyplot as plt import warnings warnings.filterwarnings("ignore") #read input data with open('testdata.csv', 'r') as csvfile: reader = csv.reader(csvfile, delimiter=',') headers = reader.next() input_data = list(reader) #grid dimensions with one-degree resolution lat_inf, lon_inf = 0, 0 lat_sup, lon_sup = 90, 360 resolution = 1 latitude, longitude = [], [] latitude = range(lat_inf, lat_sup, resolution) longitude = range(lon_inf, lon_sup, resolution) #create output grid output_grid = [] for i in latitude: output_grid.append([]) for j in longitude: output_grid[i].append(0) #traverse the input_data evaluating the lat, lon coordinates #summing +1 in the output_grid[latitude][longitude]. for row in input_data: lat = int(row[2]) lon = int(row[3]) #sp = row[1] #check its indexes i_lat = latitude.index(lat) i_lon = longitude.index(lon) #increase counter output_grid[i_lat][i_lon] += 1 output_grid = np.array(output_grid, np.int16) lons,lats = np.meshgrid(np.linspace(1, 30, output_grid.shape[1]+1), np.linspace(2, 60, output_grid.shape[0]+1)) #create map m = Basemap() m.drawcoastlines(linewidth=0.25) X, Y = m(lons,lats) #display image pc = m.pcolormesh(X, Y, output_grid, cmap='summer') m.colorbar(pc) plt.show() -------------- next part -------------- A non-text attachment was scrubbed... Name: Figure_1.png Type: image/png Size: 15345 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: testdata.csv Type: text/csv Size: 277 bytes Desc: not available URL: From jklymak at uvic.ca Tue Oct 10 19:10:46 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Tue, 10 Oct 2017 16:10:46 -0700 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: I?m not 100% following, but can?t you just `np.roll` your data by N/2 to get it between -180 and +180 instead of 0 and 360, and set llcrnrlon=-180 and urcrnrlon=180? I didn?t test, so sorry if that is a dumb suggestion... Cheers, Jody > On 10 Oct 2017, at 16:04 PM, Mauro Cavalcanti wrote: > > Dear Ben, > > Sure, I am aware of Cartopy and have been following its development. However, I am afraid it is not yet mature enough for the kind of application I have been working on (a PyQt-based multiplatform desktop application for mapping biodiversity data). Documentation is also not as good as that already available for Matplotlib/Basemap. But I surely intend to take the time to eventually port my application to Cartopy! > > That said, I will be very grateful if you can help me with the 'tricky' part of my problem. I have also another test version using meshgrid instead of imshow. It looks promising because only the gridded data is displayed on the map (while imshow covers the whole map). However, as the attached image show, I have to fiddle with the grid limits when creating the mesh, and even so the grid is not yet plotted in the correct position. > > With warmest regards, > > 2017-10-10 17:25 GMT-03:00 Benjamin Root >: > So, the problem here is that what you are asking for is in conflict with the settings. You are giving bounding box that starts at llcrnrlon=lon_inf and goes to urcrnrlon=lon_sup, and that is the extent of the data you are providing, too. But you want to view it in a different bounds. It is possible to get what you want, but it starts to get tricky at this point. > > Before venturing further, I should point out to you that Basemap is effectively deprecated. Its support will be terminated in 2020. The CartoPy project, also built on top of matplotlib, is a far superior library, and I think would be much easier for you to use. It doesn't do everything that basemap does yet, but the things that it does do, it does better. I suggest checking it out before we go any further here. > > Cheers! > Ben Root > > > On Tue, Oct 10, 2017 at 2:57 PM, Mauro Cavalcanti > wrote: > Dear Ben, > > Thanks a lot again for your help and patience. > > After modifying the call to Basemap according to your suggestion: > > m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, urcrnrlon=lon_sup) > > the grid is correctly displayed where it belongs (thr west coast of Africa). But now I got a map centered at the Pacific basin, with the grid appearing on the lower left corner of it! In fact, See the attached image. I would like a conventional map centered around the Atlantic basin (ie., with center coordinates at lat_0=0 and long_0=0). > > After using the superb Matplotlib for almost a decade (in the beginning, I even got some help here from the legendary John Hunter!), I nonetheless feel somewhat ashamed of having found a potential bug in the library... > > All the best, > > 2017-10-10 12:20 GMT-03:00 Benjamin Root >: > Ah, the problem was that by default, the limits for a Basemap goes from -180 to 180, and -90 to 90. If you do: > > m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, > urcrnrlat=lat_sup, urcrnrlon=lon_sup) > > Then things line up correctly, and you don't need the origin keyword argument, the transpose, or even the extent argument. > > In fact, there might even be a bug, as I would have expected specifying the extent should have worked regardless of the original bounds. Might need to look into that. > > Cheers! > Ben Root > > > On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti > wrote: > Hi, > > Thanks for you reply and suggestions. > > I changed the imshow call to: > > im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, lon_sup, lat_sup), aspect='auto', interpolation='none') > > However, the figure is stil wrong (see attachment). > > Maybe if instead of imshow, should I use meshgrid/pcolormesh? > > Best regards, > > 2017-10-09 11:29 GMT-03:00 Benjamin Root >: > First, you shouldn't need to transpose your image... that'll effectively rotate the data by 90 degrees. Second, you didn't specify the extents of your image, so Basemap is putting everything starting at coordinate 0,0 in the default projection. > > If you specify the extent keyword argument to imshow as the (lon1, lat1, lon2, lat2) tuple for the lower-left and upper right corners, you won't even need the origin='lower', and you definitely won't need the transpose. > > Cheers! > Ben Root > > > On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti > wrote: > Dear ALL, > > I have a simple dataset of longitudes/latitudes (see the attached csv file). > > From such data, I want to generate a grid like this: > > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 1 0 0 0 0 0 0 > 0 0 0 0 0 0 1 1 2 0 0 0 0 > 0 0 0 0 0 1 1 1 1 0 0 0 0 > 0 0 0 1 0 1 0 0 0 0 0 0 0 > 0 0 0 2 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 1 3 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 1 0 0 0 > 0 0 0 0 0 0 0 0 0 1 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 1 0 0 > 0 0 0 0 0 0 0 0 0 0 1 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 > > which gives the number of data records in each cell of the grid, using one of the variables in the dataset ("spp") as a categorical (grouping) factor. > > From this grid, I then want to create a heat map, superimposed on a Matplotlib/Basemap. > > I wrote some code which does what I want (see the attachments). > > It (mostly) works, but te problem is that the grid image is not being displayed correctly: as shown in the attached figure, it appears too small, and in the lower left corner of the map, instead of where it should be (the West coast of Africa, along the Gulf of Guinea). > > Thanks in advance for any assistance you can provide. > > Best regards, > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > > > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > > > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From maurobio at gmail.com Tue Oct 10 19:43:13 2017 From: maurobio at gmail.com (Mauro Cavalcanti) Date: Tue, 10 Oct 2017 20:43:13 -0300 Subject: [Matplotlib-users] Problem using imshow with Matplotlib/Basemap In-Reply-To: References: Message-ID: Dear Jody, Thank you very much for your suggestion! It looks interesting and I will play with it. (By the way, I don't consider any suggestion here as "dumb" and value very much all of them.) All the best, 2017-10-10 20:10 GMT-03:00 Jody Klymak : > I?m not 100% following, but can?t you just `np.roll` your data by N/2 to > get it between -180 and +180 instead of 0 and 360, and set llcrnrlon=-180 > and urcrnrlon=180? > > I didn?t test, so sorry if that is a dumb suggestion... > > Cheers, Jody > > > > > > On 10 Oct 2017, at 16:04 PM, Mauro Cavalcanti wrote: > > Dear Ben, > > Sure, I am aware of Cartopy and have been following its development. > However, I am afraid it is not yet mature enough for the kind of > application I have been working on (a PyQt-based multiplatform desktop > application for mapping biodiversity data). Documentation is also not as > good as that already available for Matplotlib/Basemap. But I surely intend > to take the time to eventually port my application to Cartopy! > > That said, I will be very grateful if you can help me with the 'tricky' > part of my problem. I have also another test version using meshgrid instead > of imshow. It looks promising because only the gridded data is displayed on > the map (while imshow covers the whole map). However, as the attached image > show, I have to fiddle with the grid limits when creating the mesh, and > even so the grid is not yet plotted in the correct position. > > With warmest regards, > > 2017-10-10 17:25 GMT-03:00 Benjamin Root : > >> So, the problem here is that what you are asking for is in conflict with >> the settings. You are giving bounding box that starts at llcrnrlon=lon_inf >> and goes to urcrnrlon=lon_sup, and that is the extent of the data you are >> providing, too. But you want to view it in a different bounds. It is >> possible to get what you want, but it starts to get tricky at this point. >> >> Before venturing further, I should point out to you that Basemap is >> effectively deprecated. Its support will be terminated in 2020. The CartoPy >> project, also built on top of matplotlib, is a far superior library, and I >> think would be much easier for you to use. It doesn't do everything that >> basemap does yet, but the things that it does do, it does better. I suggest >> checking it out before we go any further here. >> >> Cheers! >> Ben Root >> >> >> On Tue, Oct 10, 2017 at 2:57 PM, Mauro Cavalcanti >> wrote: >> >>> Dear Ben, >>> >>> Thanks a lot again for your help and patience. >>> >>> After modifying the call to Basemap according to your suggestion: >>> >>> m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, urcrnrlat=lat_sup, >>> urcrnrlon=lon_sup) >>> >>> the grid is correctly displayed where it belongs (thr west coast of >>> Africa). But now I got a map centered at the Pacific basin, with the grid >>> appearing on the lower left corner of it! In fact, See the attached image. >>> I would like a conventional map centered around the Atlantic basin (ie., >>> with center coordinates at lat_0=0 and long_0=0). >>> >>> After using the superb Matplotlib for almost a decade (in the beginning, >>> I even got some help here from the legendary John Hunter!), I nonetheless >>> feel somewhat ashamed of having found a potential bug in the library... >>> >>> All the best, >>> >>> 2017-10-10 12:20 GMT-03:00 Benjamin Root : >>> >>>> Ah, the problem was that by default, the limits for a Basemap goes from >>>> -180 to 180, and -90 to 90. If you do: >>>> >>>> m = Basemap(llcrnrlat=lat_inf, llcrnrlon=lon_inf, >>>> urcrnrlat=lat_sup, urcrnrlon=lon_sup) >>>> >>>> Then things line up correctly, and you don't need the origin keyword >>>> argument, the transpose, or even the extent argument. >>>> >>>> In fact, there might even be a bug, as I would have expected specifying >>>> the extent should have worked regardless of the original bounds. Might need >>>> to look into that. >>>> >>>> Cheers! >>>> Ben Root >>>> >>>> >>>> On Mon, Oct 9, 2017 at 7:54 PM, Mauro Cavalcanti >>>> wrote: >>>> >>>>> Hi, >>>>> >>>>> Thanks for you reply and suggestions. >>>>> >>>>> I changed the imshow call to: >>>>> >>>>> im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf, >>>>> lon_sup, lat_sup), aspect='auto', interpolation='none') >>>>> >>>>> However, the figure is stil wrong (see attachment). >>>>> >>>>> Maybe if instead of imshow, should I use meshgrid/pcolormesh? >>>>> >>>>> Best regards, >>>>> >>>>> 2017-10-09 11:29 GMT-03:00 Benjamin Root : >>>>> >>>>>> First, you shouldn't need to transpose your image... that'll >>>>>> effectively rotate the data by 90 degrees. Second, you didn't specify the >>>>>> extents of your image, so Basemap is putting everything starting at >>>>>> coordinate 0,0 in the default projection. >>>>>> >>>>>> If you specify the extent keyword argument to imshow as the (lon1, >>>>>> lat1, lon2, lat2) tuple for the lower-left and upper right corners, you >>>>>> won't even need the origin='lower', and you definitely won't need the >>>>>> transpose. >>>>>> >>>>>> Cheers! >>>>>> Ben Root >>>>>> >>>>>> >>>>>> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti >>>>>> wrote: >>>>>> >>>>>>> Dear ALL, >>>>>>> >>>>>>> I have a simple dataset of longitudes/latitudes (see the attached >>>>>>> csv file). >>>>>>> >>>>>>> From such data, I want to generate a grid like this: >>>>>>> >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 1 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 1 1 2 0 0 0 0 >>>>>>> 0 0 0 0 0 1 1 1 1 0 0 0 0 >>>>>>> 0 0 0 1 0 1 0 0 0 0 0 0 0 >>>>>>> 0 0 0 2 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 1 3 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 1 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 1 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> 0 0 0 0 0 0 0 0 0 0 0 0 0 >>>>>>> >>>>>>> which gives the number of data records in each cell of the grid, >>>>>>> using one of the variables in the dataset ("spp") as a categorical >>>>>>> (grouping) factor. >>>>>>> >>>>>>> From this grid, I then want to create a heat map, superimposed on a >>>>>>> Matplotlib/Basemap. >>>>>>> >>>>>>> I wrote some code which does what I want (see the attachments). >>>>>>> >>>>>>> It (mostly) works, but te problem is that the grid image is not >>>>>>> being displayed correctly: as shown in the attached figure, it appears too >>>>>>> small, and in the lower left corner of the map, instead of where it should >>>>>>> be (the West coast of Africa, along the Gulf of Guinea). >>>>>>> >>>>>>> Thanks in advance for any assistance you can provide. >>>>>>> >>>>>>> Best regards, >>>>>>> >>>>>>> -- >>>>>>> Dr. Mauro J. Cavalcanti >>>>>>> E-mail: maurobio at gmail.com >>>>>>> Web: http://sites.google.com/site/maurobio >>>>>>> "Life is complex. It consists of real and imaginary parts." >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Matplotlib-users mailing list >>>>>>> Matplotlib-users at python.org >>>>>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Dr. Mauro J. Cavalcanti >>>>> E-mail: maurobio at gmail.com >>>>> Web: http://sites.google.com/site/maurobio >>>>> "Life is complex. It consists of real and imaginary parts." >>>>> >>>> >>>> >>> >>> >>> -- >>> Dr. Mauro J. Cavalcanti >>> E-mail: maurobio at gmail.com >>> Web: http://sites.google.com/site/maurobio >>> "Life is complex. It consists of real and imaginary parts." >>> >> >> > > > -- > Dr. Mauro J. Cavalcanti > E-mail: maurobio at gmail.com > Web: http://sites.google.com/site/maurobio > "Life is complex. It consists of real and imaginary parts." > _________________ > ______________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > -- > Jody Klymak > http://web.uvic.ca/~jklymak/ > > > > > > -- Dr. Mauro J. Cavalcanti E-mail: maurobio at gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stuart_Mentzer at objexx.com Tue Oct 10 13:08:29 2017 From: Stuart_Mentzer at objexx.com (Stuart Mentzer) Date: Tue, 10 Oct 2017 10:08:29 -0700 (MST) Subject: [Matplotlib-users] Unzoom problem in 2.1.0 In-Reply-To: References: <1507606322709-0.post@n5.nabble.com> Message-ID: <1507655309893-0.post@n5.nabble.com> Ben, There is a signal connection set up to call the toolbar's back() method on right clicks. Using right-click to unzoom is a common plotting UI (e.g., in Qwt) so we set that up. That is not the problem here. Both right-click and clicking the back button on the toolbar display the same buggy behavior I describe. Thanks, Stuart -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From vzhao23 at gmail.com Thu Oct 12 11:59:59 2017 From: vzhao23 at gmail.com (Victor Zhao) Date: Thu, 12 Oct 2017 11:59:59 -0400 Subject: [Matplotlib-users] MacOS matplotlib broken after `pip install matplotlib --upgrade` to version 2.1.0 Message-ID: My OS X python installation is through homebrew. I then add python software using pip. I recently upgraded matplotlib from version 1.4.3 to 2.1.0 via `pip install matplotlib --upgrade`, and now matplotlib gives me this error when I try to make a basic plot: In [1]: plt.plot(np.arange(10)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 plt.plot(np.arange(10)) /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs) 3227 @_autogen_docstring(Axes.plot) 3228 def plot(*args, **kwargs): -> 3229 ax = gca() 3230 # Deprecated: allow callers to override the hold state 3231 # by passing hold=True|False /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gca(**kwargs) 957 matplotlib.figure.Figure.gca : The figure's gca method. 958 """ --> 959 return gcf().gca(**kwargs) 960 961 # More ways of creating axes: /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gcf() 586 return figManager.canvas.figure 587 else: --> 588 return figure() 589 590 /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs) 554 # FigureManager base class. 555 if matplotlib.is_interactive(): --> 556 draw_if_interactive() 557 558 if _INSTALL_FIG_OBSERVER: /usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in draw_if_interactive(cls) 183 manager = Gcf.get_active() 184 if manager: --> 185 cls.trigger_manager_draw(manager) 186 187 @classmethod TypeError: unbound method trigger_manager_draw() must be called with _BackendMac instance as first argument (got FigureManagerMac instance instead) I am not sure how to diagnose this. I do have a working Python 3 matplotlib however. Is this actually a bug within version 2.1.0 of matplotlib? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From nuncio.m at gmail.com Fri Oct 13 06:14:04 2017 From: nuncio.m at gmail.com (nuncio) Date: Fri, 13 Oct 2017 03:14:04 -0700 (MST) Subject: [Matplotlib-users] contourf with data frames Message-ID: <1507889644936-0.post@n5.nabble.com> HI, I am trying to plot a time height diagram. here is the code used dates=mpl.dates.date2num(data.index.to_pydatetime()) xh=list(dates) dfX=pd.DataFrame(xh) date2= dfX.groupby(np.arange(len(dfX))//400).mean() dates=num2date(date2) dfT=pd.DataFrame(data.iloc[:,5].reshape(400,427).T) #dfT.insert(loc=0,column='',value=date) hgtl=data.iloc[0:400:,1] #plot(dates,dfT.iloc[:,0]) contourf(dates,hgtl,dfT.iloc[0:400:,0].T) this results in the following error TypeError Traceback (most recent call last) in () 8 hgtl=data.iloc[0:400:,1] 9 #plot(dates,dfT.iloc[:,0]) ---> 10 contourf(dates,hgtl,dfT.iloc[0:400:,0].T) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in contourf(*args, **kwargs) 2781 ax.hold(hold) 2782 try: -> 2783 ret = ax.contourf(*args, **kwargs) 2784 finally: 2785 ax.hold(washold) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs) 1810 warnings.warn(msg % (label_namer, func.__name__), 1811 RuntimeWarning, stacklevel=2) -> 1812 return func(ax, *args, **kwargs) 1813 pre_doc = inner.__doc__ 1814 if pre_doc is None: /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in contourf(self, *args, **kwargs) 5650 self.cla() 5651 kwargs['filled'] = True -> 5652 return mcontour.QuadContourSet(self, *args, **kwargs) 5653 contourf.__doc__ = mcontour.QuadContourSet.contour_doc 5654 /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs) 1422 are described in QuadContourSet.contour_doc. 1423 """ -> 1424 ContourSet.__init__(self, ax, *args, **kwargs) 1425 1426 def _process_args(self, *args, **kwargs): /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs) 861 self._transform = kwargs.get('transform', None) 862 --> 863 self._process_args(*args, **kwargs) 864 self._process_levels() 865 /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _process_args(self, *args, **kwargs) 1443 self._corner_mask = mpl.rcParams['contour.corner_mask'] 1444 -> 1445 x, y, z = self._contour_args(args, kwargs) 1446 1447 _mask = ma.getmask(z) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _contour_args(self, args, kwargs) 1526 args = args[1:] 1527 elif Nargs <= 4: -> 1528 x, y, z = self._check_xyz(args[:3], kwargs) 1529 args = args[3:] 1530 else: /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _check_xyz(self, args, kwargs) 1555 y = self.ax.convert_yunits(y) 1556 -> 1557 x = np.asarray(x, dtype=np.float64) 1558 y = np.asarray(y, dtype=np.float64) 1559 z = ma.asarray(args[2], dtype=np.float64) /home/nuncio/anaconda2/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order) 472 473 """ --> 474 return array(a, dtype, copy=False, order=order) 475 476 def asanyarray(a, dtype=None, order=None): *TypeError: float() argument must be a string or a number* I identify this as the problem with using "dates" in contourf , however I do not find any problem in running plot(dates,dfT.iloc[:,0]) How to get around this THanks and regards nuncio -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From nuncio.m at gmail.com Fri Oct 13 07:05:53 2017 From: nuncio.m at gmail.com (nuncio) Date: Fri, 13 Oct 2017 04:05:53 -0700 (MST) Subject: [Matplotlib-users] contourf with data frames Message-ID: <1507892753913-0.post@n5.nabble.com> I am trying to make a time height contour plot , here is the script used dates=mpl.dates.date2num(data.index.to_pydatetime()) xh=list(dates) dfX=pd.DataFrame(xh) date2= dfX.groupby(np.arange(len(dfX))//400).mean() dates=num2date(date2) dfT=pd.DataFrame(data.iloc[:,5].reshape(400,427).T) #dfT.insert(loc=0,column='',value=date) hgtl=data.iloc[0:400:,1] #plot(dates,dfT.iloc[:,0]) contourf(dates,hgtl,dfT.iloc[0:400:,0].T) this results in the following error TypeError Traceback (most recent call last) in () 8 hgtl=data.iloc[0:400:,1] 9 #plot(dates,dfT.iloc[:,0]) ---> 10 contourf(dates,hgtl,dfT.iloc[0:400:,0].T) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in contourf(*args, **kwargs) 2781 ax.hold(hold) 2782 try: -> 2783 ret = ax.contourf(*args, **kwargs) 2784 finally: 2785 ax.hold(washold) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs) 1810 warnings.warn(msg % (label_namer, func.__name__), 1811 RuntimeWarning, stacklevel=2) -> 1812 return func(ax, *args, **kwargs) 1813 pre_doc = inner.__doc__ 1814 if pre_doc is None: /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in contourf(self, *args, **kwargs) 5650 self.cla() 5651 kwargs['filled'] = True -> 5652 return mcontour.QuadContourSet(self, *args, **kwargs) 5653 contourf.__doc__ = mcontour.QuadContourSet.contour_doc 5654 /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs) 1422 are described in QuadContourSet.contour_doc. 1423 """ -> 1424 ContourSet.__init__(self, ax, *args, **kwargs) 1425 1426 def _process_args(self, *args, **kwargs): /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs) 861 self._transform = kwargs.get('transform', None) 862 --> 863 self._process_args(*args, **kwargs) 864 self._process_levels() 865 /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _process_args(self, *args, **kwargs) 1443 self._corner_mask = mpl.rcParams['contour.corner_mask'] 1444 -> 1445 x, y, z = self._contour_args(args, kwargs) 1446 1447 _mask = ma.getmask(z) /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _contour_args(self, args, kwargs) 1526 args = args[1:] 1527 elif Nargs <= 4: -> 1528 x, y, z = self._check_xyz(args[:3], kwargs) 1529 args = args[3:] 1530 else: /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc in _check_xyz(self, args, kwargs) 1555 y = self.ax.convert_yunits(y) 1556 -> 1557 x = np.asarray(x, dtype=np.float64) 1558 y = np.asarray(y, dtype=np.float64) 1559 z = ma.asarray(args[2], dtype=np.float64) /home/nuncio/anaconda2/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order) 472 473 """ --> 474 return array(a, dtype, copy=False, order=order) 475 476 def asanyarray(a, dtype=None, order=None): * TypeError: float() argument must be a string or a number* I undesrstand the problem is with the dates however plot(dates,dfT.iloc[:,0]) runs perfectly Any suggestions to get around it THanks and regards nuncio -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From jklymak at uvic.ca Fri Oct 13 10:47:13 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Fri, 13 Oct 2017 07:47:13 -0700 Subject: [Matplotlib-users] MacOS matplotlib broken after `pip install matplotlib --upgrade` to version 2.1.0 In-Reply-To: References: Message-ID: <44163313-E2B6-4D28-AED7-FB5C2A782FC4@uvic.ca> Hi Victor, This is apparently a bug that will be patched soon. I?d roll back to 2.0.2 in the meantime if you aren?t comfortable working off github?. https://github.com/matplotlib/matplotlib/issues/9345 Cheers, Jody > On Oct 12, 2017, at 8:59 AM, Victor Zhao wrote: > > My OS X python installation is through homebrew. I then add python software using pip. I recently upgraded matplotlib from version 1.4.3 to 2.1.0 via `pip install matplotlib --upgrade`, and now matplotlib gives me this error when I try to make a basic plot: > > In [1]: plt.plot(np.arange(10)) > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > in () > ----> 1 plt.plot(np.arange(10)) > > /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs) > 3227 @_autogen_docstring(Axes.plot) > 3228 def plot(*args, **kwargs): > -> 3229 ax = gca() > 3230 # Deprecated: allow callers to override the hold state > 3231 # by passing hold=True|False > > /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gca(**kwargs) > 957 matplotlib.figure.Figure.gca : The figure's gca method. > 958 """ > --> 959 return gcf().gca(**kwargs) > 960 > 961 # More ways of creating axes: > > /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gcf() > 586 return figManager.canvas.figure > 587 else: > --> 588 return figure() > 589 > 590 > > /usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs) > 554 # FigureManager base class. > 555 if matplotlib.is_interactive(): > --> 556 draw_if_interactive() > 557 > 558 if _INSTALL_FIG_OBSERVER: > > /usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in draw_if_interactive(cls) > 183 manager = Gcf.get_active() > 184 if manager: > --> 185 cls.trigger_manager_draw(manager) > 186 > 187 @classmethod > > TypeError: unbound method trigger_manager_draw() must be called with _BackendMac instance as first argument (got FigureManagerMac instance instead) > > I am not sure how to diagnose this. I do have a working Python 3 matplotlib however. > > Is this actually a bug within version 2.1.0 of matplotlib? Thanks > _______________________________________________ > 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 Fri Oct 13 17:21:25 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 13 Oct 2017 21:21:25 +0000 Subject: [Matplotlib-users] contourf with data frames In-Reply-To: <1507892753913-0.post@n5.nabble.com> References: <1507892753913-0.post@n5.nabble.com> Message-ID: It looks like you are converting the dates back to datetime objects (`dates = num2date(date2)`). This smells like a bug in contour that it does not properly handle units on the input (but `ax.plot` does) The easiest way around this (with out patching Matplotlib ;) ) is to plot with the dates converted to numbers and then manually set the x axis ticker and locator to be the date related ones. Tom On Fri, Oct 13, 2017 at 9:00 AM nuncio wrote: > I am trying to make a time height contour plot , here is the script used > > dates=mpl.dates.date2num(data.index.to_pydatetime()) > xh=list(dates) > dfX=pd.DataFrame(xh) > date2= dfX.groupby(np.arange(len(dfX))//400).mean() > dates=num2date(date2) > dfT=pd.DataFrame(data.iloc[:,5].reshape(400,427).T) > #dfT.insert(loc=0,column='',value=date) > hgtl=data.iloc[0:400:,1] > #plot(dates,dfT.iloc[:,0]) > contourf(dates,hgtl,dfT.iloc[0:400:,0].T) > > this results in the following error > > > TypeError Traceback (most recent call last) > in () > 8 hgtl=data.iloc[0:400:,1] > 9 #plot(dates,dfT.iloc[:,0]) > ---> 10 contourf(dates,hgtl,dfT.iloc[0:400:,0].T) > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in > contourf(*args, **kwargs) > 2781 ax.hold(hold) > 2782 try: > -> 2783 ret = ax.contourf(*args, **kwargs) > 2784 finally: > 2785 ax.hold(washold) > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc > in inner(ax, *args, **kwargs) > 1810 warnings.warn(msg % (label_namer, > func.__name__), > 1811 RuntimeWarning, stacklevel=2) > -> 1812 return func(ax, *args, **kwargs) > 1813 pre_doc = inner.__doc__ > 1814 if pre_doc is None: > > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc > in contourf(self, *args, **kwargs) > 5650 self.cla() > 5651 kwargs['filled'] = True > -> 5652 return mcontour.QuadContourSet(self, *args, **kwargs) > 5653 contourf.__doc__ = mcontour.QuadContourSet.contour_doc > 5654 > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc > in > __init__(self, ax, *args, **kwargs) > 1422 are described in QuadContourSet.contour_doc. > 1423 """ > -> 1424 ContourSet.__init__(self, ax, *args, **kwargs) > 1425 > 1426 def _process_args(self, *args, **kwargs): > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc > in > __init__(self, ax, *args, **kwargs) > 861 self._transform = kwargs.get('transform', None) > 862 > --> 863 self._process_args(*args, **kwargs) > 864 self._process_levels() > 865 > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc > in > _process_args(self, *args, **kwargs) > 1443 self._corner_mask = > mpl.rcParams['contour.corner_mask'] > 1444 > -> 1445 x, y, z = self._contour_args(args, kwargs) > 1446 > 1447 _mask = ma.getmask(z) > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc > in > _contour_args(self, args, kwargs) > 1526 args = args[1:] > 1527 elif Nargs <= 4: > -> 1528 x, y, z = self._check_xyz(args[:3], kwargs) > 1529 args = args[3:] > 1530 else: > > /home/nuncio/anaconda2/lib/python2.7/site-packages/matplotlib/contour.pyc > in > _check_xyz(self, args, kwargs) > 1555 y = self.ax.convert_yunits(y) > 1556 > -> 1557 x = np.asarray(x, dtype=np.float64) > 1558 y = np.asarray(y, dtype=np.float64) > 1559 z = ma.asarray(args[2], dtype=np.float64) > > /home/nuncio/anaconda2/lib/python2.7/site-packages/numpy/core/numeric.pyc > in > asarray(a, dtype, order) > 472 > 473 """ > --> 474 return array(a, dtype, copy=False, order=order) > 475 > 476 def asanyarray(a, dtype=None, order=None): > * > TypeError: float() argument must be a string or a number* > > I undesrstand the problem is with the dates > > however > > plot(dates,dfT.iloc[:,0]) > > runs perfectly > > Any suggestions to get around it > > THanks and regards > nuncio > > > > -- > Sent from: > http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html > _______________________________________________ > 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 winash12 at gmail.com Wed Oct 18 16:59:11 2017 From: winash12 at gmail.com (ashwin .D) Date: Thu, 19 Oct 2017 02:29:11 +0530 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude Message-ID: Hello, I have data on a 2d lat lon grid(equal grid spacing) in terms of laitude and longitude and heights as enclosed in the image. I need the coordinates(in terms of latitude and longitude) of the contours( as shown in red in the image). From this answer - https://stackoverflow.com/questions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/ will this give me what I am looking for or is there a scaling required to latitude and longitude that I need to include? Best regards, Ashwin. import numpy as np def get_contour_verts(cn): contours = [] # for each contour line for cc in cn.collections: paths = [] # for each separate section of the contour line for pp in cc.get_paths(): xy = [] # for each segment of that section for vv in pp.iter_segments(): xy.append(vv[0]) paths.append(np.vstack(xy)) contours.append(paths) return contours -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sfc_trough1.gif Type: image/gif Size: 13312 bytes Desc: not available URL: From ben.v.root at gmail.com Wed Oct 18 17:08:16 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Wed, 18 Oct 2017 17:08:16 -0400 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude In-Reply-To: References: Message-ID: If you passed the coordinate arrays in with the call to contourf(), then you will get what you expect. I should note that you should watch out for path simplification (you'll want to turn it off). I also recommend using contourf() over contour() because it handles the edges of the domain better and NaNs. Cheers! Ben Root On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D wrote: > Hello, > I have data on a 2d lat lon grid(equal grid spacing) in terms of > laitude and longitude and heights as enclosed in the image. I need the > coordinates(in terms of latitude and longitude) of the contours( as shown > in red in the image). From this answer - https://stackoverflow.com/ > questions/18304722/python-find-contour-lines-from- > matplotlib-pyplot-contour/ will this give me what I am looking for or is > there a scaling required to latitude and longitude that I need to include? > > Best regards, > Ashwin. > > import numpy as np > def get_contour_verts(cn): > contours = [] > # for each contour line > for cc in cn.collections: > paths = [] > # for each separate section of the contour line > for pp in cc.get_paths(): > xy = [] > # for each segment of that section > for vv in pp.iter_segments(): > xy.append(vv[0]) > paths.append(np.vstack(xy)) > contours.append(paths) > > return contours > > > > _______________________________________________ > 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 rmay31 at gmail.com Wed Oct 18 17:38:42 2017 From: rmay31 at gmail.com (Ryan May) Date: Wed, 18 Oct 2017 15:38:42 -0600 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude In-Reply-To: References: Message-ID: For this problem, though, I don't think contouring is what you want. I think you'd be better off looking for some spatial consistency in the gradient field directly rather than going through contours. Ryan On Wed, Oct 18, 2017 at 2:59 PM, ashwin .D wrote: > Hello, > I have data on a 2d lat lon grid(equal grid spacing) in terms of > laitude and longitude and heights as enclosed in the image. I need the > coordinates(in terms of latitude and longitude) of the contours( as shown > in red in the image). From this answer - https://stackoverflow.com/ > questions/18304722/python-find-contour-lines-from- > matplotlib-pyplot-contour/ will this give me what I am looking for or is > there a scaling required to latitude and longitude that I need to include? > > Best regards, > Ashwin. > > import numpy as np > def get_contour_verts(cn): > contours = [] > # for each contour line > for cc in cn.collections: > paths = [] > # for each separate section of the contour line > for pp in cc.get_paths(): > xy = [] > # for each segment of that section > for vv in pp.iter_segments(): > xy.append(vv[0]) > paths.append(np.vstack(xy)) > contours.append(paths) > > return contours > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -- Ryan May -------------- next part -------------- An HTML attachment was scrubbed... URL: From winash12 at gmail.com Wed Oct 18 17:32:28 2017 From: winash12 at gmail.com (ashwin .D) Date: Thu, 19 Oct 2017 03:02:28 +0530 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude In-Reply-To: References: Message-ID: Ben, Thanks ! Can you explain a bit more on what you mean by path simplification ? Here is the code as I see it right now. Also I had a second question - cs.levels returns the contour levels associated with the contours. Is there a dictionary that maps a contour level to the contour coordinates or is cs.collections in the same order as cs.levels? import numpy as np from netCDF4 import Dataset import matplotlib.pyplot as plt clevs = np.arange(5300.,5900.,20.) cs = plt.contourf(lons, lats, np.squeeze(hgt),clevs) for cc in cs.collections: paths = [] for pp in cc.get_paths(): xy = [] for vv in pp.iter_segments(): xy.append(vv[0]) paths.append(np.vstack(xy)) contours.append(paths) On Thu, Oct 19, 2017 at 2:38 AM, Benjamin Root wrote: > If you passed the coordinate arrays in with the call to contourf(), then > you will get what you expect. > > I should note that you should watch out for path simplification (you'll > want to turn it off). I also recommend using contourf() over contour() > because it handles the edges of the domain better and NaNs. > > Cheers! > Ben Root > > > On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D wrote: > >> Hello, >> I have data on a 2d lat lon grid(equal grid spacing) in terms of >> laitude and longitude and heights as enclosed in the image. I need the >> coordinates(in terms of latitude and longitude) of the contours( as shown >> in red in the image). From this answer - https://stackoverflow.com/ques >> tions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/ >> will this give me what I am looking for or is there a scaling required to >> latitude and longitude that I need to include? >> >> Best regards, >> Ashwin. >> >> import numpy as np >> def get_contour_verts(cn): >> contours = [] >> # for each contour line >> for cc in cn.collections: >> paths = [] >> # for each separate section of the contour line >> for pp in cc.get_paths(): >> xy = [] >> # for each segment of that section >> for vv in pp.iter_segments(): >> xy.append(vv[0]) >> paths.append(np.vstack(xy)) >> contours.append(paths) >> >> return contours >> >> >> >> _______________________________________________ >> 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 winash12 at gmail.com Thu Oct 19 04:48:24 2017 From: winash12 at gmail.com (ashwin .D) Date: Thu, 19 Oct 2017 14:18:24 +0530 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude In-Reply-To: References: Message-ID: Hi Ben, I believe have a better idea of my doubt and I am just thinking loudly here - apologies if all of this is irrelevant. Usually when you have a raster grid you need to define it with respect to a origin. So since in my case I have a global grid the lower left hand corner is taken to be the origin. This is usually -90 S, 180 W. But you could also have a subset of the global grid in which case the lower left corner's latitude and longitude can be considered as the origin. This is important especially if you want to know what is grid orientation of the contour with respect to the origin. I presume I do not need to worry about this with matplotlib's contourf - am I correct on that or put it differently does it even matter ? Looking in the code collections.py under lib/matplotlib I see some references to rasterizing a grid and affine transformations. I am not sure whether that is related to any of what I just asked. Best regards, Ashwin. On Thu, Oct 19, 2017 at 2:38 AM, Benjamin Root wrote: > If you passed the coordinate arrays in with the call to contourf(), then > you will get what you expect. > > I should note that you should watch out for path simplification (you'll > want to turn it off). I also recommend using contourf() over contour() > because it handles the edges of the domain better and NaNs. > > Cheers! > Ben Root > > > On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D wrote: > >> Hello, >> I have data on a 2d lat lon grid(equal grid spacing) in terms of >> laitude and longitude and heights as enclosed in the image. I need the >> coordinates(in terms of latitude and longitude) of the contours( as shown >> in red in the image). From this answer - https://stackoverflow.com/ques >> tions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/ >> will this give me what I am looking for or is there a scaling required to >> latitude and longitude that I need to include? >> >> Best regards, >> Ashwin. >> >> import numpy as np >> def get_contour_verts(cn): >> contours = [] >> # for each contour line >> for cc in cn.collections: >> paths = [] >> # for each separate section of the contour line >> for pp in cc.get_paths(): >> xy = [] >> # for each segment of that section >> for vv in pp.iter_segments(): >> xy.append(vv[0]) >> paths.append(np.vstack(xy)) >> contours.append(paths) >> >> return contours >> >> >> >> _______________________________________________ >> 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 jslavin at cfa.harvard.edu Thu Oct 19 08:32:36 2017 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Thu, 19 Oct 2017 08:32:36 -0400 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude Message-ID: I'm wondering if we could make this easier by modifying contour/contourf so that the ContourSet object created had a paths object attribute. It doesn't seem like it'd be that hard. Maybe some would object that it would slow down the creation of contour plots? Jon On Wed, Oct 18, 2017 at 5:08 PM, wrote: > > Date: Thu, 19 Oct 2017 02:29:11 +0530 > From: "ashwin .D" > To: matplotlib-users at python.org > Subject: [Matplotlib-users] Obtaining the contour data in terms of > latitude and longitude > Message-ID: > mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hello, > I have data on a 2d lat lon grid(equal grid spacing) in terms of > laitude and longitude and heights as enclosed in the image. I need the > coordinates(in terms of latitude and longitude) of the contours( as shown > in red in the image). From this answer - > https://stackoverflow.com/questions/18304722/python- > find-contour-lines-from-matplotlib-pyplot-contour/ > will this give me what I am looking for or is there a scaling required to > latitude and longitude that I need to include? > > Best regards, > Ashwin. > > import numpy as np > def get_contour_verts(cn): > contours = [] > # for each contour line > for cc in cn.collections: > paths = [] > # for each separate section of the contour line > for pp in cc.get_paths(): > xy = [] > # for each segment of that section > for vv in pp.iter_segments(): > xy.append(vv[0]) > paths.append(np.vstack(xy)) > contours.append(paths) > > return contours > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: attachments/20171019/c5cb0664/attachment-0001.html> > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: sfc_trough1.gif > Type: image/gif > Size: 13312 bytes > Desc: not available > URL: attachments/20171019/c5cb0664/attachment-0001.gif> > > ------------------------------ > > Message: 2 > Date: Wed, 18 Oct 2017 17:08:16 -0400 > From: Benjamin Root > To: "ashwin .D" > Cc: Matplotlib-users > Subject: Re: [Matplotlib-users] Obtaining the contour data in terms of > latitude and longitude > Message-ID: > gmail.com> > Content-Type: text/plain; charset="utf-8" > > If you passed the coordinate arrays in with the call to contourf(), then > you will get what you expect. > > I should note that you should watch out for path simplification (you'll > want to turn it off). I also recommend using contourf() over contour() > because it handles the edges of the domain better and NaNs. > > Cheers! > Ben Root > > > On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D wrote: > > > Hello, > > I have data on a 2d lat lon grid(equal grid spacing) in terms of > > laitude and longitude and heights as enclosed in the image. I need the > > coordinates(in terms of latitude and longitude) of the contours( as shown > > in red in the image). From this answer - https://stackoverflow.com/ > > questions/18304722/python-find-contour-lines-from- > > matplotlib-pyplot-contour/ will this give me what I am looking for or is > > there a scaling required to latitude and longitude that I need to > include? > > > > Best regards, > > Ashwin. > > > > import numpy as np > > def get_contour_verts(cn): > > contours = [] > > # for each contour line > > for cc in cn.collections: > > paths = [] > > # for each separate section of the contour line > > for pp in cc.get_paths(): > > xy = [] > > # for each segment of that section > > for vv in pp.iter_segments(): > > xy.append(vv[0]) > > paths.append(np.vstack(xy)) > > contours.append(paths) > > > > return contours > > > > > > > > _______________________________________________ > > 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: attachments/20171018/b9f14b69/attachment.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 27, Issue 24 > ************************************************ > -- ________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Thu Oct 19 10:32:35 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Thu, 19 Oct 2017 10:32:35 -0400 Subject: [Matplotlib-users] Problem of memory leak using FigureCanvasTkAgg In-Reply-To: <1508423218080.28805@etu.univ-lyon1.fr> References: <1494500114526.97210@etu.univ-lyon1.fr> <1508423218080.28805@etu.univ-lyon1.fr> Message-ID: Did the rate of memory leak change? On Thu, Oct 19, 2017 at 10:26 AM, GARCIA PIERRE SIMON p0904379 < pierre.garcia at etu.univ-lyon1.fr> wrote: > Thank you for your answer but I updated MPL to 2.1.0 and the memory leak > is still there. Also, I skipped entirely pyplot and the result is strictly > the same. > > > Pierre > ------------------------------ > *De :* Benjamin Root > *Envoy? :* lundi 7 ao?t 2017 19:27 > *? :* Thomas Caswell > *Cc :* GARCIA PIERRE SIMON p0904379; matplotlib-users at python.org > *Objet :* Re: [Matplotlib-users] Problem of memory leak using > FigureCanvasTkAgg > > The stackoverflow posting notes that mpl v1.1.1 was used, which is 5 years > old. I am pretty sure we have made a lot of memory leak fixes since then. I > noted as such on SO. > > Ben Root > > On Sat, Aug 5, 2017 at 7:48 PM, Thomas Caswell wrote: > >> It is likely there things are not being garbage collected due to either a >> missed reference surviving or the circular references between the various >> objects is delaying gc from collecting them (I do not recall the details >> exactly off the top of my head, but running gc manually with more >> generations may help). >> >> However, if you are embedding in a GUI you are probably better off just >> doing the embedding directly (and skipping `pyplot` entirely, see >> https://matplotlib.org/examples/user_interfaces/embedding_in_tk.html ). >> Re-using the Figures / Axes / Artists to update the data (rather than >> starting from scratch every time) may also prevent the memory leaks _and_ >> give you a performance boost. >> >> Please subscribe to the list so that you can post without moderation. >> >> Tom >> >> On Sat, Aug 5, 2017 at 12:36 PM GARCIA PIERRE SIMON p0904379 < >> pierre.garcia at etu.univ-lyon1.fr> wrote: >> >>> Hello, >>> >>> I'm PhD student in Bioinformatic and I'm working on a project using >>> matplotlib and Tkinter but I've got a big problem of memory leak using >>> these modules. I'll be very grateful if you could help me to solve this >>> problem. Here is the link explaining what happends, with a reduced script: >>> http://stackoverflow.com/questions/43097378/matplotlib-vs- >>> tkinter-memory-leak-using-figurecanvastkagg >>> >>> Thank you in advance, >>> >>> >>> Sincerly, >>> >>> >>> >>> >>> Pierre Garcia, PhD Student >>> --------- >>> Bases Mol?culaires et Structurales des Syst?mes infectieux-UMR5086 >>> Institut de Biologie et Chimie des Prot?ines >>> 7 passage du Vercors >>> >>> 69 367 Lyon cedex 07 >>> --------- >>> Laboratoire de Biom?trie et Biologie Evolutive-UMR5558 >>> UCBL Lyon 1 -B?t. Gr?gory Mendel >>> 43 bd du 11 novembre 1918 >>> >>> 69622 VILLEURBANNE cedex >>> >>> >>> _______________________________________________ >>> 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 tcaswell at gmail.com Thu Oct 19 11:30:26 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Thu, 19 Oct 2017 15:30:26 +0000 Subject: [Matplotlib-users] Problem of memory leak using FigureCanvasTkAgg In-Reply-To: <1508425001765.79170@etu.univ-lyon1.fr> References: <1494500114526.97210@etu.univ-lyon1.fr> <1508423218080.28805@etu.univ-lyon1.fr> <1508425001765.79170@etu.univ-lyon1.fr> Message-ID: Have you tried manually adding calls to `gc.collect(2)`? That may help to clean up any circular reference cycles hanging around. Can you replicate this with a simpler script? The code on SO is hard to follow. Tom On Thu, Oct 19, 2017 at 10:56 AM GARCIA PIERRE SIMON p0904379 < pierre.garcia at etu.univ-lyon1.fr> wrote: > Here is the diagnostic for the old version : > > Memory usage: 39832 (kb) Memory usage: 45376 (kb)Memory usage: 46168 (kb) Memory usage: 46960 (kb)Memory usage: 47224 (kb) Memory usage: 47752 (kb)Memory usage: 47752 (kb) Memory usage: 48544 (kb)Memory usage: 48544 (kb) Memory usage: 48808 (kb)Memory usage: 48808 (kb) Memory usage: 49072 (kb)Memory usage: 49072 (kb) Memory usage: 49336 (kb)Memory usage: 49336 (kb) Memory usage: 49864 (kb)Memory usage: 49864 (kb) Memory usage: 50128 (kb)Memory usage: 50128 (kb) Memory usage: 50392 (kb)Memory usage: 50392 (kb) Memory usage: 50656 (kb) > > and here is the diagnostic for 2.1.0: > > Memory usage: 51808 (kb) Memory usage: 55504 (kb) > Memory usage: 57088 (kb) Memory usage: 57352 (kb) > Memory usage: 57880 (kb) Memory usage: 58144 (kb) > Memory usage: 58672 (kb) Memory usage: 58936 (kb) > Memory usage: 59464 (kb) Memory usage: 59464 (kb) > Memory usage: 59992 (kb) Memory usage: 60256 (kb) > Memory usage: 60520 (kb) Memory usage: 61048 (kb) > Memory usage: 61312 (kb) Memory usage: 61576 (kb) > Memory usage: 62104 (kb) Memory usage: 62368 (kb) > Memory usage: 62632 (kb) Memory usage: 63160 (kb) > Memory usage: 63424 (kb) Memory usage: 63688 (kb) > Memory usage: 64216 (kb) Memory usage: 64480 (kb) > > It seems that the initial memory used is higher for 2.1.0. > > For the delta against n and n+1, the value varies at the begin > and converge to 264 for 1.1.1 and 792 for 2.1.0. > > > So globally, the rate of leak increases in 2.1.0.... > > > Pierre > ------------------------------ > *De :* Benjamin Root > *Envoy? :* jeudi 19 octobre 2017 16:32 > *? :* GARCIA PIERRE SIMON p0904379 > *Cc :* Thomas Caswell; matplotlib-users at python.org > > *Objet :* Re: [Matplotlib-users] Problem of memory leak using > FigureCanvasTkAgg > Did the rate of memory leak change? > > On Thu, Oct 19, 2017 at 10:26 AM, GARCIA PIERRE SIMON p0904379 < > pierre.garcia at etu.univ-lyon1.fr> wrote: > >> Thank you for your answer but I updated MPL to 2.1.0 and the memory leak >> is still there. Also, I skipped entirely pyplot and the result is strictly >> the same. >> >> >> Pierre >> ------------------------------ >> *De :* Benjamin Root >> *Envoy? :* lundi 7 ao?t 2017 19:27 >> *? :* Thomas Caswell >> *Cc :* GARCIA PIERRE SIMON p0904379; matplotlib-users at python.org >> *Objet :* Re: [Matplotlib-users] Problem of memory leak using >> FigureCanvasTkAgg >> >> The stackoverflow posting notes that mpl v1.1.1 was used, which is 5 >> years old. I am pretty sure we have made a lot of memory leak fixes since >> then. I noted as such on SO. >> >> Ben Root >> >> On Sat, Aug 5, 2017 at 7:48 PM, Thomas Caswell >> wrote: >> >>> It is likely there things are not being garbage collected due to either >>> a missed reference surviving or the circular references between the various >>> objects is delaying gc from collecting them (I do not recall the details >>> exactly off the top of my head, but running gc manually with more >>> generations may help). >>> >>> However, if you are embedding in a GUI you are probably better off just >>> doing the embedding directly (and skipping `pyplot` entirely, see >>> https://matplotlib.org/examples/user_interfaces/embedding_in_tk.html ). >>> Re-using the Figures / Axes / Artists to update the data (rather than >>> starting from scratch every time) may also prevent the memory leaks _and_ >>> give you a performance boost. >>> >>> Please subscribe to the list so that you can post without moderation. >>> >>> Tom >>> >>> On Sat, Aug 5, 2017 at 12:36 PM GARCIA PIERRE SIMON p0904379 < >>> pierre.garcia at etu.univ-lyon1.fr> wrote: >>> >>>> Hello, >>>> >>>> I'm PhD student in Bioinformatic and I'm working on a project using >>>> matplotlib and Tkinter but I've got a big problem of memory leak using >>>> these modules. I'll be very grateful if you could help me to solve this >>>> problem. Here is the link explaining what happends, with a reduced script: >>>> >>>> http://stackoverflow.com/questions/43097378/matplotlib-vs-tkinter-memory-leak-using-figurecanvastkagg >>>> >>>> Thank you in advance, >>>> >>>> >>>> Sincerly, >>>> >>>> >>>> >>>> >>>> Pierre Garcia, PhD Student >>>> --------- >>>> Bases Mol?culaires et Structurales des Syst?mes infectieux-UMR5086 >>>> Institut de Biologie et Chimie des Prot?ines >>>> 7 passage du Vercors >>>> >>>> 69 367 Lyon cedex 07 >>>> --------- >>>> Laboratoire de Biom?trie et Biologie Evolutive-UMR5558 >>>> UCBL Lyon 1 -B?t. Gr?gory Mendel >>>> 43 bd du 11 novembre 1918 >>>> >>>> 69622 VILLEURBANNE cedex >>>> >>>> >>>> _______________________________________________ >>>> 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 ianthomas23 at gmail.com Thu Oct 19 11:57:33 2017 From: ianthomas23 at gmail.com (Ian Thomas) Date: Thu, 19 Oct 2017 16:57:33 +0100 Subject: [Matplotlib-users] Obtaining the contour data in terms of latitude and longitude In-Reply-To: References: Message-ID: See https://github.com/matplotlib/matplotlib/issues/367 for discussion and examples of good and bad ways of doing this. Ian On 19 October 2017 at 13:32, Slavin, Jonathan wrote: > I'm wondering if we could make this easier by modifying contour/contourf > so that the ContourSet object created had a paths object attribute. It > doesn't seem like it'd be that hard. Maybe some would object that it would > slow down the creation of contour plots? > > Jon > > On Wed, Oct 18, 2017 at 5:08 PM, > wrote: >> >> Date: Thu, 19 Oct 2017 02:29:11 +0530 >> From: "ashwin .D" >> To: matplotlib-users at python.org >> Subject: [Matplotlib-users] Obtaining the contour data in terms of >> latitude and longitude >> Message-ID: >> > gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> >> Hello, >> I have data on a 2d lat lon grid(equal grid spacing) in terms of >> laitude and longitude and heights as enclosed in the image. I need the >> coordinates(in terms of latitude and longitude) of the contours( as shown >> in red in the image). From this answer - >> https://stackoverflow.com/questions/18304722/python-find- >> contour-lines-from-matplotlib-pyplot-contour/ >> will this give me what I am looking for or is there a scaling required to >> latitude and longitude that I need to include? >> >> Best regards, >> Ashwin. >> >> import numpy as np >> def get_contour_verts(cn): >> contours = [] >> # for each contour line >> for cc in cn.collections: >> paths = [] >> # for each separate section of the contour line >> for pp in cc.get_paths(): >> xy = [] >> # for each segment of that section >> for vv in pp.iter_segments(): >> xy.append(vv[0]) >> paths.append(np.vstack(xy)) >> contours.append(paths) >> >> return contours >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> URL: > ts/20171019/c5cb0664/attachment-0001.html> >> -------------- next part -------------- >> A non-text attachment was scrubbed... >> Name: sfc_trough1.gif >> Type: image/gif >> Size: 13312 bytes >> Desc: not available >> URL: > ts/20171019/c5cb0664/attachment-0001.gif> >> >> ------------------------------ >> >> Message: 2 >> Date: Wed, 18 Oct 2017 17:08:16 -0400 >> From: Benjamin Root >> To: "ashwin .D" >> Cc: Matplotlib-users >> Subject: Re: [Matplotlib-users] Obtaining the contour data in terms of >> latitude and longitude >> Message-ID: >> > ail.com> >> Content-Type: text/plain; charset="utf-8" >> >> >> If you passed the coordinate arrays in with the call to contourf(), then >> you will get what you expect. >> >> I should note that you should watch out for path simplification (you'll >> want to turn it off). I also recommend using contourf() over contour() >> because it handles the edges of the domain better and NaNs. >> >> Cheers! >> Ben Root >> >> >> On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D wrote: >> >> > Hello, >> > I have data on a 2d lat lon grid(equal grid spacing) in terms >> of >> > laitude and longitude and heights as enclosed in the image. I need the >> > coordinates(in terms of latitude and longitude) of the contours( as >> shown >> > in red in the image). From this answer - https://stackoverflow.com/ >> > questions/18304722/python-find-contour-lines-from- >> > matplotlib-pyplot-contour/ will this give me what I am looking for or is >> > there a scaling required to latitude and longitude that I need to >> include? >> > >> > Best regards, >> > Ashwin. >> > >> > import numpy as np >> > def get_contour_verts(cn): >> > contours = [] >> > # for each contour line >> > for cc in cn.collections: >> > paths = [] >> > # for each separate section of the contour line >> > for pp in cc.get_paths(): >> > xy = [] >> > # for each segment of that section >> > for vv in pp.iter_segments(): >> > xy.append(vv[0]) >> > paths.append(np.vstack(xy)) >> > contours.append(paths) >> > >> > return contours >> > >> > >> > >> > _______________________________________________ >> > 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: > ts/20171018/b9f14b69/attachment.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 27, Issue 24 >> ************************************************ >> > > > > -- > ________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ________________________________________________________ > > > _______________________________________________ > 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 Fri Oct 20 00:10:59 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 20 Oct 2017 04:10:59 +0000 Subject: [Matplotlib-users] Problem of memory leak using FigureCanvasTkAgg In-Reply-To: <1508429902922.94316@etu.univ-lyon1.fr> References: <1494500114526.97210@etu.univ-lyon1.fr> <1508423218080.28805@etu.univ-lyon1.fr> <1508425001765.79170@etu.univ-lyon1.fr> <1508429902922.94316@etu.univ-lyon1.fr> Message-ID: I think there was a bug in how you were capturing the clearing the children of the top level frame. Tweaking it a bit I can reproduce the leaking, but not on every cycle: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import matplotlib.patches as patches # from Tkinter import Tk, Canvas, Frame, Label, Button from six.moves import tkinter as Tk import gc import resource from matplotlib.figure import Figure import sys list_fig_g = [] list_wid_g = [] def launcher(list_wid, list_fig, frame): print('Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,) for f in list_fig: f.clf() f.clear() f._master = None del f list_fig.clear() for i in list_wid: print(i, sys.getrefcount(i)) r = i.winfo_toplevel() i.grid_forget() i.destroy() for k in ('', ''): r.unbind(k) print(i, sys.getrefcount(i)) del i list_wid.clear() fig1 = Figure(figsize=(1, 1)) ax1 = fig1.add_subplot(111, aspect='equal') ax1.add_patch( patches.Arrow( 0, # x -0, # y 1, # dx 0, # dy width=1, ) ) list_fig.append(fig1) # this seems to be the first line that leaks memory # but not _always_ canvas = FigureCanvasTkAgg(fig1, master=None) t1, t2, w, h = fig1.bbox.bounds widget = canvas.get_tk_widget() # widget = Tk.Canvas( # master=frame, width=w, height=h, borderwidth=0, # highlightthickness=0) # w2 = Tk.PhotoImage( # master=widget, width=int(w), height=int(h)) # widget.create_image(w//2, h//2, image=w2) widget.grid(row=0, column=1) widget.focus_set() list_wid.extend(frame.winfo_children()) # print(w) # print('gc: ', gc.collect(2)) gc.collect(2) # canvas.draw() print('Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) print() def bulk(list_wid, list_fig, frame): for j in range(100): launcher(list_wid, list_fig, frame) root = Tk.Tk() Entete5 = Tk.Label(root, width=20, height=1).grid(row=0, column=1) fond = Tk.Canvas(root, width=800, height=200) fond.grid(row=1, column=1) frame_g = Tk.Frame(fond, width=80, height=10) frame_g.grid(row=0, column=1) fond.create_window(0, 0, window=frame_g) Load = Tk.Button(root, text="Load", command=lambda: launcher(list_wid_g, list_fig_g, frame_g)) go = Tk.Button(root, text="bulk", command=lambda: bulk(list_wid_g, list_fig_g, frame_g)) Load.grid(row=7, column=4) go.grid(row=6, column=4) list_wid = frame_g.winfo_children() root.mainloop() (I also added a 'bulk' button to run 100 iterations). I tried just creating a FigureCanvasAgg object (the super-class of FigureCanvasTkAgg) and that seems not to leak. Doing most of the tk work that FigureCanvasTkAgg does not seem to leak. It looks like it is the callbacks that are registered to handle mouse and key board events, deleteing them from the __init__ seems to prevent the leak! Not sure what the right way to clean those up is though, but at least this is pointing the right direction! Tom On Thu, Oct 19, 2017 at 12:18 PM GARCIA PIERRE SIMON p0904379 < pierre.garcia at etu.univ-lyon1.fr> wrote: > Adding gc.collect() everywhere in the script doesn't change anything. Here > is a code that works and that is simpler: > > > #! /usr/bin/python2.7 > #-*- coding: utf-8 -*- > import matplotlib > matplotlib.use('Tkagg') > from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg > import matplotlib.patches as patches > from Tkinter import * > import gc > import resource > from matplotlib.figure import Figure > > list_fig_g = [] > list_wid_g = [] > > def Launcher(list_wid,list_fig,frame): > print 'Memory usage: %s (kb)' % > resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, > for i in list_wid: > i.grid_forget() > i.destroy() > del i > try: > list_fig[0].clf()# other round > list_fig[0].clear() > del list_fig[0] > except: > print "",# first round > fig1 = Figure(figsize=(1,1)) > ax1 = fig1.add_subplot(111, aspect='equal') > ax1.add_patch( > patches.Arrow( > 0, # x > -0, # y > 1, # dx > 0, # dy > width=1, > ) > ) > list_fig.append(fig1) > canvas = FigureCanvasTkAgg(list_fig[0], master=frame) > canvas.get_tk_widget().grid(row=0,column=1) > list_wid = frame.winfo_children() > print 'Memory usage: %s (kb)' % > resource.getrusage(resource.RUSAGE_SELF).ru_maxrss > > root = Tk() > Entete5 = Label(root,width=20, height=1).grid(row=0,column=1) > fond = Canvas(root, width=800, height=200) > fond.grid(row=1, column=1) > frame_g = Frame(fond,width=80, height=10) > frame_g.grid(row=0,column=1) > fond.create_window(0, 0, window=frame_g) > Load = Button (root, text = "Load", command = lambda : > Launcher(list_wid_g,list_fig_g,frame_g)) > Load.grid(row=7,column=4) > list_wid = frame_g.winfo_children() > root.mainloop() > > > and here is the output: > > > Memory usage: 49516 (kb) Memory usage: 50824 (kb) > Memory usage: 51880 (kb) Memory usage: 52672 (kb) > Memory usage: 52936 (kb) Memory usage: 53728 (kb) > Memory usage: 53992 (kb) Memory usage: 54256 (kb) > Memory usage: 54520 (kb) Memory usage: 54520 (kb) > Memory usage: 54520 (kb) Memory usage: 55048 (kb) > Memory usage: 55312 (kb) Memory usage: 55840 (kb) > Memory usage: 55840 (kb) Memory usage: 55840 (kb) > Memory usage: 56104 (kb) Memory usage: 56104 (kb) > Memory usage: 56104 (kb) Memory usage: 56104 (kb) > Memory usage: 56368 (kb) Memory usage: 56368 (kb) > Memory usage: 56368 (kb) Memory usage: 56632 (kb) > Memory usage: 56896 (kb) Memory usage: 57424 (kb) > Memory usage: 57688 (kb) Memory usage: 57688 (kb) > Memory usage: 57688 (kb) Memory usage: 57952 (kb) > Memory usage: 58216 (kb) Memory usage: 59008 (kb) > Memory usage: 59008 (kb) Memory usage: 59008 (kb) > Memory usage: 59008 (kb) Memory usage: 59272 (kb) > Memory usage: 59536 (kb) Memory usage: 60328 (kb) > > Pierre > ------------------------------ > *De :* Thomas Caswell > *Envoy? :* jeudi 19 octobre 2017 17:30 > *? :* GARCIA PIERRE SIMON p0904379; Benjamin Root > *Cc :* matplotlib-users at python.org > > *Objet :* Re: [Matplotlib-users] Problem of memory leak using > FigureCanvasTkAgg > Have you tried manually adding calls to `gc.collect(2)`? That may help to > clean up any circular reference cycles hanging around. > > Can you replicate this with a simpler script? The code on SO is hard to > follow. > > Tom > > On Thu, Oct 19, 2017 at 10:56 AM GARCIA PIERRE SIMON p0904379 < > pierre.garcia at etu.univ-lyon1.fr> wrote: > >> Here is the diagnostic for the old version : >> >> Memory usage: 39832 (kb) Memory usage: 45376 (kb)Memory usage: 46168 (kb) Memory usage: 46960 (kb)Memory usage: 47224 (kb) Memory usage: 47752 (kb)Memory usage: 47752 (kb) Memory usage: 48544 (kb)Memory usage: 48544 (kb) Memory usage: 48808 (kb)Memory usage: 48808 (kb) Memory usage: 49072 (kb)Memory usage: 49072 (kb) Memory usage: 49336 (kb)Memory usage: 49336 (kb) Memory usage: 49864 (kb)Memory usage: 49864 (kb) Memory usage: 50128 (kb)Memory usage: 50128 (kb) Memory usage: 50392 (kb)Memory usage: 50392 (kb) Memory usage: 50656 (kb) >> >> and here is the diagnostic for 2.1.0: >> >> Memory usage: 51808 (kb) Memory usage: 55504 (kb) >> Memory usage: 57088 (kb) Memory usage: 57352 (kb) >> Memory usage: 57880 (kb) Memory usage: 58144 (kb) >> Memory usage: 58672 (kb) Memory usage: 58936 (kb) >> Memory usage: 59464 (kb) Memory usage: 59464 (kb) >> Memory usage: 59992 (kb) Memory usage: 60256 (kb) >> Memory usage: 60520 (kb) Memory usage: 61048 (kb) >> Memory usage: 61312 (kb) Memory usage: 61576 (kb) >> Memory usage: 62104 (kb) Memory usage: 62368 (kb) >> Memory usage: 62632 (kb) Memory usage: 63160 (kb) >> Memory usage: 63424 (kb) Memory usage: 63688 (kb) >> Memory usage: 64216 (kb) Memory usage: 64480 (kb) >> >> It seems that the initial memory used is higher for 2.1.0. >> >> For the delta against n and n+1, the value varies at the begin >> and converge to 264 for 1.1.1 and 792 for 2.1.0. >> >> >> So globally, the rate of leak increases in 2.1.0.... >> >> >> Pierre >> ------------------------------ >> *De :* Benjamin Root >> *Envoy? :* jeudi 19 octobre 2017 16:32 >> *? :* GARCIA PIERRE SIMON p0904379 >> *Cc :* Thomas Caswell; matplotlib-users at python.org >> >> *Objet :* Re: [Matplotlib-users] Problem of memory leak using >> FigureCanvasTkAgg >> Did the rate of memory leak change? >> >> On Thu, Oct 19, 2017 at 10:26 AM, GARCIA PIERRE SIMON p0904379 < >> pierre.garcia at etu.univ-lyon1.fr> wrote: >> >>> Thank you for your answer but I updated MPL to 2.1.0 and the memory leak >>> is still there. Also, I skipped entirely pyplot and the result is strictly >>> the same. >>> >>> >>> Pierre >>> ------------------------------ >>> *De :* Benjamin Root >>> *Envoy? :* lundi 7 ao?t 2017 19:27 >>> *? :* Thomas Caswell >>> *Cc :* GARCIA PIERRE SIMON p0904379; matplotlib-users at python.org >>> *Objet :* Re: [Matplotlib-users] Problem of memory leak using >>> FigureCanvasTkAgg >>> >>> The stackoverflow posting notes that mpl v1.1.1 was used, which is 5 >>> years old. I am pretty sure we have made a lot of memory leak fixes since >>> then. I noted as such on SO. >>> >>> Ben Root >>> >>> On Sat, Aug 5, 2017 at 7:48 PM, Thomas Caswell >>> wrote: >>> >>>> It is likely there things are not being garbage collected due to either >>>> a missed reference surviving or the circular references between the various >>>> objects is delaying gc from collecting them (I do not recall the details >>>> exactly off the top of my head, but running gc manually with more >>>> generations may help). >>>> >>>> However, if you are embedding in a GUI you are probably better off just >>>> doing the embedding directly (and skipping `pyplot` entirely, see >>>> https://matplotlib.org/examples/user_interfaces/embedding_in_tk.html ). >>>> Re-using the Figures / Axes / Artists to update the data (rather than >>>> starting from scratch every time) may also prevent the memory leaks _and_ >>>> give you a performance boost. >>>> >>>> Please subscribe to the list so that you can post without moderation. >>>> >>>> Tom >>>> >>>> On Sat, Aug 5, 2017 at 12:36 PM GARCIA PIERRE SIMON p0904379 < >>>> pierre.garcia at etu.univ-lyon1.fr> wrote: >>>> >>>>> Hello, >>>>> >>>>> I'm PhD student in Bioinformatic and I'm working on a project using >>>>> matplotlib and Tkinter but I've got a big problem of memory leak using >>>>> these modules. I'll be very grateful if you could help me to solve this >>>>> problem. Here is the link explaining what happends, with a reduced script: >>>>> >>>>> http://stackoverflow.com/questions/43097378/matplotlib-vs-tkinter-memory-leak-using-figurecanvastkagg >>>>> >>>>> Thank you in advance, >>>>> >>>>> >>>>> Sincerly, >>>>> >>>>> >>>>> >>>>> >>>>> Pierre Garcia, PhD Student >>>>> --------- >>>>> Bases Mol?culaires et Structurales des Syst?mes infectieux-UMR5086 >>>>> Institut de Biologie et Chimie des Prot?ines >>>>> 7 passage du Vercors >>>>> >>>>> 69 367 Lyon cedex 07 >>>>> --------- >>>>> Laboratoire de Biom?trie et Biologie Evolutive-UMR5558 >>>>> UCBL Lyon 1 -B?t. Gr?gory Mendel >>>>> 43 bd du 11 novembre 1918 >>>>> >>>>> 69622 VILLEURBANNE cedex >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 eulergaussriemann at gmail.com Fri Oct 20 17:38:52 2017 From: eulergaussriemann at gmail.com (David Goldsmith) Date: Fri, 20 Oct 2017 14:38:52 -0700 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image Message-ID: Hi! I spent a good part of yesterday trying to figure this out on my own, without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI figure I export to a png using print_figure; here's sample code: PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array curfig = PLB.Figure fig = PLB.gcf() # next three lines are in my code; don't seem relevant, but I include them in case they are ax = fig.gca() ax.xaxis.set_ticks([]) ax.yaxis.set_ticks([]) fig.canvas.print_figure(fn + '.png', dpi=300, bbox_inches='tight', pad_inches=-1.0 / 72) The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) Thanks! DLG -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Fri Oct 20 17:59:59 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Fri, 20 Oct 2017 14:59:59 -0700 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: Message-ID: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> Hi David, What are you trying to achieve as the output? An image with no white space? `bbox_inches=tight` changes the size of the figure to get rid of white space around it. Prob not what you really want. Drilling down into `canvas` shouldn?t really be necessary. What is `PLB`? etc? This will get you pretty close if you just want an image w/ no white space. But I?m not 100% sure that every pixel has been preserved? ``` import matplotlib.pyplot as plt import numpy as np im = np.floor(np.random.rand(3601,2401)*100) fig, ax = plt.subplots(figsize = (2401/300, 3601/300), dpi=300) # turn off axis and labels ax.set_axis_off() # fill the figure ax.set_position([0., 0., 1., 1.]) ax.imshow(im) fig.savefig('Test.png', dpi=300) ``` > On 20 Oct 2017, at 14:38 PM, David Goldsmith wrote: > > Hi! I spent a good part of yesterday trying to figure this out on my own, without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI figure I export to a png using print_figure; here's sample code: > > PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array > curfig = PLB.Figure > fig = PLB.gcf() > # next three lines are in my code; don't seem relevant, but I include them in case they are > ax = fig.gca() > ax.xaxis.set_ticks([]) > ax.yaxis.set_ticks([]) > > fig.canvas.print_figure(fn + '.png', > dpi=300, > bbox_inches='tight', > pad_inches=-1.0 / 72) > The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). > What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) > Thanks! > DLG > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From warren.weckesser at gmail.com Fri Oct 20 18:28:29 2017 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Fri, 20 Oct 2017 18:28:29 -0400 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: Message-ID: On Fri, Oct 20, 2017 at 5:38 PM, David Goldsmith < eulergaussriemann at gmail.com> wrote: > Hi! I spent a good part of yesterday trying to figure this out on my own, > without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI figure > I export to a png using print_figure; here's sample code: > > David, If you are trying to write the numpy array directly to a PNG file, an alternative to matplotlib is a package that I created called numpngw: https://pypi.python.org/pypi/numpngw (github: https://github.com/WarrenWeckesser/numpngw). Both those links show several examples of its use. numpngw uses just Python and NumPy, so it is easy to install. Warren PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array > curfig = PLB.Figure > fig = PLB.gcf() > # next three lines are in my code; don't seem relevant, but I include them in case they are > > ax = fig.gca() > ax.xaxis.set_ticks([]) > ax.yaxis.set_ticks([]) > > fig.canvas.print_figure(fn + '.png', > dpi=300, > > bbox_inches='tight', > > pad_inches=-1.0 / 72) > > The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). > > What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) > > Thanks! > > DLG > > > > _______________________________________________ > 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 eulergaussriemann at gmail.com Fri Oct 20 18:33:49 2017 From: eulergaussriemann at gmail.com (David Goldsmith) Date: Fri, 20 Oct 2017 22:33:49 +0000 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> References: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> Message-ID: On Fri, Oct 20, 2017 at 3:00 PM Jody Klymak wrote: > Hi David, > > What are you trying to achieve as the output? An image with no white > space? > Yes, and no edge, but one that replaces that white space with my figure. in other words, if what is going on is that my figure w/ the white space is what is 3600x2400, how do I get the full 3600x2400 to be my figure? (I don?t care if it puts white space around that because I figured out an ?alternative? way to get rid of that). But mostly, I?d just like to understand what?s going on, because what?s happening now makes absolutely no sense to me whatsoever. > `bbox_inches=tight` changes the size of the figure to get rid of white > space around it. Prob not what you really want. > OK, so that may be the problem: what?s the ?proper? way to ?get rid of? the white space, module what I said above. > > Drilling down into `canvas` shouldn?t really be necessary. > I?m all ears. > > What is `PLB`? etc? > import pylab as PLB > > This will get you pretty close if you just want an image w/ no white > space. But I?m not 100% sure that every pixel has been preserved? > > > ``` > import matplotlib.pyplot as plt > import numpy as np > > im = np.floor(np.random.rand(3601,2401)*100) > > fig, ax = plt.subplots(figsize = (2401/300, 3601/300), dpi=300) > > # turn off axis and labels > ax.set_axis_off() > # fill the figure > ax.set_position([0., 0., 1., 1.]) > ax.imshow(im) > fig.savefig('Test.png', dpi=300) > Ok, I?ll try that, thanks. DLG > ``` > > > > > On 20 Oct 2017, at 14:38 PM, David Goldsmith > wrote: > > Hi! I spent a good part of yesterday trying to figure this out on my own, > without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI figure > I export to a png using print_figure; here's sample code: > > PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array > curfig = PLB.Figure > fig = PLB.gcf() > # next three lines are in my code; don't seem relevant, but I include them in case they are > > ax = fig.gca() > ax.xaxis.set_ticks([]) > ax.yaxis.set_ticks([]) > > fig.canvas.print_figure(fn + '.png', > dpi=300, > > bbox_inches='tight', > > pad_inches=-1.0 / 72) > > The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). > > What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) > > Thanks! > > DLG > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > -- > Jody Klymak > http://web.uvic.ca/~jklymak/ > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eulergaussriemann at gmail.com Fri Oct 20 18:36:30 2017 From: eulergaussriemann at gmail.com (David Goldsmith) Date: Fri, 20 Oct 2017 22:36:30 +0000 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: Message-ID: Thanks. Does it have pylab?s range of built in color maps? Does it even use colormaps, or do I have to write my own (or ?copy? them from MPL). DLG On Fri, Oct 20, 2017 at 3:28 PM Warren Weckesser wrote: > On Fri, Oct 20, 2017 at 5:38 PM, David Goldsmith < > eulergaussriemann at gmail.com> wrote: > >> Hi! I spent a good part of yesterday trying to figure this out on my >> own, without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI >> figure I export to a png using print_figure; here's sample code: >> >> > > David, > > If you are trying to write the numpy array directly to a PNG file, an > alternative to matplotlib is a package that I created called numpngw: > https://pypi.python.org/pypi/numpngw (github: > https://github.com/WarrenWeckesser/numpngw). Both those links show > several examples of its use. numpngw uses just Python and NumPy, so it is > easy to install. > > Warren > > > PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array >> curfig = PLB.Figure >> fig = PLB.gcf() >> # next three lines are in my code; don't seem relevant, but I include them in case they are >> >> ax = fig.gca() >> ax.xaxis.set_ticks([]) >> ax.yaxis.set_ticks([]) >> >> fig.canvas.print_figure(fn + '.png', >> dpi=300, >> >> bbox_inches='tight', >> >> pad_inches=-1.0 / 72) >> >> The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). >> >> What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) >> >> Thanks! >> >> DLG >> >> >> >> _______________________________________________ >> 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 jklymak at uvic.ca Fri Oct 20 18:44:54 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Fri, 20 Oct 2017 15:44:54 -0700 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> Message-ID: <686398FC-DCB6-4367-AA99-E841CC4846B8@uvic.ca> > On 20 Oct 2017, at 15:33 PM, David Goldsmith wrote: > > But mostly, I?d just like to understand what?s going on, because what?s happening now makes absolutely no sense to me whatsoever. Ha! I think you are approaching this from the point of view of an image processing library or something like Photoshop where you want your image to be 6x8 and 300 dpi, and you expect 1800x2400 pixels. Thats not *really* what matplotlib is for. It really is for presentation of scientific data. So, I have a 500x600 matrix of data, I may use `imshow` to plot it up, but most people don?t care about the dpi of those pixels, so they will just set the dpi to something that shows all the data clearly. Much more important is the ability to have axis labels, annotations, etc. Its not to say that you can?t be careful and get what you want. I think what I sent you is pretty close. But the library is not trying to conserve pixels. Anyway, what I sent should be clear enough. I think what you were missing was setting the figure size to the size you wanted before trying to draw on it. Cheers, Jody -------------- next part -------------- An HTML attachment was scrubbed... URL: From eulergaussriemann at gmail.com Fri Oct 20 19:02:19 2017 From: eulergaussriemann at gmail.com (David Goldsmith) Date: Fri, 20 Oct 2017 23:02:19 +0000 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: <686398FC-DCB6-4367-AA99-E841CC4846B8@uvic.ca> References: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> <686398FC-DCB6-4367-AA99-E841CC4846B8@uvic.ca> Message-ID: OK, thanks for your help. What I?m doing is somewhere in between: I?m making my own ?fractals,? ?from scratch?; so if im going to the trouble of computing a 3600x2400 grid so that I can have a 300 DPI image end up being 12x8, that?s what I want to end up with (i don?t want to compute any more than I have to, but by the same token, I want to see everything I?m computing). Anyway, i?ll see if that does what I?m after and reply again if not. (Though I?d still like to know what?s going on under the hood, so that I can exploit that if I choose.) Thanks again! DLG On Fri, Oct 20, 2017 at 3:44 PM Jody Klymak wrote: > > > On 20 Oct 2017, at 15:33 PM, David Goldsmith > wrote: > > But mostly, I?d just like to understand what?s going on, because what?s > happening now makes absolutely no sense to me whatsoever. > >> > Ha! > > I think you are approaching this from the point of view of an image > processing library or something like Photoshop where you want your image to > be 6x8 and 300 dpi, and you expect 1800x2400 pixels. > > Thats not *really* what matplotlib is for. It really is for presentation > of scientific data. So, I have a 500x600 matrix of data, I may use > `imshow` to plot it up, but most people don?t care about the dpi of those > pixels, so they will just set the dpi to something that shows all the data > clearly. Much more important is the ability to have axis labels, > annotations, etc. > > Its not to say that you can?t be careful and get what you want. I think > what I sent you is pretty close. But the library is not trying to conserve > pixels. > > Anyway, what I sent should be clear enough. I think what you were missing > was setting the figure size to the size you wanted before trying to draw on > it. > > Cheers, Jody > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Fri Oct 20 20:32:57 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Fri, 20 Oct 2017 17:32:57 -0700 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: <45743492-C845-4493-A8EE-585FB33040C3@uvic.ca> <686398FC-DCB6-4367-AA99-E841CC4846B8@uvic.ca> Message-ID: Fair enough. Just to be safe, just do dpi=600! It?ll be big, but... Cheers, Jody > On Oct 20, 2017, at 16:02 PM, David Goldsmith wrote: > > OK, thanks for your help. > > What I?m doing is somewhere in between: I?m making my own ?fractals,? ?from scratch?; so if im going to the trouble of computing a 3600x2400 grid so that I can have a 300 DPI image end up being 12x8, that?s what I want to end up with (i don?t want to compute any more than I have to, but by the same token, I want to see everything I?m computing). Anyway, i?ll see if that does what I?m after and reply again if not. (Though I?d still like to know what?s going on under the hood, so that I can exploit that if I choose.) > > Thanks again! > > DLG > > On Fri, Oct 20, 2017 at 3:44 PM Jody Klymak > wrote: > > >> On 20 Oct 2017, at 15:33 PM, David Goldsmith > wrote: >> >> But mostly, I?d just like to understand what?s going on, because what?s happening now makes absolutely no sense to me whatsoever. > > Ha! > > I think you are approaching this from the point of view of an image processing library or something like Photoshop where you want your image to be 6x8 and 300 dpi, and you expect 1800x2400 pixels. > > Thats not *really* what matplotlib is for. It really is for presentation of scientific data. So, I have a 500x600 matrix of data, I may use `imshow` to plot it up, but most people don?t care about the dpi of those pixels, so they will just set the dpi to something that shows all the data clearly. Much more important is the ability to have axis labels, annotations, etc. > > Its not to say that you can?t be careful and get what you want. I think what I sent you is pretty close. But the library is not trying to conserve pixels. > > Anyway, what I sent should be clear enough. I think what you were missing was setting the figure size to the size you wanted before trying to draw on it. > > Cheers, Jody > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From warren.weckesser at gmail.com Sat Oct 21 08:27:09 2017 From: warren.weckesser at gmail.com (Warren Weckesser) Date: Sat, 21 Oct 2017 08:27:09 -0400 Subject: [Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image In-Reply-To: References: Message-ID: On Fri, Oct 20, 2017 at 6:36 PM, David Goldsmith < eulergaussriemann at gmail.com> wrote: > Thanks. Does it have pylab?s range of built in color maps? Does it even > use colormaps, or do I have to write my own (or ?copy? them from MPL). > No, numpngw doesn't use colormaps. You'd have to map and scale the image to an array of integers yourself. You could use matplotlib for the mapping. For example, if foo is a 2-D array of floats with values between 0 and 1, you could do something like mapped_foo = mpl.cm.viridis(foo) # Use matplotlib's 'viridis' colormap. maxint = 2**16 img = np.floor(maxint*mapped_foo) img[img == maxint] = maxint - 1 numpngw.write_png("foo.png", img.astype(np.uint16)) That would create a 16 bit RGB PNG file. Warren > DLG > > On Fri, Oct 20, 2017 at 3:28 PM Warren Weckesser < > warren.weckesser at gmail.com> wrote: > >> On Fri, Oct 20, 2017 at 5:38 PM, David Goldsmith < >> eulergaussriemann at gmail.com> wrote: >> >>> Hi! I spent a good part of yesterday trying to figure this out on my >>> own, without success, so I'm posting. I have a 3601x2401 pixel, 300 DPI >>> figure I export to a png using print_figure; here's sample code: >>> >>> >> >> David, >> >> If you are trying to write the numpy array directly to a PNG file, an >> alternative to matplotlib is a package that I created called numpngw: >> https://pypi.python.org/pypi/numpngw (github: https://github.com/ >> WarrenWeckesser/numpngw). Both those links show several examples of its >> use. numpngw uses just Python and NumPy, so it is easy to install. >> >> Warren >> >> >> PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array >>> curfig = PLB.Figure >>> fig = PLB.gcf() >>> # next three lines are in my code; don't seem relevant, but I include them in case they are >>> >>> ax = fig.gca() >>> ax.xaxis.set_ticks([]) >>> ax.yaxis.set_ticks([]) >>> >>> fig.canvas.print_figure(fn + '.png', >>> dpi=300, >>> >>> bbox_inches='tight', >>> >>> pad_inches=-1.0 / 72) >>> >>> The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried). >>> >>> What's going on, and how do I "fix" it? (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different? If it has something to do with compression, is there some undocumented way to say "no compression" and will that have the desired effect?) >>> >>> Thanks! >>> >>> DLG >>> >>> >>> >>> _______________________________________________ >>> 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 ardeal.liang at philips.com Fri Oct 27 03:50:45 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Fri, 27 Oct 2017 07:50:45 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Message-ID: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? [cid:image003.jpg at 01D34F3B.58162F30] Best Regards, Ardeal Liang ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.jpg Type: image/jpeg Size: 19109 bytes Desc: image003.jpg URL: From efiring at hawaii.edu Fri Oct 27 03:59:43 2017 From: efiring at hawaii.edu (Eric Firing) Date: Thu, 26 Oct 2017 21:59:43 -1000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: Message-ID: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > Hi, > > If I put the mouse on the figure, x and y axis are displayed on the > left-bottom corner of the figure. > but the x axis is displayed as scientific notation, I want it to be > displayed as decimal notation. > > how to make x axis or y axis values displayed as decimal notation on the > left-bottom corner? > > *Best Regards,* > > *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric From ardeal.liang at philips.com Fri Oct 27 04:45:31 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Fri, 27 Oct 2017 08:45:31 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> Message-ID: Hi Eric, I add you code to my code: fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. [cid:image001.jpg at 01D34F42.FD042720] Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > Hi, > > If I put the mouse on the figure, x and y axis are displayed on the > left-bottom corner of the figure. > but the x axis is displayed as scientific notation, I want it to be > displayed as decimal notation. > > how to make x axis or y axis values displayed as decimal notation on > the left-bottom corner? > > *Best Regards,* > > *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 137486 bytes Desc: image001.jpg URL: From berceanu at runbox.com Fri Oct 27 07:17:54 2017 From: berceanu at runbox.com (Andrei Berceanu) Date: Fri, 27 Oct 2017 13:17:54 +0200 (CEST) Subject: [Matplotlib-users] loop through x and y axes Message-ID: Hi all, Please consider this code: fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=[14,4]) for ax in (ax1, ax2): ax.set_xlabel(labels[0]) ax.set_ylabel(labels[1]) This could be simplified if I could just loop though the x and y axes of each subplot, something like: for index, ax in enumerate((ax1, ax2)): ax.set_label[index](labels[index]) Is there some way of achieving this in Matplotlib? From what I found, it seems one can only refer to the axes using x and y, and so I don't know how to loop over both of them. Thank you, Andrei From joferkington at gmail.com Fri Oct 27 11:05:52 2017 From: joferkington at gmail.com (Joe Kington) Date: Fri, 27 Oct 2017 10:05:52 -0500 Subject: [Matplotlib-users] loop through x and y axes In-Reply-To: References: Message-ID: It sounds like you want to use the ``set_label_text`` method of the ``Axis`` instances directly? Perhaps something like: import matplotlib.pyplot as plt labels = ['xlabel', 'ylabel'] fig, axes = plt.subplots(ncols=2) for ax in axes: for axis, label in zip([ax.xaxis, ax.yaxis], labels): axis.set(label_text=label) fig.tight_layout() plt.show() However, that's not really much cleaner than doing: import matplotlib.pyplot as plt fig, axes = plt.subplots(ncols=2) for ax in axes: ax.set(xlabel='xlabel', ylabel='ylabel') fig.tight_layout() plt.show() However, I might be misunderstanding your question entirely... Hope that helps a bit, anyway. -Joe On Fri, Oct 27, 2017 at 6:17 AM, Andrei Berceanu wrote: > Hi all, > > Please consider this code: > > fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=[14,4]) > > for ax in (ax1, ax2): > ax.set_xlabel(labels[0]) > ax.set_ylabel(labels[1]) > > This could be simplified if I could just loop though the x and y axes of > each subplot, something like: > > for index, ax in enumerate((ax1, ax2)): > ax.set_label[index](labels[index]) > > Is there some way of achieving this in Matplotlib? From what I found, it > seems one can only refer to the axes using x and y, and so I don't know how > to loop over both of them. > > Thank you, > Andrei > _______________________________________________ > 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 ardeal.liang at philips.com Fri Oct 27 04:07:40 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Fri, 27 Oct 2017 08:07:40 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> Message-ID: Hi Eric, I added your code to my code: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel='rawdata') axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > Hi, > > If I put the mouse on the figure, x and y axis are displayed on the > left-bottom corner of the figure. > but the x axis is displayed as scientific notation, I want it to be > displayed as decimal notation. > > how to make x axis or y axis values displayed as decimal notation on > the left-bottom corner? > > *Best Regards,* > > *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Fri Oct 27 11:39:38 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Fri, 27 Oct 2017 08:39:38 -0700 Subject: [Matplotlib-users] loop through x and y axes In-Reply-To: References: Message-ID: <1D56B271-0D0E-43B6-90DB-F51ACB0A6633@uvic.ca> How about, as recently pointed out by @anntzer on github: ```python fig, axs = plt.subplots(1, 2, figsize=[14, 4]) plt.setp(axs, ?xlabel?, labels[0], ?ylabel?, labels[1]) ``` or, suppose you don?t want to repeat labels except on outer ```python fig, axs = plt.subplots(3, 3, figsize=[14, 4]) plt.setp(axs[-1,:], ?xlabel?, labels[0]) plt.setp(axs[0,:], ?ylabel?, labels[1]) ``` Cheers, Jody > On 27 Oct 2017, at 4:17 AM, Andrei Berceanu wrote: > > Hi all, > > Please consider this code: > > fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=[14,4]) > > for ax in (ax1, ax2): > ax.set_xlabel(labels[0]) > ax.set_ylabel(labels[1]) > > This could be simplified if I could just loop though the x and y axes of each subplot, something like: > > for index, ax in enumerate((ax1, ax2)): > ax.set_label[index](labels[index]) > > Is there some way of achieving this in Matplotlib? From what I found, it seems one can only refer to the axes using x and y, and so I don't know how to loop over both of them. > > Thank you, > Andrei > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/ From efiring at hawaii.edu Fri Oct 27 13:22:42 2017 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 27 Oct 2017 07:22:42 -1000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> Message-ID: <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: > Hi Eric, > > I added your code to my code: > > *from *matplotlib.ticker *import *ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > > /# ax.fmt_xaxis = fmt_no_sci > > /prow = 4 > pcol = 1 > pidx = 0 > fig = plt.figure() > pidx += 1 > axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) > axx.plot(np.abs(testdata)) > > axx.fmt_xaxis = fmt_no_sci > > The *x axis value displayed at the left-bottom corner of the figure*is > still scientific notation, but not decimal notation. > > Best Regards, > > Ardeal Liang > > -----Original Message----- > From: Matplotlib-users > [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On > Behalf Of Eric Firing > Sent: 2017?10?27? 16:00 > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at > left-bottom corner of figure > > On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > > > Hi, > > > > > > If I put the mouse on the figure, x and y axis are displayed on the > > > left-bottom corner of the figure. > > > but the x axis is displayed as scientific notation, I want it to be > > > displayed as decimal notation. > > > > > > how to make x axis or y axis values displayed as decimal notation on > > > the left-bottom corner? > > > > > > *Best Regards,* > > > > > > *Ardeal Liang* > > Something like this, assuming your Axes is ax: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > > fmt_no_sci.set_scientific(False) > > ax.fmt_xaxis = fmt_no_sci > > Eric > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ------------------------------------------------------------------------ > The information contained in this email may be confidential and/or > legally protected under applicable law. The message is intended solely > for the addressee(s). If you are not the intended recipient, you are > hereby notified that any use, forwarding, dissemination, or reproduction > of this email is strictly prohibited and may be unlawful. If you are not > the intended recipient, please contact the sender by return e-mail and > destroy all copies of the original email. From ardeal.liang at philips.com Sun Oct 29 20:46:04 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 00:46:04 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> Message-ID: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG ; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: > Hi Eric, > > I added your code to my code: > > *from *matplotlib.ticker *import *ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > > /# ax.fmt_xaxis = fmt_no_sci > > /prow = 4 > pcol = 1 > pidx = 0 > fig = plt.figure() > pidx += 1 > axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) > axx.plot(np.abs(testdata)) > > axx.fmt_xaxis = fmt_no_sci > > The *x axis value displayed at the left-bottom corner of the figure*is > still scientific notation, but not decimal notation. > > Best Regards, > > Ardeal Liang > > -----Original Message----- > From: Matplotlib-users > [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] > On Behalf Of Eric Firing > Sent: 2017?10?27? 16:00 > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at > left-bottom corner of figure > > On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > > > Hi, > > > > > > If I put the mouse on the figure, x and y axis are displayed on the > > > left-bottom corner of the figure. > > > but the x axis is displayed as scientific notation, I want it to be > > > displayed as decimal notation. > > > > > > how to make x axis or y axis values displayed as decimal notation > on > > > the left-bottom corner? > > > > > > *Best Regards,* > > > > > > *Ardeal Liang* > > Something like this, assuming your Axes is ax: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > > fmt_no_sci.set_scientific(False) > > ax.fmt_xaxis = fmt_no_sci > > Eric > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ---------------------------------------------------------------------- > -- The information contained in this email may be confidential and/or > legally protected under applicable law. The message is intended solely > for the addressee(s). If you are not the intended recipient, you are > hereby notified that any use, forwarding, dissemination, or > reproduction of this email is strictly prohibited and may be unlawful. > If you are not the intended recipient, please contact the sender by > return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. From jklymak at uvic.ca Sun Oct 29 22:24:14 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sun, 29 Oct 2017 19:24:14 -0700 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> Message-ID: <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> > On Oct 29, 2017, at 17:46 PM, Ardeal LIANG wrote: > > HI Eric, > > Did you review the picture attached in my former email? > I suspect you go to the wrong direction about what I want to ask. > > Best Regards, > Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody > > -----Original Message----- > From: Eric Firing [mailto:efiring at hawaii.edu ] > Sent: 2017?10?28? 1:23 > To: Ardeal LIANG >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > I'm getting a different result, but on the basic point we now agree: > the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. > > Examples: > > def format_as_int(num): > return str(int(num)) > > def format_float_no_sci(num): > return "%f" % num > > Eric > > On 2017/10/26 10:07 PM, Ardeal LIANG wrote: >> Hi Eric, >> >> I added your code to my code: >> >> *from *matplotlib.ticker *import *ScalarFormatter >> >> fmt_no_sci = ScalarFormatter(useOffset=False) >> fmt_no_sci.set_scientific(False) >> >> /# ax.fmt_xaxis = fmt_no_sci >> >> /prow = 4 >> pcol = 1 >> pidx = 0 >> fig = plt.figure() >> pidx += 1 >> axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) >> axx.plot(np.abs(testdata)) >> >> axx.fmt_xaxis = fmt_no_sci >> >> The *x axis value displayed at the left-bottom corner of the figure*is >> still scientific notation, but not decimal notation. >> >> Best Regards, >> >> Ardeal Liang >> >> -----Original Message----- >> From: Matplotlib-users >> [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] >> On Behalf Of Eric Firing >> Sent: 2017?10?27? 16:00 >> To: matplotlib-users at python.org >> Subject: Re: [Matplotlib-users] Scientific notation digits at >> left-bottom corner of figure >> >> On 2017/10/26 9:50 PM, Ardeal LIANG wrote: >> >>> Hi, >> >>> >> >>> If I put the mouse on the figure, x and y axis are displayed on the >> >>> left-bottom corner of the figure. >> >>> but the x axis is displayed as scientific notation, I want it to be >> >>> displayed as decimal notation. >> >>> >> >>> how to make x axis or y axis values displayed as decimal notation >> on >> >>> the left-bottom corner? >> >>> >> >>> *Best Regards,* >> >>> >> >>> *Ardeal Liang* >> >> Something like this, assuming your Axes is ax: >> >> from matplotlib.ticker import ScalarFormatter >> >> fmt_no_sci = ScalarFormatter(useOffset=False) >> >> fmt_no_sci.set_scientific(False) >> >> ax.fmt_xaxis = fmt_no_sci >> >> Eric >> >> _______________________________________________ >> >> Matplotlib-users mailing list >> >> Matplotlib-users at python.org >> >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> >> ---------------------------------------------------------------------- >> -- The information contained in this email may be confidential and/or >> legally protected under applicable law. The message is intended solely >> for the addressee(s). If you are not the intended recipient, you are >> hereby notified that any use, forwarding, dissemination, or >> reproduction of this email is strictly prohibited and may be unlawful. >> If you are not the intended recipient, please contact the sender by >> return e-mail and destroy all copies of the original email. > > > ________________________________ > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > _______________________________________________ > 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 mckauf at gmail.com Sun Oct 29 22:31:30 2017 From: mckauf at gmail.com (Mike Kaufman) Date: Sun, 29 Oct 2017 22:31:30 -0400 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: <6d55cfbf-71bd-5dd1-5b41-7ed989362cd6@gmail.com> I believe he's talking about the coordinates label in the navigation toolbar... M On 10/29/17 10:24 PM, Jody Klymak wrote: > > >> On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > > wrote: >> >> HI Eric, >> >> Did you review the picture attached in my former email? >> I suspect you go to the wrong direction about what I want to ask. >> >> Best Regards, >> Ardeal Liang > > Hi Ardeal, > > Its not clear to me what you want. Do you want 3.2 x 10^3 instead of > 0.0032? The former is scientific and the latter decimal. > > Thanks, Jody > > > >> >> -----Original Message----- >> From: Eric Firing [mailto:efiring at hawaii.edu] >> Sent: 2017?10?28? 1:23 >> To: Ardeal LIANG > >; matplotlib-users at python.org >> >> Subject: Re: [Matplotlib-users] Scientific notation digits at >> left-bottom corner of figure >> >> I'm getting a different result, but on the basic point we now agree: >> the ScalarFormatter is not the right tool for this. What you need is >> a function that takes a number and returns the kind of string you want. >> >> Examples: >> >> def format_as_int(num): >> return str(int(num)) >> >> def format_float_no_sci(num): >> return "%f" % num >> >> Eric >> >> On 2017/10/26 10:07 PM, Ardeal LIANG wrote: >>> Hi Eric, >>> >>> I added your code to my code: >>> >>> *from *matplotlib.ticker *import *ScalarFormatter >>> >>> fmt_no_sci = ScalarFormatter(useOffset=False) >>> fmt_no_sci.set_scientific(False) >>> >>> /# ax.fmt_xaxis = fmt_no_sci >>> >>> /prow = 4 >>> pcol = 1 >>> pidx = 0 >>> fig = plt.figure() >>> pidx += 1 >>> axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) >>> axx.plot(np.abs(testdata)) >>> >>> axx.fmt_xaxis = fmt_no_sci >>> >>> The *x axis value displayed at the left-bottom corner of the figure*is >>> still scientific notation, but not decimal notation. >>> >>> Best Regards, >>> >>> Ardeal Liang >>> >>> -----Original Message----- >>> From: Matplotlib-users >>> [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] >>> On Behalf Of Eric Firing >>> Sent: 2017?10?27? 16:00 >>> To: matplotlib-users at python.org >>> Subject: Re: [Matplotlib-users] Scientific notation digits at >>> left-bottom corner of figure >>> >>> On 2017/10/26 9:50 PM, Ardeal LIANG wrote: >>> >>>> Hi, >>> >>>> >>> >>>> If I put the mouse on the figure, x and y axis are displayed on the >>> >>>> left-bottom corner of the figure. >>> >>>> but the x axis is displayed as scientific notation, I want it to be >>> >>>> displayed as decimal notation. >>> >>>> >>> >>>> how to make x axis or y axis values displayed as decimal notation >>> on >>> >>>> the left-bottom corner? >>> >>>> >>> >>>> *Best Regards,* >>> >>>> >>> >>>> *Ardeal Liang* >>> >>> Something like this, assuming your Axes is ax: >>> >>> from matplotlib.ticker import ScalarFormatter >>> >>> fmt_no_sci = ScalarFormatter(useOffset=False) >>> >>> fmt_no_sci.set_scientific(False) >>> >>> ax.fmt_xaxis = fmt_no_sci >>> >>> Eric >>> >>> _______________________________________________ >>> >>> Matplotlib-users mailing list >>> >>> Matplotlib-users at python.org >>> >>> >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >>> >>> ---------------------------------------------------------------------- >>> -- The information contained in this email may be confidential and/or >>> legally protected under applicable law. The message is intended solely >>> for the addressee(s). If you are not the intended recipient, you are >>> hereby notified that any use, forwarding, dissemination, or >>> reproduction of this email is strictly prohibited and may be unlawful. >>> If you are not the intended recipient, please contact the sender by >>> return e-mail and destroy all copies of the original email. >> >> >> ________________________________ >> The information contained in this email may be confidential and/or >> legally protected under applicable law. The message is intended solely >> for the addressee(s). If you are not the intended recipient, you are >> hereby notified that any use, forwarding, dissemination, or >> reproduction of this email is strictly prohibited and may be unlawful. >> If you are not the intended recipient, please contact the sender by >> return e-mail and destroy all copies of the original email. >> _______________________________________________ >> 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 ardeal.liang at philips.com Sun Oct 29 22:36:42 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 02:36:42 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: Hi Jody, I apologize if I said it backwards! I think you now get what I want. I tried your code. It didn?t work still. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:34 To: Ardeal LIANG Cc: Firing Eric ; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Did you try: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. I think you just said it backwards: You want scientific ntoation, not decimal notation. Cheers, Jody On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: Hi Jody, Please check the red ellipse in the picture. I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:24 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: Hi Eric, I added your code to my code: *from *matplotlib.ticker *import *ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) /# ax.fmt_xaxis = fmt_no_sci /prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The *x axis value displayed at the left-bottom corner of the figure*is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? *Best Regards,* *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ---------------------------------------------------------------------- -- The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Sun Oct 29 22:33:46 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sun, 29 Oct 2017 19:33:46 -0700 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: Did you try: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. I think you just said it backwards: You want scientific ntoation, not decimal notation. Cheers, Jody > On Oct 29, 2017, at 19:29 PM, Ardeal LIANG wrote: > > Hi Jody, > > Please check the red ellipse in the picture. > > I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. > > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > # ax.fmt_xaxis = fmt_no_sci > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(testdata) > ax.fmt_xaxis = fmt_no_sci > plt.show(0) > > The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. > Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. > > > > > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca] > Sent: 2017?10?30? 10:24 > To: Ardeal LIANG > Cc: Firing Eric ; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > > > > On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: > > HI Eric, > > Did you review the picture attached in my former email? > I suspect you go to the wrong direction about what I want to ask. > > Best Regards, > Ardeal Liang > > Hi Ardeal, > > Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. > > Thanks, Jody > > > > > > -----Original Message----- > From: Eric Firing [mailto:efiring at hawaii.edu ] > Sent: 2017?10?28? 1:23 > To: Ardeal LIANG >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > I'm getting a different result, but on the basic point we now agree: > the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. > > Examples: > > def format_as_int(num): > return str(int(num)) > > def format_float_no_sci(num): > return "%f" % num > > Eric > > On 2017/10/26 10:07 PM, Ardeal LIANG wrote: > > Hi Eric, > > I added your code to my code: > > *from *matplotlib.ticker *import *ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > > /# ax.fmt_xaxis = fmt_no_sci > > /prow = 4 > pcol = 1 > pidx = 0 > fig = plt.figure() > pidx += 1 > axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) > axx.plot(np.abs(testdata)) > > axx.fmt_xaxis = fmt_no_sci > > The *x axis value displayed at the left-bottom corner of the figure*is > still scientific notation, but not decimal notation. > > Best Regards, > > Ardeal Liang > > -----Original Message----- > From: Matplotlib-users > [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org ] > On Behalf Of Eric Firing > Sent: 2017?10?27? 16:00 > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at > left-bottom corner of figure > > On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > > > Hi, > > > > > > If I put the mouse on the figure, x and y axis are displayed on the > > > left-bottom corner of the figure. > > > but the x axis is displayed as scientific notation, I want it to be > > > displayed as decimal notation. > > > > > > how to make x axis or y axis values displayed as decimal notation > on > > > the left-bottom corner? > > > > > > *Best Regards,* > > > > > > *Ardeal Liang* > > Something like this, assuming your Axes is ax: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > > fmt_no_sci.set_scientific(False) > > ax.fmt_xaxis = fmt_no_sci > > Eric > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ---------------------------------------------------------------------- > -- The information contained in this email may be confidential and/or > legally protected under applicable law. The message is intended solely > for the addressee(s). If you are not the intended recipient, you are > hereby notified that any use, forwarding, dissemination, or > reproduction of this email is strictly prohibited and may be unlawful. > If you are not the intended recipient, please contact the sender by > return e-mail and destroy all copies of the original email. > > > ________________________________ > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Sun Oct 29 22:44:13 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sun, 29 Oct 2017 19:44:13 -0700 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: <8DF3FBE8-BBD1-4051-AEB2-CD1C6786CABB@uvic.ca> Maybe? def format_coord(x, y): return 'x=%4.4e, y=%4.4e?%(x, y)) # or whatever formatting you want ax.format_coord = format_coord Cheers, Jody > On Oct 29, 2017, at 19:36 PM, Ardeal LIANG wrote: > > Hi Jody, > > I apologize if I said it backwards! > I think you now get what I want. > > I tried your code. It didn?t work still. > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca] > Sent: 2017?10?30? 10:34 > To: Ardeal LIANG > Cc: Firing Eric ; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > Did you try: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(True) # NOTE True instead of False. > > I think you just said it backwards: You want scientific ntoation, not decimal notation. > > Cheers, Jody > > > > On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: > > Hi Jody, > > Please check the red ellipse in the picture. > > I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. > > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > # ax.fmt_xaxis = fmt_no_sci > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(testdata) > ax.fmt_xaxis = fmt_no_sci > plt.show(0) > > The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. > Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. > > > > > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca ] > Sent: 2017?10?30? 10:24 > To: Ardeal LIANG > > Cc: Firing Eric >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > > > > > On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: > > HI Eric, > > Did you review the picture attached in my former email? > I suspect you go to the wrong direction about what I want to ask. > > Best Regards, > Ardeal Liang > > Hi Ardeal, > > Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. > > Thanks, Jody > > > > > > > -----Original Message----- > From: Eric Firing [mailto:efiring at hawaii.edu ] > Sent: 2017?10?28? 1:23 > To: Ardeal LIANG >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > I'm getting a different result, but on the basic point we now agree: > the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. > > Examples: > > def format_as_int(num): > return str(int(num)) > > def format_float_no_sci(num): > return "%f" % num > > Eric > > On 2017/10/26 10:07 PM, Ardeal LIANG wrote: > > > Hi Eric, > > I added your code to my code: > > *from *matplotlib.ticker *import *ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > > /# ax.fmt_xaxis = fmt_no_sci > > /prow = 4 > pcol = 1 > pidx = 0 > fig = plt.figure() > pidx += 1 > axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) > axx.plot(np.abs(testdata)) > > axx.fmt_xaxis = fmt_no_sci > > The *x axis value displayed at the left-bottom corner of the figure*is > still scientific notation, but not decimal notation. > > Best Regards, > > Ardeal Liang > > -----Original Message----- > From: Matplotlib-users > [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org ] > On Behalf Of Eric Firing > Sent: 2017?10?27? 16:00 > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at > left-bottom corner of figure > > On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > > > > Hi, > > > > > > > > If I put the mouse on the figure, x and y axis are displayed on the > > > > left-bottom corner of the figure. > > > > but the x axis is displayed as scientific notation, I want it to be > > > > displayed as decimal notation. > > > > > > > > how to make x axis or y axis values displayed as decimal notation > on > > > > the left-bottom corner? > > > > > > > > *Best Regards,* > > > > > > > > *Ardeal Liang* > > Something like this, assuming your Axes is ax: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > > fmt_no_sci.set_scientific(False) > > ax.fmt_xaxis = fmt_no_sci > > Eric > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ---------------------------------------------------------------------- > -- The information contained in this email may be confidential and/or > legally protected under applicable law. The message is intended solely > for the addressee(s). If you are not the intended recipient, you are > hereby notified that any use, forwarding, dissemination, or > reproduction of this email is strictly prohibited and may be unlawful. > If you are not the intended recipient, please contact the sender by > return e-mail and destroy all copies of the original email. > > > ________________________________ > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Sun Oct 29 22:53:18 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sun, 29 Oct 2017 19:53:18 -0700 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> <8DF3FBE8-BBD1-4051-AEB2-CD1C6786CABB@uvic.ca> Message-ID: <44BCB453-6271-46A9-B7A8-47F7AD311D64@uvic.ca> ax.format_coord is the function that formats the numbers shown in the red ellipse of your picture. Given that knowledge you can put anything in that red ellipse you want. Cheers, Jody > On Oct 29, 2017, at 19:46 PM, Ardeal LIANG wrote: > > Hi Jody, > > Did you check the picture I attached? You are still in the wrong direction about what I want?????.. > Please check the digit in the red ellipse in my picture!!!!!!!!!!!!!! > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca ] > Sent: 2017?10?30? 10:44 > To: Ardeal LIANG > > Cc: Firing Eric >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > Maybe? > > > def format_coord(x, y): > return 'x=%4.4e, y=%4.4e?%(x, y)) # or whatever formatting you want > > ax.format_coord = format_coord > > > Cheers, Jody > > > > > On Oct 29, 2017, at 19:36 PM, Ardeal LIANG > wrote: > > Hi Jody, > > I apologize if I said it backwards! > I think you now get what I want. > > I tried your code. It didn?t work still. > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca ] > Sent: 2017?10?30? 10:34 > To: Ardeal LIANG > > Cc: Firing Eric >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > Did you try: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(True) # NOTE True instead of False. > > I think you just said it backwards: You want scientific ntoation, not decimal notation. > > Cheers, Jody > > > > > On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: > > Hi Jody, > > Please check the red ellipse in the picture. > > I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. > > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > # ax.fmt_xaxis = fmt_no_sci > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(testdata) > ax.fmt_xaxis = fmt_no_sci > plt.show(0) > > The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. > Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. > > > > > > Best Regards, > Ardeal Liang > > From: Jody Klymak [mailto:jklymak at uvic.ca ] > Sent: 2017?10?30? 10:24 > To: Ardeal LIANG > > Cc: Firing Eric >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > > > > > > On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: > > HI Eric, > > Did you review the picture attached in my former email? > I suspect you go to the wrong direction about what I want to ask. > > Best Regards, > Ardeal Liang > > Hi Ardeal, > > Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. > > Thanks, Jody > > > > > > > > -----Original Message----- > From: Eric Firing [mailto:efiring at hawaii.edu ] > Sent: 2017?10?28? 1:23 > To: Ardeal LIANG >; matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure > > I'm getting a different result, but on the basic point we now agree: > the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. > > Examples: > > def format_as_int(num): > return str(int(num)) > > def format_float_no_sci(num): > return "%f" % num > > Eric > > On 2017/10/26 10:07 PM, Ardeal LIANG wrote: > > > > Hi Eric, > > I added your code to my code: > > *from *matplotlib.ticker *import *ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > fmt_no_sci.set_scientific(False) > > /# ax.fmt_xaxis = fmt_no_sci > > /prow = 4 > pcol = 1 > pidx = 0 > fig = plt.figure() > pidx += 1 > axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) > axx.plot(np.abs(testdata)) > > axx.fmt_xaxis = fmt_no_sci > > The *x axis value displayed at the left-bottom corner of the figure*is > still scientific notation, but not decimal notation. > > Best Regards, > > Ardeal Liang > > -----Original Message----- > From: Matplotlib-users > [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org ] > On Behalf Of Eric Firing > Sent: 2017?10?27? 16:00 > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] Scientific notation digits at > left-bottom corner of figure > > On 2017/10/26 9:50 PM, Ardeal LIANG wrote: > > > > > Hi, > > > > > > > > > > If I put the mouse on the figure, x and y axis are displayed on the > > > > > left-bottom corner of the figure. > > > > > but the x axis is displayed as scientific notation, I want it to be > > > > > displayed as decimal notation. > > > > > > > > > > how to make x axis or y axis values displayed as decimal notation > on > > > > > the left-bottom corner? > > > > > > > > > > *Best Regards,* > > > > > > > > > > *Ardeal Liang* > > Something like this, assuming your Axes is ax: > > from matplotlib.ticker import ScalarFormatter > > fmt_no_sci = ScalarFormatter(useOffset=False) > > fmt_no_sci.set_scientific(False) > > ax.fmt_xaxis = fmt_no_sci > > Eric > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ---------------------------------------------------------------------- > -- The information contained in this email may be confidential and/or > legally protected under applicable law. The message is intended solely > for the addressee(s). If you are not the intended recipient, you are > hereby notified that any use, forwarding, dissemination, or > reproduction of this email is strictly prohibited and may be unlawful. > If you are not the intended recipient, please contact the sender by > return e-mail and destroy all copies of the original email. > > > ________________________________ > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. > > > The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ardeal.liang at philips.com Sun Oct 29 22:42:06 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 02:42:06 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: Hi All, You can try to run the following code. If I put the mouse on the figure, the digit of x axis displayed on the left-bottom corner is scientific notation which is not what I want. I want it to be decimal notation. testdata = np.arange(0, 10000000, 1) # fmt_no_sci = ScalarFormatter(useOffset=False) # fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) Best Regards, Ardeal Liang From: Ardeal LIANG [mailto:ardeal.liang at lighting.com] Sent: 2017?10?30? 10:37 To: Jody Klymak ; Ardeal LIANG Cc: Firing Eric ; matplotlib-users at python.org Subject: RE: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Hi Jody, I apologize if I said it backwards! I think you now get what I want. I tried your code. It didn?t work still. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:34 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Did you try: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. I think you just said it backwards: You want scientific ntoation, not decimal notation. Cheers, Jody On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: Hi Jody, Please check the red ellipse in the picture. I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:24 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: Hi Eric, I added your code to my code: *from *matplotlib.ticker *import *ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) /# ax.fmt_xaxis = fmt_no_sci /prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The *x axis value displayed at the left-bottom corner of the figure*is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? *Best Regards,* *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ---------------------------------------------------------------------- -- The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ardeal.liang at philips.com Sun Oct 29 22:29:27 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 02:29:27 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> Message-ID: Hi Jody, Please check the red ellipse in the picture. I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. [cid:image001.jpg at 01D35169.F2F33F40] Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:24 To: Ardeal LIANG Cc: Firing Eric ; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: Hi Eric, I added your code to my code: *from *matplotlib.ticker *import *ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) /# ax.fmt_xaxis = fmt_no_sci /prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The *x axis value displayed at the left-bottom corner of the figure*is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? *Best Regards,* *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ---------------------------------------------------------------------- -- The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 127364 bytes Desc: image001.jpg URL: From ardeal.liang at philips.com Sun Oct 29 22:46:23 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 02:46:23 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <8DF3FBE8-BBD1-4051-AEB2-CD1C6786CABB@uvic.ca> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> <8DF3FBE8-BBD1-4051-AEB2-CD1C6786CABB@uvic.ca> Message-ID: Hi Jody, Did you check the picture I attached? You are still in the wrong direction about what I want?????.. Please check the digit in the red ellipse in my picture!!!!!!!!!!!!!! Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:44 To: Ardeal LIANG Cc: Firing Eric ; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Maybe? def format_coord(x, y): return 'x=%4.4e, y=%4.4e?%(x, y)) # or whatever formatting you want ax.format_coord = format_coord Cheers, Jody On Oct 29, 2017, at 19:36 PM, Ardeal LIANG > wrote: Hi Jody, I apologize if I said it backwards! I think you now get what I want. I tried your code. It didn?t work still. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:34 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Did you try: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. I think you just said it backwards: You want scientific ntoation, not decimal notation. Cheers, Jody On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: Hi Jody, Please check the red ellipse in the picture. I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:24 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: Hi Eric, I added your code to my code: *from *matplotlib.ticker *import *ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) /# ax.fmt_xaxis = fmt_no_sci /prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The *x axis value displayed at the left-bottom corner of the figure*is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? *Best Regards,* *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ---------------------------------------------------------------------- -- The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ardeal.liang at philips.com Sun Oct 29 22:55:38 2017 From: ardeal.liang at philips.com (Ardeal LIANG) Date: Mon, 30 Oct 2017 02:55:38 +0000 Subject: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure In-Reply-To: <44BCB453-6271-46A9-B7A8-47F7AD311D64@uvic.ca> References: <60935ee1-4b69-76a5-4c71-d2901cb00b2e@hawaii.edu> <135de16c-f71b-78aa-40bc-2b7e6279c0d6@hawaii.edu> <9ABC007B-267A-4A2D-8342-62917D281C88@uvic.ca> <8DF3FBE8-BBD1-4051-AEB2-CD1C6786CABB@uvic.ca> <44BCB453-6271-46A9-B7A8-47F7AD311D64@uvic.ca> Message-ID: This is the error message if I add your code to my test code: Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.5\helpers\pydev\pydevd.py", line 1591, in globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.5\helpers\pydev\pydevd.py", line 1018, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:/work/code_python/mwsignal/misc_experiment.py", line 49 SyntaxError: Non-ASCII character '\xe2' in file C:/work/code_python/mwsignal/misc_experiment.py on line 49, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:53 To: Ardeal LIANG Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure ax.format_coord is the function that formats the numbers shown in the red ellipse of your picture. Given that knowledge you can put anything in that red ellipse you want. Cheers, Jody On Oct 29, 2017, at 19:46 PM, Ardeal LIANG > wrote: Hi Jody, Did you check the picture I attached? You are still in the wrong direction about what I want?????.. Please check the digit in the red ellipse in my picture!!!!!!!!!!!!!! Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:44 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Maybe? def format_coord(x, y): return 'x=%4.4e, y=%4.4e?%(x, y)) # or whatever formatting you want ax.format_coord = format_coord Cheers, Jody On Oct 29, 2017, at 19:36 PM, Ardeal LIANG > wrote: Hi Jody, I apologize if I said it backwards! I think you now get what I want. I tried your code. It didn?t work still. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:34 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure Did you try: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(True) # NOTE True instead of False. I think you just said it backwards: You want scientific ntoation, not decimal notation. Cheers, Jody On Oct 29, 2017, at 19:29 PM, Ardeal LIANG > wrote: Hi Jody, Please check the red ellipse in the picture. I want the value 1.85092e+06 to be 1850922 in the red ellipse in the following picture. fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) # ax.fmt_xaxis = fmt_no_sci fig = plt.figure() ax = fig.add_subplot(111) ax.plot(testdata) ax.fmt_xaxis = fmt_no_sci plt.show(0) The x axis value displayed at the left-bottom corner of the figure is still scientific notation, but not decimal notation. Please check the x axis value displayed at the left-bottom corner of the figure in the red circle. Best Regards, Ardeal Liang From: Jody Klymak [mailto:jklymak at uvic.ca] Sent: 2017?10?30? 10:24 To: Ardeal LIANG > Cc: Firing Eric >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On Oct 29, 2017, at 17:46 PM, Ardeal LIANG > wrote: HI Eric, Did you review the picture attached in my former email? I suspect you go to the wrong direction about what I want to ask. Best Regards, Ardeal Liang Hi Ardeal, Its not clear to me what you want. Do you want 3.2 x 10^3 instead of 0.0032? The former is scientific and the latter decimal. Thanks, Jody -----Original Message----- From: Eric Firing [mailto:efiring at hawaii.edu] Sent: 2017?10?28? 1:23 To: Ardeal LIANG >; matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure I'm getting a different result, but on the basic point we now agree: the ScalarFormatter is not the right tool for this. What you need is a function that takes a number and returns the kind of string you want. Examples: def format_as_int(num): return str(int(num)) def format_float_no_sci(num): return "%f" % num Eric On 2017/10/26 10:07 PM, Ardeal LIANG wrote: Hi Eric, I added your code to my code: *from *matplotlib.ticker *import *ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) /# ax.fmt_xaxis = fmt_no_sci /prow = 4 pcol = 1 pidx = 0 fig = plt.figure() pidx += 1 axx = fig.add_subplot(prow, pcol, pidx, ylabel=*'rawdata'*) axx.plot(np.abs(testdata)) axx.fmt_xaxis = fmt_no_sci The *x axis value displayed at the left-bottom corner of the figure*is still scientific notation, but not decimal notation. Best Regards, Ardeal Liang -----Original Message----- From: Matplotlib-users [mailto:matplotlib-users-bounces+ardeal.liang=philips.com at python.org] On Behalf Of Eric Firing Sent: 2017?10?27? 16:00 To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Scientific notation digits at left-bottom corner of figure On 2017/10/26 9:50 PM, Ardeal LIANG wrote: Hi, If I put the mouse on the figure, x and y axis are displayed on the left-bottom corner of the figure. but the x axis is displayed as scientific notation, I want it to be displayed as decimal notation. how to make x axis or y axis values displayed as decimal notation on the left-bottom corner? *Best Regards,* *Ardeal Liang* Something like this, assuming your Axes is ax: from matplotlib.ticker import ScalarFormatter fmt_no_sci = ScalarFormatter(useOffset=False) fmt_no_sci.set_scientific(False) ax.fmt_xaxis = fmt_no_sci Eric _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ---------------------------------------------------------------------- -- The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. ________________________________ The information contained in this email may be confidential and/or legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original email. -------------- next part -------------- An HTML attachment was scrubbed... URL: