From steve at judgement.com Sat Mar 7 15:48:59 2020 From: steve at judgement.com (Steve Morris) Date: Sat, 7 Mar 2020 15:48:59 -0500 Subject: [Matplotlib-users] Mac OS: Can't get rid of 286 figures. Message-ID: I am new to macplotlib and can only do the simplest things but there are many hidden complexities I can't figure out that are now killing me. My big problem is everytime I plot I get a new 'figure' which I first thought was just a mysterious incrementing number but in fact seems to be some kind of persistent object which consumes resources and won't go away. I don't even know what a figure is. Where does it exist? Where is it's state recorded? How do I get rid of them? Now I have so 'figures' many that performance is degraded and matplotlib is becoming unusable. I have many times closed them all by patiently clicking the close box of all 286 (now empty) windows but that apparently only hides them because they all pop up again when I make a new plot. I tried killing python but they all reappear the next time I run a python script. The top of my plot script now has the following code but it apparently doesn't do anything: plt.close('all') for i in range(285): plt.close(i) I rebooted but the mess all comes back. >From many google searches I've recently discovered this is all apparently part of something normally hidden called a backend which is another thing I never heard of before this problem got out of control. I started using matplotlib from various online pyplot tutorials. The words 'close', 'backend' and 'figure' were never mentioned in any of them, so I had no warning. My questions: 1) Is this the right forum for this problem? 2) is there an easy way to get rid of figures. Can I reset or uninstall/reinstall something that will allow me to start over so I can use matplotlib again? 3) Where is this hidden infrastrastructure documented? What is its name? What keywords do I need to google to figure this out. 4) How do I do simple plots which go away when I am done looking at them? I have no current need for persistent plots. 5) Why is this so hard? I just want to plot some data. Thanks, -steve Versions: Python 3.7.6 installed by homebrew Matplotlib 3.0.3 OS: Catalina 10.15.3 MacBook Pro -------------- next part -------------- An HTML attachment was scrubbed... URL: From selasley at icloud.com Sun Mar 8 18:04:19 2020 From: selasley at icloud.com (Scott Lasley) Date: Sun, 8 Mar 2020 18:04:19 -0400 Subject: [Matplotlib-users] Mac OS: Can't get rid of 286 figures. In-Reply-To: References: Message-ID: I am using matplotlib 3.2 with python 3.8.2 from the python.org installer in macOS 10.15 and I don't see this problem of persistent plots. Can you post the code you're using to generate your plots? In my scripts, plt.close('all') closes all plot windows. When you say that "the mess all comes back", do you mean the 286 plots show up after running your script or do they show up when you just import matplotlib from the python repl? The Matplotlib usage faq has information on figures, axes, etc - https://matplotlib.org/faq/usage_faq.html RealPython has a nice introductory matplotlib tutorial that mentions the problem with having too many plots open - https://realpython.com/python-matplotlib-guide/ Since you say you just want to plot some data, you might want to try matplotlib wrappers or alternatives. Jake VanderPlas gave a nice talk at PyCon 2017 about the Python Visualization Landscape that mentions a few, such as bokeh, seaborn, plotly and altair. The talk is a few years old but still has useful information. https://www.youtube.com/watch?v=FytuB8nFHPQ I haven't used these next two, so I can't tell you if they are easier to use than using matplotlib directly - Veusz is a python package with "GUI, command-line, and scripting interfaces". There is a macOS installer https://pypi.org/project/veusz/ https://veusz.github.io EasyPlot is "A matplotlib wrapper written in Python to enable fast and easy creation of reusable plots." https://pypi.org/project/EasyPlot/ https://github.com/HamsterHuey/easyplot Hth, Scott > On Mar 7, 2020, at 3:48 PM, Steve Morris wrote: > > I am new to macplotlib and can only do the simplest things but there are many hidden complexities I can't figure out that are now killing me. My big problem is everytime I plot I get a new 'figure' which I first thought was just a mysterious incrementing number but in fact seems to be some kind of persistent object which consumes resources and won't go away. I don't even know what a figure is. Where does it exist? Where is it's state recorded? How do I get rid of them? Now I have so 'figures' many that performance is degraded and matplotlib is becoming unusable. I have many times closed them all by patiently clicking the close box of all 286 (now empty) windows but that apparently only hides them because they all pop up again when I make a new plot. I tried killing python but they all reappear the next time I run a python script. The top of my plot script now has the following code but it apparently doesn't do anything: > plt.close('all') > for i in range(285): > plt.close(i) > > I rebooted but the mess all comes back. > > From many google searches I've recently discovered this is all apparently part of something normally hidden called a backend which is another thing I never heard of before this problem got out of control. I started using matplotlib from various online pyplot tutorials. The words 'close', 'backend' and 'figure' were never mentioned in any of them, so I had no warning. > > My questions: > > 1) Is this the right forum for this problem? > 2) is there an easy way to get rid of figures. Can I reset or uninstall/reinstall something that will allow me to start over so I can use matplotlib again? > 3) Where is this hidden infrastrastructure documented? What is its name? What keywords do I need to google to figure this out. > 4) How do I do simple plots which go away when I am done looking at them? I have no current need for persistent plots. > 5) Why is this so hard? I just want to plot some data. > > Thanks, > > -steve > > Versions: > Python 3.7.6 installed by homebrew > Matplotlib 3.0.3 > OS: Catalina 10.15.3 > MacBook Pro > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From jni at fastmail.com Mon Mar 9 07:52:47 2020 From: jni at fastmail.com (Juan Nunez-Iglesias) Date: Mon, 9 Mar 2020 22:52:47 +1100 Subject: [Matplotlib-users] Mac OS: Can't get rid of 286 figures. In-Reply-To: References: Message-ID: <3B5CE725-501C-49FB-91B4-D6FBC894F089@fastmail.com> Hi Steve, In addition to Scott?s excellent list of resources, I?d like to recommend ?effective matplotlib? from Practical Business Python: https://pbpython.com/effective-matplotlib.html It answers a lot of your questions about the hierarchy of objects of matplotlib. Please bear in mind that matplotlib is an old library (started in 2001 I believe) so it?s hard to ensure that all information out there is totally up to date. This *is* the right forum to get up to date information. On Stack Overflow, be sure to look for more recent answers than the ?accepted? one, in case there is a newer way of doing things. Juan. > On 8 Mar 2020, at 7:49 am, Steve Morris wrote: > > ? > I am new to macplotlib and can only do the simplest things but there are many hidden complexities I can't figure out that are now killing me. My big problem is everytime I plot I get a new 'figure' which I first thought was just a mysterious incrementing number but in fact seems to be some kind of persistent object which consumes resources and won't go away. I don't even know what a figure is. Where does it exist? Where is it's state recorded? How do I get rid of them? Now I have so 'figures' many that performance is degraded and matplotlib is becoming unusable. I have many times closed them all by patiently clicking the close box of all 286 (now empty) windows but that apparently only hides them because they all pop up again when I make a new plot. I tried killing python but they all reappear the next time I run a python script. The top of my plot script now has the following code but it apparently doesn't do anything: > plt.close('all') > for i in range(285): > plt.close(i) > > I rebooted but the mess all comes back. > > From many google searches I've recently discovered this is all apparently part of something normally hidden called a backend which is another thing I never heard of before this problem got out of control. I started using matplotlib from various online pyplot tutorials. The words 'close', 'backend' and 'figure' were never mentioned in any of them, so I had no warning. > > My questions: > > 1) Is this the right forum for this problem? > 2) is there an easy way to get rid of figures. Can I reset or uninstall/reinstall something that will allow me to start over so I can use matplotlib again? > 3) Where is this hidden infrastrastructure documented? What is its name? What keywords do I need to google to figure this out. > 4) How do I do simple plots which go away when I am done looking at them? I have no current need for persistent plots. > 5) Why is this so hard? I just want to plot some data. > > Thanks, > > -steve > > Versions: > Python 3.7.6 installed by homebrew > Matplotlib 3.0.3 > OS: Catalina 10.15.3 > MacBook Pro > > > _______________________________________________ > 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 Randall.Benson at avangrid.com Wed Mar 11 16:00:00 2020 From: Randall.Benson at avangrid.com (Benson, Randall) Date: Wed, 11 Mar 2020 20:00:00 +0000 Subject: [Matplotlib-users] Variability Plots Matplotlib NetCDF4 Data Message-ID: HI- I'm trying to develop monthly standardized anomaly plots of Sea Level Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot netCDF4 data for a single month in plot form like the example shown below. However, I need to construct average SLP plots for each month given a set of years and use those to plot the standardized anomalies for each month of the current year. So, I'm looking too for just examples (python code) of creating variability plots using gridded data in Matplotlib. Thank you! Randall Benson [cid:image005.jpg at 01D5F7A4.F7DBEBE0] [Description: cid:image001.jpg at 01D34737.23261CB0] Randall P. Benson, PhD Wind Asset Meteorologist, Energy Resource - Onshore 1125 NW Couch Street, Suite 700 Portland, Oregon, USA 97209 Telephone 503-796-7129 Cell 971-227-2477 randall.benson at avangrid.com [Description: cid:image002.png at 01D34737.23261CB0] In the interest of the environment, please print only if necessary and recycle. ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 45526 bytes Desc: image001.jpg URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 3441 bytes Desc: image002.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.jpg Type: image/jpeg Size: 46007 bytes Desc: image005.jpg URL: From story645 at gmail.com Wed Mar 11 19:27:45 2020 From: story645 at gmail.com (Hannah) Date: Wed, 11 Mar 2020 19:27:45 -0400 Subject: [Matplotlib-users] Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: Hi Randall, I'm not sure what specifically you're asking for. Are you using xarray ( http://xarray.pydata.org/en/stable/) ? If not, it might help in more efficiently computing the anomolies once you read all the files into an xarray: http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies On Wed, Mar 11, 2020, 4:17 PM Benson, Randall wrote: > HI- > > > > I?m trying to develop monthly standardized anomaly plots of Sea Level > Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot > netCDF4 data for a single month in plot form like the example shown below. > However, I need to construct average SLP plots for each month given a set > of years and use those to plot the standardized anomalies for each month of > the current year. So, I?m looking too for just examples (python code) of > creating variability plots using gridded data in Matplotlib. Thank you! > > > > Randall Benson > > > > [image: Description: cid:image001.jpg at 01D34737.23261CB0] > > *Randall P. Benson, PhD* > Wind Asset Meteorologist, Energy Resource - Onshore > > 1125 NW Couch Street, Suite 700 > > Portland, Oregon, USA 97209 > Telephone 503-796-7129 > Cell 971-227-2477 > randall.benson at avangrid.com > > > [image: Description: cid:image002.png at 01D34737.23261CB0] > > > In the interest of the environment, > please print only if necessary and recycle. > > > > > > > > ============================================================== > > Please consider the environment before printing this email. > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > ============================================================== > > _______________________________________________ > 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 45526 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 3441 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.jpg Type: image/jpeg Size: 46007 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.jpg Type: image/jpeg Size: 46007 bytes Desc: not available URL: From story645 at gmail.com Thu Mar 19 16:32:20 2020 From: story645 at gmail.com (Hannah) Date: Thu, 19 Mar 2020 16:32:20 -0400 Subject: [Matplotlib-users] EXTERNAL: Re: Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: Hi, Sorry for the late reply, been swamped. If you haven't sorted this out, can you please post at least some of the code that generated this error? Thanks! On Tue, Mar 17, 2020 at 1:06 AM Benson, Randall wrote: > Hi Hannah ? > > > > Are you familiar with this error using xarray to plot gridded netcd4 data? > > > > This is the out from ?stdn.var? > > > > .wrapped_func > of > > Dimensions: (lat: 73, lon: 144, month: 1) > > Coordinates: > > * month (month) int64 2 > > * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 > > * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 > -90.0 > > Data variables: > > slp (month, lat, lon) float32 dask.array meta=np.ndarray>> > > > > I keep getting this error ? > > - AttributeError: '_Dataset_PlotMethods' object has no attribute 'contourf' > > > > Thank you, > > Randall > > > > *From:* Hannah > *Sent:* Wednesday, March 11, 2020 4:28 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib > NetCDF4 Data > > > > Hi Randall, > > I'm not sure what specifically you're asking for. Are you using xarray ( > http://xarray.pydata.org/en/stable/) ? If not, it might help in more > efficiently computing the anomolies once you read all the files into an > xarray: > > > > > http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies > > On Wed, Mar 11, 2020, 4:17 PM Benson, Randall > wrote: > > HI- > > > > I?m trying to develop monthly standardized anomaly plots of Sea Level > Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot > netCDF4 data for a single month in plot form like the example shown below. > However, I need to construct average SLP plots for each month given a set > of years and use those to plot the standardized anomalies for each month of > the current year. So, I?m looking too for just examples (python code) of > creating variability plots using gridded data in Matplotlib. Thank you! > > > > Randall Benson > > > > [image: Description: cid:image001.jpg at 01D34737.23261CB0] > > *Randall P. Benson, PhD* > Wind Asset Meteorologist, Energy Resource - Onshore > > 1125 NW Couch Street, Suite 700 > > Portland, Oregon, USA 97209 > Telephone 503-796-7129 > Cell 971-227-2477 > randall.benson at avangrid.com > > > [image: Description: cid:image002.png at 01D34737.23261CB0] > > > In the interest of the environment, > please print only if necessary and recycle. > > > > > > > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > ============================================================== > > Please consider the environment before printing this email. > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > ============================================================== > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jslavin at cfa.harvard.edu Thu Mar 19 17:36:18 2020 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Thu, 19 Mar 2020 17:36:18 -0400 Subject: [Matplotlib-users] trouble removing tick labels Message-ID: Hi, I'm making a plot that's a grid of 4 x 4 axes. I'd like to remove the tick labels for the y axes that are not in the first column. I tried using what I saw in an example: for ax in axs.flat: ax.label_outer() but that seems to have no effect. I found where the code that defines that function is and tried to use that code directly: for ax in axs.flat: if ax.colNum != 0: for label in ax.get_yticklabels(which='both'): label.set_visible(False) ax.get_yaxis().get_offset_text().set_visible(False) ax.set_ylabel("") but again no effect. Does anyone have any ideas why these are not working? Any help would be appreciated. Regards, Jon -- Jonathan D. Slavin Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 83 | Cambridge, MA 02138 -------------- next part -------------- An HTML attachment was scrubbed... URL: From story645 at gmail.com Thu Mar 19 18:35:34 2020 From: story645 at gmail.com (Hannah) Date: Thu, 19 Mar 2020 18:35:34 -0400 Subject: [Matplotlib-users] EXTERNAL: Re: Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: try stdna.squeeze().plot() ? I tried to make a minimum reproduction & I can't reproduce the error. Any chance you can share a binder or how you're getting your data? This is what I tried: slp = np.random.random(([1, 73,144])) stdn = xr.Dataset({'slp': (['month', 'lat', 'lon'], slp)}) stdna = stdn.to_array()# must convert the xarray "dataset" to "dataArray"!!! print(stdna.shape) stdna = stdna.rename('Standardized SLP Anomaly') ax = plt.axes(projection=ccrs.PlateCarree()) ax.coastlines(lw=1) stdna.plot() On Thu, Mar 19, 2020 at 5:52 PM Benson, Randall wrote: > Hi - > > I solved it by converting the datasets to dataarrays using this below with > my variable a dataArray ?stdna? and calling the ?plot? command. > > However, when I try to plot this variable using -- stdna.plot.contourf() ? > but I get an error saying my data must be 2D. The ?stnda? variable looks > like this ? > > > > stdna > > Out[181]: > > 73, lon: 144)> > > dask.array 73, 144), chunktype=numpy.ndarray> > > Coordinates: > > * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 > 357.5 > > * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 > -90.0 > > * month (month) int64 1 > > * variable (variable) > -------------------------------------------------------------- > > This works below?. > > stdna = stdn.to_array()# must convert the xarray "dataset" to > "dataArray"!!! > > #stdna.rename('Standardized SLP Anomaly')#rename dataarray > > stdna = stdna.rename('Standardized SLP Anomaly')#for legend description > label > > # Define an axes object with a projection > > ax = plt.axes(projection=ccrs.PlateCarree()) > > # Plot the coastline > > ax.coastlines(lw=1) > > stdna.plot() > > > > # > > > > *From:* Hannah > *Sent:* Thursday, March 19, 2020 1:32 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots > Matplotlib NetCDF4 Data > > > > Hi, > > Sorry for the late reply, been swamped. If you haven't sorted this out, > can you please post at least some of the code that generated this error? > > Thanks! > > > > On Tue, Mar 17, 2020 at 1:06 AM Benson, Randall < > Randall.Benson at avangrid.com> wrote: > > Hi Hannah ? > > > > Are you familiar with this error using xarray to plot gridded netcd4 data? > > > > This is the out from ?stdn.var? > > > > .wrapped_func > of > > Dimensions: (lat: 73, lon: 144, month: 1) > > Coordinates: > > * month (month) int64 2 > > * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 > > * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 > -90.0 > > Data variables: > > slp (month, lat, lon) float32 dask.array meta=np.ndarray>> > > > > I keep getting this error ? > > - AttributeError: '_Dataset_PlotMethods' object has no attribute 'contourf' > > > > Thank you, > > Randall > > > > *From:* Hannah > *Sent:* Wednesday, March 11, 2020 4:28 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib > NetCDF4 Data > > > > Hi Randall, > > I'm not sure what specifically you're asking for. Are you using xarray ( > http://xarray.pydata.org/en/stable/) ? If not, it might help in more > efficiently computing the anomolies once you read all the files into an > xarray: > > > > > http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies > > On Wed, Mar 11, 2020, 4:17 PM Benson, Randall > wrote: > > HI- > > > > I?m trying to develop monthly standardized anomaly plots of Sea Level > Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot > netCDF4 data for a single month in plot form like the example shown below. > However, I need to construct average SLP plots for each month given a set > of years and use those to plot the standardized anomalies for each month of > the current year. So, I?m looking too for just examples (python code) of > creating variability plots using gridded data in Matplotlib. Thank you! > > > > Randall Benson > > > > *Randall P. Benson, PhD* > Wind Asset Meteorologist, Energy Resource - Onshore > > 1125 NW Couch Street, Suite 700 > > Portland, Oregon, USA 97209 > Telephone 503-796-7129 > Cell 971-227-2477 > randall.benson at avangrid.com > > > > In the interest of the environment, > please print only if necessary and recycle. > > > > > > > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > > > ============================================================== > > Please consider the environment before printing this email. > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > ============================================================== > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From story645 at gmail.com Thu Mar 19 18:37:50 2020 From: story645 at gmail.com (Hannah) Date: Thu, 19 Mar 2020 18:37:50 -0400 Subject: [Matplotlib-users] EXTERNAL: Re: Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: Ok, was able to reproduce when I did stdna.plot.contour() (missed that bit the first time!) and the fix was stdna.squeeze().plot.contour() On Thu, Mar 19, 2020 at 6:35 PM Hannah wrote: > try stdna.squeeze().plot() ? > > I tried to make a minimum reproduction & I can't reproduce the error. Any > chance you can share a binder or how you're getting your data? > > This is what I tried: > slp = np.random.random(([1, 73,144])) > stdn = xr.Dataset({'slp': (['month', 'lat', 'lon'], slp)}) > stdna = stdn.to_array()# must convert the xarray "dataset" to > "dataArray"!!! > > print(stdna.shape) > > stdna = stdna.rename('Standardized SLP Anomaly') > ax = plt.axes(projection=ccrs.PlateCarree()) > ax.coastlines(lw=1) > stdna.plot() > > > On Thu, Mar 19, 2020 at 5:52 PM Benson, Randall < > Randall.Benson at avangrid.com> wrote: > >> Hi - >> >> I solved it by converting the datasets to dataarrays using this below >> with my variable a dataArray ?stdna? and calling the ?plot? command. >> >> However, when I try to plot this variable using -- stdna.plot.contourf() >> ? but I get an error saying my data must be 2D. The ?stnda? variable looks >> like this ? >> >> >> >> stdna >> >> Out[181]: >> >> > 73, lon: 144)> >> >> dask.array> 73, 144), chunktype=numpy.ndarray> >> >> Coordinates: >> >> * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 >> 357.5 >> >> * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 >> -87.5 -90.0 >> >> * month (month) int64 1 >> >> * variable (variable) > >> -------------------------------------------------------------- >> >> This works below?. >> >> stdna = stdn.to_array()# must convert the xarray "dataset" to >> "dataArray"!!! >> >> #stdna.rename('Standardized SLP Anomaly')#rename dataarray >> >> stdna = stdna.rename('Standardized SLP Anomaly')#for legend description >> label >> >> # Define an axes object with a projection >> >> ax = plt.axes(projection=ccrs.PlateCarree()) >> >> # Plot the coastline >> >> ax.coastlines(lw=1) >> >> stdna.plot() >> >> >> >> # >> >> >> >> *From:* Hannah >> *Sent:* Thursday, March 19, 2020 1:32 PM >> *To:* Benson, Randall >> *Cc:* Matplotlib-users >> *Subject:* Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots >> Matplotlib NetCDF4 Data >> >> >> >> Hi, >> >> Sorry for the late reply, been swamped. If you haven't sorted this out, >> can you please post at least some of the code that generated this error? >> >> Thanks! >> >> >> >> On Tue, Mar 17, 2020 at 1:06 AM Benson, Randall < >> Randall.Benson at avangrid.com> wrote: >> >> Hi Hannah ? >> >> >> >> Are you familiar with this error using xarray to plot gridded netcd4 >> data? >> >> >> >> This is the out from ?stdn.var? >> >> >> >> > ImplementsDatasetReduce._reduce_method..wrapped_func of >> >> >> Dimensions: (lat: 73, lon: 144, month: 1) >> >> Coordinates: >> >> * month (month) int64 2 >> >> * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 >> 357.5 >> >> * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 >> -90.0 >> >> Data variables: >> >> slp (month, lat, lon) float32 dask.array> meta=np.ndarray>> >> >> >> >> I keep getting this error ? >> >> - AttributeError: '_Dataset_PlotMethods' object has no attribute >> 'contourf' >> >> >> >> Thank you, >> >> Randall >> >> >> >> *From:* Hannah >> *Sent:* Wednesday, March 11, 2020 4:28 PM >> *To:* Benson, Randall >> *Cc:* Matplotlib-users >> *Subject:* EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib >> NetCDF4 Data >> >> >> >> Hi Randall, >> >> I'm not sure what specifically you're asking for. Are you using xarray ( >> http://xarray.pydata.org/en/stable/) ? If not, it might help in more >> efficiently computing the anomolies once you read all the files into an >> xarray: >> >> >> >> >> http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies >> >> On Wed, Mar 11, 2020, 4:17 PM Benson, Randall < >> Randall.Benson at avangrid.com> wrote: >> >> HI- >> >> >> >> I?m trying to develop monthly standardized anomaly plots of Sea Level >> Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot >> netCDF4 data for a single month in plot form like the example shown below. >> However, I need to construct average SLP plots for each month given a set >> of years and use those to plot the standardized anomalies for each month of >> the current year. So, I?m looking too for just examples (python code) of >> creating variability plots using gridded data in Matplotlib. Thank you! >> >> >> >> Randall Benson >> >> >> >> *Randall P. Benson, PhD* >> Wind Asset Meteorologist, Energy Resource - Onshore >> >> 1125 NW Couch Street, Suite 700 >> >> Portland, Oregon, USA 97209 >> Telephone 503-796-7129 >> Cell 971-227-2477 >> randall.benson at avangrid.com >> >> >> >> In the interest of the environment, >> please print only if necessary and recycle. >> >> >> >> >> >> >> >> ============================================================== >> >> >> >> Please consider the environment before printing this email. >> >> >> >> If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. >> >> >> >> The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. >> >> >> >> ============================================================== >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> ============================================================== >> >> >> >> Please consider the environment before printing this email. >> >> >> >> If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. >> >> >> >> The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. >> >> >> >> ============================================================== >> >> >> >> ============================================================== >> >> Please consider the environment before printing this email. >> >> If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. >> >> The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. >> >> ============================================================== >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Thu Mar 19 18:42:31 2020 From: efiring at hawaii.edu (Eric Firing) Date: Thu, 19 Mar 2020 12:42:31 -1000 Subject: [Matplotlib-users] trouble removing tick labels In-Reply-To: References: Message-ID: <77e44a65-c519-705e-24ad-dc13f7c204c3@hawaii.edu> Jon, If you are removing the tick labels it suggests that the y-axes are all matched, in which case using fig, axs = plt.subplots(2, 2, sharey=True) should do what you want. If not, please supply a minimal but complete example illustrating the problem. Eric On 2020/03/19 11:36 AM, Slavin, Jonathan wrote: > Hi, > > I'm making a plot that's a grid of 4 x 4 axes. I'd like to remove the > tick labels for the y axes that are not in the first column. I tried > using what I saw in an example: > for ax in axs.flat: > ? ? ax.label_outer() > but that seems to have no effect. I found where the code that defines > that function is and tried to use that code directly: > for ax in axs.flat: > ? ? if ax.colNum != 0: > ? ? ? ? for label in ax.get_yticklabels(which='both'): > ? ? ? ? ? ? label.set_visible(False) > ? ? ? ? ax.get_yaxis().get_offset_text().set_visible(False) > ? ? ? ? ax.set_ylabel("") > but again no effect. Does anyone have any ideas why these are not > working? Any help would be appreciated. > > Regards, > Jon > > > -- > Jonathan D. Slavin > Astrophysicist - High Energy Astrophysics Division > Center for Astrophysics | Harvard & Smithsonian > Office: (617) 496-7981 | Cell: (781) 363-0035 > 60 Garden Street | MS 83 |?Cambridge, MA 02138 > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From t.appel17 at imperial.ac.uk Fri Mar 20 10:34:36 2020 From: t.appel17 at imperial.ac.uk (Thibaut Appel) Date: Fri, 20 Mar 2020 14:34:36 +0000 Subject: [Matplotlib-users] Transparency for pcolor slices in Axes3D plot Message-ID: Dear matplotlib users/developers, I struggle to set some transparency in an Axes3D plot with series of 2D-slices generated with pcolor. In spite of trying to set alpha, all the slices remain opaque. I've just posted the issue on stackoverflow , where you can see an illustration of the problem. Would someone have a workaround? |import numpy as np| |import matplotlib.pyplot as plt| |from mpl_toolkits.mplot3d import Axes3D| |from matplotlib.collections import PolyCollection| || |X, Y = np.meshgrid(x,y)| || |fig = plt.figure()| |ax = fig.gca(projection='3d')| || |alpha = 0.8| || |for i in range(len(islices)):| |??? im = ax.pcolor(X,Y,u[islices[i],:,:]) #,alpha=alpha)| |??? #im.set_facecolor((0, 0, 1, alpha))| |||ax.add_collection3d(im,zs=xslices[i],zdir='y')|| | |plt.show()| Thank you in advance. || -------------- next part -------------- An HTML attachment was scrubbed... URL: From akkana at shallowsky.com Fri Mar 20 11:48:26 2020 From: akkana at shallowsky.com (Akkana Peck) Date: Fri, 20 Mar 2020 09:48:26 -0600 Subject: [Matplotlib-users] Transparency for pcolor slices in Axes3D plot In-Reply-To: References: Message-ID: <20200320154826.GA2324@shallowsky.com> Thibaut Appel writes: > Dear matplotlib users/developers, > > I struggle to set some transparency in an Axes3D plot with series of > 2D-slices generated with pcolor. In spite of trying to set alpha, all the > slices remain opaque. I've just posted the issue on stackoverflow , That image -- the way the 0.45 layer is drawn as if it's in front of the 0.40 layer -- illustrates a problem I've always had with Axes3D. I didn't have trouble making them transparent, but Axes3D sometimes makes the wrong decision about which layer is in front, so you get the wrong translucency. I have an illustration of the problem at http://shallowsky.com/blog/programming/matplotlib-3d-collection.html I always meant to file a bug on it but never did. Thibaut, I'm not sure why your alpha values aren't working, but you might want to compare my demo (linked from that page) to see what's different, since the alpha is working for me. ...Akkana From Randall.Benson at avangrid.com Fri Mar 20 12:25:36 2020 From: Randall.Benson at avangrid.com (Benson, Randall) Date: Fri, 20 Mar 2020 16:25:36 +0000 Subject: [Matplotlib-users] EXTERNAL: Re: Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: Hi Hannah- Yes, that works!! Thank you! I?ve got one more question ?and if I can understand this example, then I think I can make my plot display the lat/lon lines onto the contour plot. Could you comment on what?s going on with this code with the highlight lines below? https://scitools.org.uk/cartopy/docs/v0.15/matplotlib/advanced_plotting.html Then, I should be able to apply it to my plotting problem. Thanks! Randall Here is my image and I?m trying to plot the lat/lon lines and the plotting code: # Define an axes object with a projection ax = plt.axes(projection=ccrs.PlateCarree()) # Plot the coastline ax.coastlines(lw=1) stdnasq = stdna.squeeze().plot.contourf(levels=12,add_labels=True) ax.set_xlabel('') plt.show() [cid:image001.jpg at 01D5FE99.80A33A50] import os import matplotlib.pyplot as plt from netCDF4 import Dataset as netcdf_dataset import numpy as np from cartopy import config import cartopy.crs as ccrs # get the path of the file. It can be found in the repo data directory. fname = os.path.join(config["repo_data_dir"], 'netcdf', 'HadISST1_SST_update.nc' ) dataset = netcdf_dataset(fname) sst = dataset.variables['sst'][0, :, :] lats = dataset.variables['lat'][:] lons = dataset.variables['lon'][:] ax = plt.axes(projection=ccrs.PlateCarree()) plt.contourf(lons, lats, sst, 60, transform=ccrs.PlateCarree()) ax.coastlines() plt.show() From: Hannah Sent: Thursday, March 19, 2020 3:38 PM To: Benson, Randall Cc: Matplotlib-users Subject: Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib NetCDF4 Data Ok, was able to reproduce when I did stdna.plot.contour() (missed that bit the first time!) and the fix was stdna.squeeze().plot.contour() On Thu, Mar 19, 2020 at 6:35 PM Hannah > wrote: try stdna.squeeze().plot() ? I tried to make a minimum reproduction & I can't reproduce the error. Any chance you can share a binder or how you're getting your data? This is what I tried: slp = np.random.random(([1, 73,144])) stdn = xr.Dataset({'slp': (['month', 'lat', 'lon'], slp)}) stdna = stdn.to_array()# must convert the xarray "dataset" to "dataArray"!!! print(stdna.shape) stdna = stdna.rename('Standardized SLP Anomaly') ax = plt.axes(projection=ccrs.PlateCarree()) ax.coastlines(lw=1) stdna.plot() On Thu, Mar 19, 2020 at 5:52 PM Benson, Randall > wrote: Hi - I solved it by converting the datasets to dataarrays using this below with my variable a dataArray ?stdna? and calling the ?plot? command. However, when I try to plot this variable using -- stdna.plot.contourf() ? but I get an error saying my data must be 2D. The ?stnda? variable looks like this ? stdna Out[181]: dask.array Coordinates: * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0 * month (month) int64 1 * variable (variable) > Sent: Thursday, March 19, 2020 1:32 PM To: Benson, Randall > Cc: Matplotlib-users > Subject: Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib NetCDF4 Data Hi, Sorry for the late reply, been swamped. If you haven't sorted this out, can you please post at least some of the code that generated this error? Thanks! On Tue, Mar 17, 2020 at 1:06 AM Benson, Randall > wrote: Hi Hannah ? Are you familiar with this error using xarray to plot gridded netcd4 data? This is the out from ?stdn.var? .wrapped_func of Dimensions: (lat: 73, lon: 144, month: 1) Coordinates: * month (month) int64 2 * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0 Data variables: slp (month, lat, lon) float32 dask.array> I keep getting this error ? - AttributeError: '_Dataset_PlotMethods' object has no attribute 'contourf' Thank you, Randall From: Hannah > Sent: Wednesday, March 11, 2020 4:28 PM To: Benson, Randall > Cc: Matplotlib-users > Subject: EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib NetCDF4 Data Hi Randall, I'm not sure what specifically you're asking for. Are you using xarray (http://xarray.pydata.org/en/stable/) ? If not, it might help in more efficiently computing the anomolies once you read all the files into an xarray: http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies On Wed, Mar 11, 2020, 4:17 PM Benson, Randall > wrote: HI- I?m trying to develop monthly standardized anomaly plots of Sea Level Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot netCDF4 data for a single month in plot form like the example shown below. However, I need to construct average SLP plots for each month given a set of years and use those to plot the standardized anomalies for each month of the current year. So, I?m looking too for just examples (python code) of creating variability plots using gridded data in Matplotlib. Thank you! Randall Benson Randall P. Benson, PhD Wind Asset Meteorologist, Energy Resource - Onshore 1125 NW Couch Street, Suite 700 Portland, Oregon, USA 97209 Telephone 503-796-7129 Cell 971-227-2477 randall.benson at avangrid.com In the interest of the environment, please print only if necessary and recycle. ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 17961 bytes Desc: image001.jpg URL: From ben.v.root at gmail.com Fri Mar 20 12:48:27 2020 From: ben.v.root at gmail.com (Benjamin Root) Date: Fri, 20 Mar 2020 12:48:27 -0400 Subject: [Matplotlib-users] Transparency for pcolor slices in Axes3D plot In-Reply-To: <20200320154826.GA2324@shallowsky.com> References: <20200320154826.GA2324@shallowsky.com> Message-ID: The ordering problem is well-known and is a limitation of the 2D rendering engine of matplotlib. I call them "Escher Effects". No need to file a bug report, there are plenty of discussions on ways to mitigate it in specific instances, but ultimately, if you need a complex 3D scene, you may need to use a true 3D rendering tool like mayavi or others. This is discussed on the mplot3d main page. I hope that helps! Ben Root On Fri, Mar 20, 2020 at 11:55 AM Akkana Peck wrote: > Thibaut Appel writes: > > Dear matplotlib users/developers, > > > > I struggle to set some transparency in an Axes3D plot with series of > > 2D-slices generated with pcolor. In spite of trying to set alpha, all the > > slices remain opaque. I've just posted the issue on stackoverflow < > https://stackoverflow.com/questions/60776103/how-to-enforce-transparency-for-pcolor-slices-within-axes3d-scope > >, > > That image -- the way the 0.45 layer is drawn as if it's in front of > the 0.40 layer -- illustrates a problem I've always had with Axes3D. > I didn't have trouble making them transparent, but Axes3D sometimes > makes the wrong decision about which layer is in front, so you get > the wrong translucency. I have an illustration of the problem at > http://shallowsky.com/blog/programming/matplotlib-3d-collection.html > I always meant to file a bug on it but never did. > > Thibaut, I'm not sure why your alpha values aren't working, but you > might want to compare my demo (linked from that page) to see > what's different, since the alpha is working for me. > > ...Akkana > _______________________________________________ > 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 Fri Mar 20 14:56:19 2020 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Fri, 20 Mar 2020 14:56:19 -0400 Subject: [Matplotlib-users] trouble removing tick labels In-Reply-To: References: Message-ID: Hi Eric, I think I've isolated the problem. In my figure I have been including colorbars for each plot. In my simple example, which I include below, label_outer works without the colorbars but not with them. Regarding using sharey, I am using the same y-axis in each row, but they differ between rows. If I use sharey, things get all messed up - the smaller images are shrunken and only take up part of the figure. In the end I was able to turn off the tick labelling by doing things like: for label in ax.get_yticklabels(which='both'): label.set_visible(False) I think this may have to do with the attributes of axs getting overwritten or something. If I print axs[1,1].get_subplotspec().colspan.start in the case with colorbars I get 0, whereas if I do it without colorbars, I get 1 as I should. Same applies to other axes and to rows. Here's the minimal example: import numpy as np import matplotlib.pyplot as plt fig,axs = plt.subplots(2,2) img0 = np.random.random((10,10)) img1 = np.random.random((10,10)) img2 = np.random.random((10,10)) img3 = np.random.random((10,10)) cax0 = axs[0,0].imshow(img0,extent=[0.,10.,0.,10.]) fig.colorbar(cax0,ax=axs[0,0],pad=0.01) cax1 = axs[0,1].imshow(img1,extent=[0.,10.,0.,10.]) fig.colorbar(cax1,ax=axs[0,1],pad=0.01) cax2 = axs[1,0].imshow(img2,extent=[0.,10.,0.,10.]) fig.colorbar(cax2,ax=axs[1,0],pad=0.01) cax3 = axs[1,1].imshow(img3,extent=[0.,10.,0.,10.]) fig.colorbar(cax3,ax=axs[1,1],pad=0.01) for ax in axs.flat: ax.label_outer() plt.show() On Fri, Mar 20, 2020 at 11:04 AM wrote: > Date: Thu, 19 Mar 2020 12:42:31 -1000 > From: Eric Firing > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] trouble removing tick labels > Message-ID: <77e44a65-c519-705e-24ad-dc13f7c204c3 at hawaii.edu> > Content-Type: text/plain; charset=utf-8; format=flowed > > Jon, > > If you are removing the tick labels it suggests that the y-axes are all > matched, in which case using > > fig, axs = plt.subplots(2, 2, sharey=True) > > should do what you want. > > If not, please supply a minimal but complete example illustrating the > problem. > > Eric > > On 2020/03/19 11:36 AM, Slavin, Jonathan wrote: > > Hi, > > > > I'm making a plot that's a grid of 4 x 4 axes. I'd like to remove the > > tick labels for the y axes that are not in the first column. I tried > > using what I saw in an example: > > for ax in axs.flat: > > ? ? ax.label_outer() > > but that seems to have no effect. I found where the code that defines > > that function is and tried to use that code directly: > > for ax in axs.flat: > > ? ? if ax.colNum != 0: > > ? ? ? ? for label in ax.get_yticklabels(which='both'): > > ? ? ? ? ? ? label.set_visible(False) > > ? ? ? ? ax.get_yaxis().get_offset_text().set_visible(False) > > ? ? ? ? ax.set_ylabel("") > > but again no effect. Does anyone have any ideas why these are not > > working? Any help would be appreciated. > > > > Regards, > > Jon > -- Jonathan D. Slavin Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 83 | Cambridge, MA 02138 -------------- next part -------------- An HTML attachment was scrubbed... URL: From story645 at gmail.com Fri Mar 20 14:59:29 2020 From: story645 at gmail.com (Hannah) Date: Fri, 20 Mar 2020 14:59:29 -0400 Subject: [Matplotlib-users] EXTERNAL: Re: Variability Plots Matplotlib NetCDF4 Data In-Reply-To: References: Message-ID: This extracts the data from the the netcdf, the sea surface temps, latitudes, and longitudes respectively sst = dataset.variables['sst'][0, :, :] lats = dataset.variables['lat'][:] lons = dataset.variables['lon'][:] this creates an axes with a PlateCarree projection ax = plt.axes(projection=ccrs.PlateCarree()) this line plots the sst at the x (lons) and y(lats) remapping using the PlateCarree projection plt.contourf(lons, lats, sst, 60, transform=ccrs.PlateCarree()) xarray basically does the unpacking and the plt.contourf for you in the stdn.squeeze().plot.contour() call, but you can basically mimic it with lats = stdna['lat'].data lons = stdna['lon'].data slp = stdna['slp'].data On Fri, Mar 20, 2020 at 12:30 PM Benson, Randall < Randall.Benson at avangrid.com> wrote: > Hi Hannah- > > Yes, that works!! Thank you! I?ve got one more question ?and if I can > understand this example, then I think I can make my plot display the > lat/lon lines onto the contour plot. Could you comment on what?s going on > with this code with the highlight lines below? > https://scitools.org.uk/cartopy/docs/v0.15/matplotlib/advanced_plotting.html > > Then, I should be able to apply it to my plotting problem. > > Thanks! Randall > > > > Here is my image and I?m trying to plot the lat/lon lines and the plotting > code: > > > > # Define an axes object with a projection > > ax = plt.axes(projection=ccrs.PlateCarree()) > > # Plot the coastline > > ax.coastlines(lw=1) > > stdnasq = stdna.squeeze().plot.contourf(levels=12,add_labels=True) > > ax.set_xlabel('') > > plt.show() > > > > > > *import* *os* > > *import* *matplotlib.pyplot* *as* *plt* > > *from* *netCDF4* *import* Dataset *as* netcdf_dataset > > *import* *numpy* *as* *np* > > > > *from* *cartopy* *import* config > > *import* *cartopy.crs* *as* *ccrs* > > > > > > *# get the path of the file. It can be found in the repo data directory.* > > fname = os.path.join(config["repo_data_dir"], > > 'netcdf', 'HadISST1_SST_update.nc' > > ) > > > > dataset = netcdf_dataset(fname) > > sst = dataset.variables['sst'][0, :, :] > > lats = dataset.variables['lat'][:] > > lons = dataset.variables['lon'][:] > > > > ax = plt.axes(projection=ccrs.PlateCarree()) > > > > plt.contourf(lons, lats, sst, 60, > > transform=ccrs.PlateCarree()) > > > > ax.coastlines() > > > > plt.show() > > > > > > *From:* Hannah > *Sent:* Thursday, March 19, 2020 3:38 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots > Matplotlib NetCDF4 Data > > > > Ok, was able to reproduce when I did stdna.plot.contour() (missed that bit > the first time!) and the fix was stdna.squeeze().plot.contour() > > > > On Thu, Mar 19, 2020 at 6:35 PM Hannah wrote: > > try stdna.squeeze().plot() ? > > > > I tried to make a minimum reproduction & I can't reproduce the error. Any > chance you can share a binder or how you're getting your data? > > > > This is what I tried: > > slp = np.random.random(([1, 73,144])) > stdn = xr.Dataset({'slp': (['month', 'lat', 'lon'], slp)}) > stdna = stdn.to_array()# must convert the xarray "dataset" to > "dataArray"!!! > > print(stdna.shape) > > stdna = stdna.rename('Standardized SLP Anomaly') > ax = plt.axes(projection=ccrs.PlateCarree()) > ax.coastlines(lw=1) > stdna.plot() > > > > > > On Thu, Mar 19, 2020 at 5:52 PM Benson, Randall < > Randall.Benson at avangrid.com> wrote: > > Hi - > > I solved it by converting the datasets to dataarrays using this below with > my variable a dataArray ?stdna? and calling the ?plot? command. > > However, when I try to plot this variable using -- stdna.plot.contourf() ? > but I get an error saying my data must be 2D. The ?stnda? variable looks > like this ? > > > > stdna > > Out[181]: > > 73, lon: 144)> > > dask.array 73, 144), chunktype=numpy.ndarray> > > Coordinates: > > * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 > 357.5 > > * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 > -90.0 > > * month (month) int64 1 > > * variable (variable) > -------------------------------------------------------------- > > This works below?. > > stdna = stdn.to_array()# must convert the xarray "dataset" to > "dataArray"!!! > > #stdna.rename('Standardized SLP Anomaly')#rename dataarray > > stdna = stdna.rename('Standardized SLP Anomaly')#for legend description > label > > # Define an axes object with a projection > > ax = plt.axes(projection=ccrs.PlateCarree()) > > # Plot the coastline > > ax.coastlines(lw=1) > > stdna.plot() > > > > # > > > > *From:* Hannah > *Sent:* Thursday, March 19, 2020 1:32 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* Re: EXTERNAL: Re: [Matplotlib-users] Variability Plots > Matplotlib NetCDF4 Data > > > > Hi, > > Sorry for the late reply, been swamped. If you haven't sorted this out, > can you please post at least some of the code that generated this error? > > Thanks! > > > > On Tue, Mar 17, 2020 at 1:06 AM Benson, Randall < > Randall.Benson at avangrid.com> wrote: > > Hi Hannah ? > > > > Are you familiar with this error using xarray to plot gridded netcd4 data? > > > > This is the out from ?stdn.var? > > > > .wrapped_func > of > > Dimensions: (lat: 73, lon: 144, month: 1) > > Coordinates: > > * month (month) int64 2 > > * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 > > * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 > -90.0 > > Data variables: > > slp (month, lat, lon) float32 dask.array meta=np.ndarray>> > > > > I keep getting this error ? > > - AttributeError: '_Dataset_PlotMethods' object has no attribute 'contourf' > > > > Thank you, > > Randall > > > > *From:* Hannah > *Sent:* Wednesday, March 11, 2020 4:28 PM > *To:* Benson, Randall > *Cc:* Matplotlib-users > *Subject:* EXTERNAL: Re: [Matplotlib-users] Variability Plots Matplotlib > NetCDF4 Data > > > > Hi Randall, > > I'm not sure what specifically you're asking for. Are you using xarray ( > http://xarray.pydata.org/en/stable/) ? If not, it might help in more > efficiently computing the anomolies once you read all the files into an > xarray: > > > > > http://xarray.pydata.org/en/stable/examples/weather-data.html#Calculate-monthly-anomalies > > On Wed, Mar 11, 2020, 4:17 PM Benson, Randall > wrote: > > HI- > > > > I?m trying to develop monthly standardized anomaly plots of Sea Level > Pressure (SLP) using NCEP reanalysis data in netCDF4 format. I can plot > netCDF4 data for a single month in plot form like the example shown below. > However, I need to construct average SLP plots for each month given a set > of years and use those to plot the standardized anomalies for each month of > the current year. So, I?m looking too for just examples (python code) of > creating variability plots using gridded data in Matplotlib. Thank you! > > > > Randall Benson > > > > *Randall P. Benson, PhD* > Wind Asset Meteorologist, Energy Resource - Onshore > > 1125 NW Couch Street, Suite 700 > > Portland, Oregon, USA 97209 > Telephone 503-796-7129 > Cell 971-227-2477 > randall.benson at avangrid.com > > > In the interest of the environment, > please print only if necessary and recycle. > > > > > > > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > > > ============================================================== > > > > Please consider the environment before printing this email. > > > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > > > ============================================================== > > > > ============================================================== > > Please consider the environment before printing this email. > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > ============================================================== > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 17961 bytes Desc: not available URL: From selasley at icloud.com Fri Mar 20 15:26:50 2020 From: selasley at icloud.com (Scott Lasley) Date: Fri, 20 Mar 2020 15:26:50 -0400 Subject: [Matplotlib-users] trouble removing tick labels In-Reply-To: References: Message-ID: You can use axis.tick_params to turn off the labels. Replacing for ax in axs.flat: ax.label_outer() with for ax in axs.flat[1::2]: ax.tick_params(labelleft=False) will turn off the left tick labels on the plots in the second column Hth, Scott > On Mar 20, 2020, at 2:56 PM, Slavin, Jonathan wrote: > > Hi Eric, > > I think I've isolated the problem. In my figure I have been including colorbars for each plot. In my simple example, which I include below, label_outer works without the colorbars but not with them. > > Regarding using sharey, I am using the same y-axis in each row, but they differ between rows. If I use sharey, things get all messed up - the smaller images are shrunken and only take up part of the figure. In the end I was able to turn off the tick labelling by doing things like: > for label in ax.get_yticklabels(which='both'): > label.set_visible(False) > > I think this may have to do with the attributes of axs getting overwritten or something. If I print > axs[1,1].get_subplotspec().colspan.start > in the case with colorbars I get 0, whereas if I do it without colorbars, I get 1 as I should. Same applies to other axes and to rows. > > Here's the minimal example: > > import numpy as np > import matplotlib.pyplot as plt > > fig,axs = plt.subplots(2,2) > img0 = np.random.random((10,10)) > img1 = np.random.random((10,10)) > img2 = np.random.random((10,10)) > img3 = np.random.random((10,10)) > cax0 = axs[0,0].imshow(img0,extent=[0.,10.,0.,10.]) > fig.colorbar(cax0,ax=axs[0,0],pad=0.01) > cax1 = axs[0,1].imshow(img1,extent=[0.,10.,0.,10.]) > fig.colorbar(cax1,ax=axs[0,1],pad=0.01) > cax2 = axs[1,0].imshow(img2,extent=[0.,10.,0.,10.]) > fig.colorbar(cax2,ax=axs[1,0],pad=0.01) > cax3 = axs[1,1].imshow(img3,extent=[0.,10.,0.,10.]) > fig.colorbar(cax3,ax=axs[1,1],pad=0.01) > for ax in axs.flat: > ax.label_outer() > plt.show() > > On Fri, Mar 20, 2020 at 11:04 AM wrote: > Date: Thu, 19 Mar 2020 12:42:31 -1000 > From: Eric Firing > To: matplotlib-users at python.org > Subject: Re: [Matplotlib-users] trouble removing tick labels > Message-ID: <77e44a65-c519-705e-24ad-dc13f7c204c3 at hawaii.edu> > Content-Type: text/plain; charset=utf-8; format=flowed > > Jon, > > If you are removing the tick labels it suggests that the y-axes are all > matched, in which case using > > fig, axs = plt.subplots(2, 2, sharey=True) > > should do what you want. > > If not, please supply a minimal but complete example illustrating the > problem. > > Eric > > On 2020/03/19 11:36 AM, Slavin, Jonathan wrote: > > Hi, > > > > I'm making a plot that's a grid of 4 x 4 axes. I'd like to remove the > > tick labels for the y axes that are not in the first column. I tried > > using what I saw in an example: > > for ax in axs.flat: > > ? ? ax.label_outer() > > but that seems to have no effect. I found where the code that defines > > that function is and tried to use that code directly: > > for ax in axs.flat: > > ? ? if ax.colNum != 0: > > ? ? ? ? for label in ax.get_yticklabels(which='both'): > > ? ? ? ? ? ? label.set_visible(False) > > ? ? ? ? ax.get_yaxis().get_offset_text().set_visible(False) > > ? ? ? ? ax.set_ylabel("") > > but again no effect. Does anyone have any ideas why these are not > > working? Any help would be appreciated. > > > > Regards, > > Jon > -- > > Jonathan D. Slavin > Astrophysicist - High Energy Astrophysics Division > Center for Astrophysics | Harvard & Smithsonian > Office: (617) 496-7981 | Cell: (781) 363-0035 > 60 Garden Street | MS 83 | Cambridge, MA 02138 > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From efiring at hawaii.edu Fri Mar 20 19:36:14 2020 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 20 Mar 2020 13:36:14 -1000 Subject: [Matplotlib-users] trouble removing tick labels In-Reply-To: References: Message-ID: <110b057a-478e-18c0-7abf-115a13e2550c@hawaii.edu> On 2020/03/20 8:56 AM, Slavin, Jonathan wrote: > Regarding using sharey, I am using the same y-axis in each row, but they > differ between rows. If I use sharey, things get all messed up - the > smaller images are shrunken and only take up part of the figure. I think you want "sharey='row'". Eric From quantum.analyst at gmail.com Fri Mar 20 22:28:40 2020 From: quantum.analyst at gmail.com (Elliott Sales de Andrade) Date: Fri, 20 Mar 2020 22:28:40 -0400 Subject: [Matplotlib-users] [ANN] Matplotlib 3.2.1 release In-Reply-To: <134e1b5e-edc0-f99b-f48b-2cac05a6d95b@gmail.com> References: <134e1b5e-edc0-f99b-f48b-2cac05a6d95b@gmail.com> Message-ID: <979411ac-260c-d148-c275-fb5ce4d37371@gmail.com> Hi all, I'm a bit late on this, but Matplotlib 3.2.1 was released a couple days ago. This is the first bugfix release of the 3.2.x series. This release contains several critical bug-fixes: * fix Quiver.set_UVC calls with scalar inputs * fix bezier.get_parallels failure from floating point rounding errors * fix markers specified as tuples (polygons, stars, or asterisks) * fix saving PNGs to file objects in some places * fix saving figures using the nbAgg/notebook backend * fix saving with tight layout using the PGF backend * fix setting custom datapath in rcParams (note: it is still deprecated) * fix various issues running setup.py in non-CI environments * fix xpdf distiller * various minor bug and documentation fixes PS, since there was no release announcement for 3.2.0, here are its release notes: * default image interpolation is now `'antialiased'` to better handle down-sampling and reduce artifacts when up-sampling by small ratios. * change when ticks switch to using an offset to improve readability * improvements to auto-scaling and auto-limits * `DivergingNorm` has been renamed to `TwoSlopeNorm` * support for 3 and 4 digit hex colors (`#123` maps to `#112233`) * improvements to Logit scale ticker and formatter * control of where errorbars start getting placed with `errorevery` * correct kerning when laying out text * improvements to MovieRegistry For the full details please see the whats new [1] and API changes [2] in the documentation [1] https://matplotlib.org/3.2.0/users/whats_new.html [2] https://matplotlib.org/3.2.0/api/api_changes.html PPS, for packagers, only: Since I tagged this release, and not Thomas, it is signed by my GPG key. The fingerprint is: 23CA B59E 3332 F94D 26BE F037 8D86 E7FA E5EB 0C10 and it is also used to sign this message. -- Elliott -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 870 bytes Desc: OpenPGP digital signature URL: From nelle.varoquaux at gmail.com Wed Mar 18 03:09:55 2020 From: nelle.varoquaux at gmail.com (Nelle Varoquaux) Date: Wed, 18 Mar 2020 08:09:55 +0100 Subject: [Matplotlib-users] Announcing the 2020 John Hunter Excellence in Plotting Contest Message-ID: Dear all, In memory of John Hunter, we are pleased to announce the John Hunter Excellence in Plotting Contest for 2020. This open competition aims to highlight the importance of data visualization to scientific progress and showcase the capabilities of open source software. Participants are invited to submit scientific plots to be judged by a panel. The winning entries will be announced and displayed at SciPy 2020 or announced in the John Hunter Excellence in Plotting Contest website and youtube channel. John Hunter?s family are graciously sponsoring cash prizes for the winners in the following amounts: - 1st prize: $1000 - 2nd prize: $750 - 3rd prize: $500 - Entries must be submitted by June 1st to the form at https://forms.gle/SrexmkDwiAmDc7ej7 - Winners will be announced at Scipy 2020 in Austin, TX or publicly on the John Hunter Excellence in Plotting Contest website and youtube channel - Participants do not need to attend the Scipy conference. - Entries may take the definition of ?visualization? rather broadly. Entries may be, for example, a traditional printed plot, an interactive visualization for the web, a dashboard, or an animation. - Source code for the plot must be provided, in the form of Python code and/or a Jupyter notebook, along with a rendering of the plot in a widely used format. The rendering may be, for example, PDF for print, standalone HTML and Javascript for an interactive plot, or MPEG-4 for a video. If the original data can not be shared for reasons of size or licensing, "fake" data may be substituted, along with an image of the plot using real data. - Each entry must include a 300-500 word abstract describing the plot and its importance for a general scientific audience. - Entries will be judged on their clarity, innovation and aesthetics, but most importantly for their effectiveness in communicating a real-world problem. Entrants are encouraged to submit plots that were used during the course of research or work, rather than merely being hypothetical. - SciPy and the John Hunter Excellence in Plotting Contest organizers reserves the right to display any and all entries, whether prize-winning or not, at the conference, use in any materials or on its website, with attribution to the original author(s). - Past entries can be found at https://jhepc.github.io/ - Questions regarding the contest can be sent to jhepc.organizers at gmail.com John Hunter Excellence in Plotting Contest Co-Chairs Madicken Munk Nelle Varoquaux -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sun Mar 22 19:48:38 2020 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 22 Mar 2020 19:48:38 -0400 Subject: [Matplotlib-users] GSOC 2020 In-Reply-To: <5e318dba.1c69fb81.d2d62.7b50@mx.google.com> References: <5e318dba.1c69fb81.d2d62.7b50@mx.google.com> Message-ID: Yes, please see https://discourse.matplotlib.org/t/gsoc-due-march-31-18-00utc/20975 for more information. Tom On Sun, Mar 22, 2020 at 7:31 PM Utkarsh Bisaria <2utkarsh at gmail.com> wrote: > > > > > Hello, > > > > I want to know if matplotlib will be participating under NumFOCUS in GSOC > 2020?? > > > > Thanks > > Utkarsh Bisaria > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jslavin at cfa.harvard.edu Mon Mar 23 10:01:03 2020 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Mon, 23 Mar 2020 10:01:03 -0400 Subject: [Matplotlib-users] trouble removing tick labels In-Reply-To: References: Message-ID: Hi Eric et al., So I have confirmed that the thing that prevents label_outer from working the way I would expect it to is that after adding a colorbar to the subplot axes, the attributes colNum and rowNum are set to 0. Would you consider this a bug? I think I would. I'm thinking that it's because adding the colorbar creates a new set of axes into which the colorbar is placed. A minimal example that illustrates the issue is: fig,axs = plt.subplots(1,2) img0 = np.random.random((5,5)) img1 = np.random.random((5,5)) cax0 = axs[0].imshow(img0) fig.colorbar(cax0,ax=axs[0]) cax1 = axs[1].imshow(img1) print(f'axs[1].column = {axs[1].colNum}') # value is 1 fig.colorbar(cax1,ax=axs[1]) print(f'axs[1].column = {axs[1].colNum}') # values is 0 plt.show() Jon On Fri, Mar 20, 2020 at 2:56 PM Slavin, Jonathan wrote: > Hi Eric, > > I think I've isolated the problem. In my figure I have been including > colorbars for each plot. In my simple example, which I include below, > label_outer works without the colorbars but not with them. > > Regarding using sharey, I am using the same y-axis in each row, but they > differ between rows. If I use sharey, things get all messed up - the > smaller images are shrunken and only take up part of the figure. In the end > I was able to turn off the tick labelling by doing things like: > for label in ax.get_yticklabels(which='both'): > label.set_visible(False) > > I think this may have to do with the attributes of axs getting overwritten > or something. If I print > axs[1,1].get_subplotspec().colspan.start > in the case with colorbars I get 0, whereas if I do it without colorbars, > I get 1 as I should. Same applies to other axes and to rows. > > Here's the minimal example: > > import numpy as np > import matplotlib.pyplot as plt > > fig,axs = plt.subplots(2,2) > img0 = np.random.random((10,10)) > img1 = np.random.random((10,10)) > img2 = np.random.random((10,10)) > img3 = np.random.random((10,10)) > cax0 = axs[0,0].imshow(img0,extent=[0.,10.,0.,10.]) > fig.colorbar(cax0,ax=axs[0,0],pad=0.01) > cax1 = axs[0,1].imshow(img1,extent=[0.,10.,0.,10.]) > fig.colorbar(cax1,ax=axs[0,1],pad=0.01) > cax2 = axs[1,0].imshow(img2,extent=[0.,10.,0.,10.]) > fig.colorbar(cax2,ax=axs[1,0],pad=0.01) > cax3 = axs[1,1].imshow(img3,extent=[0.,10.,0.,10.]) > fig.colorbar(cax3,ax=axs[1,1],pad=0.01) > for ax in axs.flat: > ax.label_outer() > plt.show() > > On Fri, Mar 20, 2020 at 11:04 AM > wrote: > >> Date: Thu, 19 Mar 2020 12:42:31 -1000 >> From: Eric Firing >> To: matplotlib-users at python.org >> Subject: Re: [Matplotlib-users] trouble removing tick labels >> Message-ID: <77e44a65-c519-705e-24ad-dc13f7c204c3 at hawaii.edu> >> Content-Type: text/plain; charset=utf-8; format=flowed >> >> Jon, >> >> If you are removing the tick labels it suggests that the y-axes are all >> matched, in which case using >> >> fig, axs = plt.subplots(2, 2, sharey=True) >> >> should do what you want. >> >> If not, please supply a minimal but complete example illustrating the >> problem. >> >> Eric >> >> On 2020/03/19 11:36 AM, Slavin, Jonathan wrote: >> > Hi, >> > >> > I'm making a plot that's a grid of 4 x 4 axes. I'd like to remove the >> > tick labels for the y axes that are not in the first column. I tried >> > using what I saw in an example: >> > for ax in axs.flat: >> > ? ? ax.label_outer() >> > but that seems to have no effect. I found where the code that defines >> > that function is and tried to use that code directly: >> > for ax in axs.flat: >> > ? ? if ax.colNum != 0: >> > ? ? ? ? for label in ax.get_yticklabels(which='both'): >> > ? ? ? ? ? ? label.set_visible(False) >> > ? ? ? ? ax.get_yaxis().get_offset_text().set_visible(False) >> > ? ? ? ? ax.set_ylabel("") >> > but again no effect. Does anyone have any ideas why these are not >> > working? Any help would be appreciated. >> > >> > Regards, >> > Jon >> > -- > Jonathan D. Slavin > Astrophysicist - High Energy Astrophysics Division > Center for Astrophysics | Harvard & Smithsonian > Office: (617) 496-7981 | Cell: (781) 363-0035 > 60 Garden Street | MS 83 | Cambridge, MA 02138 > > > -- Jonathan D. Slavin Astrophysicist - High Energy Astrophysics Division Center for Astrophysics | Harvard & Smithsonian Office: (617) 496-7981 | Cell: (781) 363-0035 60 Garden Street | MS 83 | Cambridge, MA 02138 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Randall.Benson at avangrid.com Tue Mar 24 18:12:49 2020 From: Randall.Benson at avangrid.com (Benson, Randall) Date: Tue, 24 Mar 2020 22:12:49 +0000 Subject: [Matplotlib-users] Reshaping Tabular Data to Column Data Message-ID: Hi - I seem to be stuck here trying to convert downloaded data that is in tabular form since I need to analyze it in single column format. The data is from here and I'm using read_csv as shown below - pnadata1= pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data') The downloaded data looks like this with the values in months 1-12 across the columns below for each year 1948-present - 1948 2020 0 1948 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... 1 1949 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... 2 1950 -3.65 -1.69 -0.06 -0.23 -0.40 -1.9... 3 1951 -1.18 -2.11 -1.09 0.47 1.19 -0.5... 4 1952 -3.19 0.08 -0.69 0.89 -0.79 0.5... And, I need it to be reshaped to look like this in yyyymm values format so I can compare it easily to other downloaded data in the column format - 194801 -99.90 194802 -99.90 194803 -99.90 ... 202001 -3.45 202002 0.87 I've tried working with "melt" and "group" in different combinations but cannot figure it out given the online references. Thank you, Randall [Description: cid:image001.jpg at 01D34737.23261CB0] Randall P. Benson, PhD Wind Asset Meteorologist, Energy Resource - Onshore 1125 NW Couch Street, Suite 700 Portland, Oregon, USA 97209 Telephone 503-796-7129 Cell 971-227-2477 randall.benson at avangrid.com [Description: cid:image002.png at 01D34737.23261CB0] In the interest of the environment, please print only if necessary and recycle. ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 45526 bytes Desc: image001.jpg URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 3441 bytes Desc: image002.png URL: From selasley at icloud.com Tue Mar 24 21:28:18 2020 From: selasley at icloud.com (Scott Lasley) Date: Tue, 24 Mar 2020 21:28:18 -0400 Subject: [Matplotlib-users] Reshaping Tabular Data to Column Data In-Reply-To: References: Message-ID: Does this do what you want? # read data from noaa, set index to first column and column names to '00' - '12' df = pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data', skiprows=1, skipfooter=3, index_col=[0], header=None, names=['{:02d}'.format(i) for i in range(13)], delim_whitespace=True) # unstack the dataframe to get a Series with and a multiindex # consisting of the date and column name df = df.unstack() # sort index by [date, column name] to "group" the dates df = df.sort_index(level=[1,0]) # create a new index using the existing multiindex levels ndx = [int(''.join([y,c])) for y in df.index.levels[1].astype(str) for c in df.index.levels[0]] df.index = ndx df.head(28) 194801 -99.90 194802 -99.90 194803 -99.90 ... 194911 -99.90 194912 -99.90 195001 -3.65 195002 -1.69 195003 -0.06 195004 -0.23 df.tail(12) 202001 -0.95 202002 -0.07 202003 -99.90 202004 -99.90 202005 -99.90 202006 -99.90 202007 -99.90 202008 -99.90 202009 -99.90 202010 -99.90 202011 -99.90 202012 -99.90 Note that the 202001 and 202002 values do not agree with the values in your email message but do agree with the values on the website. Hth, Scott > On Mar 24, 2020, at 6:12 PM, Benson, Randall wrote: > > Hi ? > I seem to be stuck here trying to convert downloaded data that is in tabular form since I need to analyze it in single column format. The data is from here and I?m using read_csv as shown below ? > > pnadata1= pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data') > > The downloaded data looks like this with the values in months 1-12 across the columns below for each year 1948-present ? > > 1948 2020 > 0 1948 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... > 1 1949 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... > 2 1950 -3.65 -1.69 -0.06 -0.23 -0.40 -1.9... > 3 1951 -1.18 -2.11 -1.09 0.47 1.19 -0.5... > 4 1952 -3.19 0.08 -0.69 0.89 -0.79 0.5... > > And, I need it to be reshaped to look like this in yyyymm values format so I can compare it easily to other downloaded data in the column format ? > > 194801 -99.90 > 194802 -99.90 > 194803 -99.90 > ... > 202001 -3.45 > 202002 0.87 > > I?ve tried working with ?melt? and ?group? in different combinations but cannot figure it out given the online references. Thank you, > Randall > > > > Randall P. Benson, PhD > Wind Asset Meteorologist, Energy Resource - Onshore > > 1125 NW Couch Street, Suite 700 > Portland, Oregon, USA 97209 > Telephone 503-796-7129 > Cell 971-227-2477 > randall.benson at avangrid.com > > > > In the interest of the environment, > please print only if necessary and recycle. > > > > ============================================================== > > Please consider the environment before printing this email. > > If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. > > The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. > > ============================================================== > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From selasley at icloud.com Tue Mar 24 22:56:32 2020 From: selasley at icloud.com (Scott Lasley) Date: Tue, 24 Mar 2020 22:56:32 -0400 Subject: [Matplotlib-users] Reshaping Tabular Data to Column Data In-Reply-To: References: Message-ID: <04F17796-D812-4C1E-A197-76429AF8033D@icloud.com> Here's a version without the unnecessary string manipulations # read data from noaa, set the index to the first column df = pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data', skiprows=1, skipfooter=3, index_col=[0], header=None, engine='python', # c engine doesn't have skipfooter delim_whitespace=True) # unstack the dataframe to get a Series with a multiindex # consisting of the column name and date df = df.unstack() # create a new index using the existing multiindex levels ndx = [y * 100 + c for (c, y) in df.index.to_flat_index()] df.index = ndx df = df.sort_index() > On Mar 24, 2020, at 9:28 PM, Scott Lasley via Matplotlib-users wrote: > > Does this do what you want? > > # read data from noaa, set index to first column and column names to '00' - '12' > df = pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data', > skiprows=1, > skipfooter=3, > index_col=[0], > header=None, > names=['{:02d}'.format(i) for i in range(13)], > delim_whitespace=True) > # unstack the dataframe to get a Series with and a multiindex > # consisting of the date and column name > df = df.unstack() > # sort index by [date, column name] to "group" the dates > df = df.sort_index(level=[1,0]) > # create a new index using the existing multiindex levels > ndx = [int(''.join([y,c])) > for y in df.index.levels[1].astype(str) > for c in df.index.levels[0]] > df.index = ndx > df.head(28) > > 194801 -99.90 > 194802 -99.90 > 194803 -99.90 > ... > 194911 -99.90 > 194912 -99.90 > 195001 -3.65 > 195002 -1.69 > 195003 -0.06 > 195004 -0.23 > > df.tail(12) > > 202001 -0.95 > 202002 -0.07 > 202003 -99.90 > 202004 -99.90 > 202005 -99.90 > 202006 -99.90 > 202007 -99.90 > 202008 -99.90 > 202009 -99.90 > 202010 -99.90 > 202011 -99.90 > 202012 -99.90 > > Note that the 202001 and 202002 values do not agree with the values in your email message but do agree with the values on the website. > > Hth, > Scott > > >> On Mar 24, 2020, at 6:12 PM, Benson, Randall wrote: >> >> Hi ? >> I seem to be stuck here trying to convert downloaded data that is in tabular form since I need to analyze it in single column format. The data is from here and I?m using read_csv as shown below ? >> >> pnadata1= pd.read_csv('https://www.esrl.noaa.gov/psd/data/correlation/pna.data') >> >> The downloaded data looks like this with the values in months 1-12 across the columns below for each year 1948-present ? >> >> 1948 2020 >> 0 1948 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... >> 1 1949 -99.90 -99.90 -99.90 -99.90 -99.90 -99.9... >> 2 1950 -3.65 -1.69 -0.06 -0.23 -0.40 -1.9... >> 3 1951 -1.18 -2.11 -1.09 0.47 1.19 -0.5... >> 4 1952 -3.19 0.08 -0.69 0.89 -0.79 0.5... >> >> And, I need it to be reshaped to look like this in yyyymm values format so I can compare it easily to other downloaded data in the column format ? >> >> 194801 -99.90 >> 194802 -99.90 >> 194803 -99.90 >> ... >> 202001 -3.45 >> 202002 0.87 >> >> I?ve tried working with ?melt? and ?group? in different combinations but cannot figure it out given the online references. Thank you, >> Randall >> >> >> >> Randall P. Benson, PhD >> Wind Asset Meteorologist, Energy Resource - Onshore >> >> 1125 NW Couch Street, Suite 700 >> Portland, Oregon, USA 97209 >> Telephone 503-796-7129 >> Cell 971-227-2477 >> randall.benson at avangrid.com >> >> >> >> In the interest of the environment, >> please print only if necessary and recycle. >> >> >> >> ============================================================== >> >> Please consider the environment before printing this email. >> >> If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. >> >> The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. >> >> ============================================================== >> >> _______________________________________________ >> 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 duncan.kerr at live.com Wed Mar 25 07:05:03 2020 From: duncan.kerr at live.com (Duncan Kerr) Date: Wed, 25 Mar 2020 11:05:03 +0000 Subject: [Matplotlib-users] Fwd: Fwd: matplotlib - extend x-axis labels and scaling problem In-Reply-To: References: <86dd0cf5-07de-b653-1133-f5514a59d060@live.com> Message-ID: > > I have a couple of issues, trying to plot two y axes.? How do I > > make grid cover whole area of plot > > make xaxis labels go all way to right > > make both y axes use same scale > > get a legend for both plots onto the graph. > > my graph and code are as follows: > > #!c:/python/python import sys > import numpyas np > import pandasas pd > import matplotlibas mpl > import matplotlib.pyplotas plt > import seabornas sns > import warnings; > > warnings.filterwarnings(action='once') > > plt.style.use('seaborn-whitegrid') > sns.set_style("white") > > cl1='red' cl2='blue' cl3='grey' print("expected title filter1 filter3 file1 file2") > print("called with "+sys.argv[1]+","+sys.argv[2]+","+sys.argv[3]+","+sys.argv[4]) > # Version print(mpl.__version__)# > 3.0.0 print(sns.__version__)# > 0.9.0 # Import Data dfr = pd.read_csv(sys.argv[4]) > dfs = pd.read_csv(sys.argv[5]) > xyr = dfr.groupby(['c1']).count()['c2'] > xys = dfs.groupby(['c1']).count()['c2'] > > fig, ax = plt.subplots(1,1,figsize=(16,9),dpi=90) > > # print data for plots print(dfr.groupby('c1').count()) > > dfr.groupby(['c1']).count()['c2'].plot(ax=ax,color=cl1,label='leftfilter') > > # Decorations # ax1 (left Y axis) ax.set_xlabel('time',color=cl3,fontsize=20) > ax.tick_params(axis='x',rotation=0,labelcolor=cl3,labelsize=12) > ax.set_ylabel(sys.argv[2],color=cl1,fontsize=20) > ax.tick_params(axis='y',rotation=0,labelcolor=cl1) > ax.grid(alpha=.4) > s ="%s min %d max %d avg %d std %d" % ( > sys.argv[1], dfr.groupby('c1').count().min()['c2'], dfr.groupby('c1').count().max()['c2'], > dfr.groupby('c1').count().mean()['c2'], dfs.groupby('c1').count().std()['c2']) > ax.set_title(s,color=cl3) > > > # ax2 (right Y axis) ax2 = ax.twinx()# instantiate a second axes that shares the same x-axis ax2.tick_params(axis='x',rotation=0,labelcolor=cl3,labelsize=12) > dfs.groupby(['c1']).count()['c2'].plot(ax=ax2,color=cl2) > ax2.set_ylabel(sys.argv[3],color=cl2,fontsize=20) > ax2.tick_params(axis='y',labelcolor=cl2) > fig.tight_layout() > # place legend in good spot #plt.legend(loc=0) plt.show() > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: decchfafllgghohe.png Type: image/png Size: 182519 bytes Desc: not available URL: From selasley at icloud.com Thu Mar 26 08:39:25 2020 From: selasley at icloud.com (Scott Lasley) Date: Thu, 26 Mar 2020 08:39:25 -0400 Subject: [Matplotlib-users] matplotlib - extend x-axis labels and scaling problem In-Reply-To: References: <86dd0cf5-07de-b653-1133-f5514a59d060@live.com> Message-ID: <1361F6F0-C71B-4DC1-8050-925DAD3D476B@icloud.com> There may be a better way to do this, but you can manually set xlim, xticks and xticklabels to cover the entire data range. Use ax.legend() and ax2.legend() to show both legends. Use set_ylim and get_ylim to set both y axes to the same scale. import numpy as np import pandas as pd import matplotlib.pyplot as plt cl1='red' cl2='blue' cl3='grey' df1 = pd.DataFrame(data=np.random.standard_normal(31), columns=['df1'], index=pd.date_range('2020-01-01', '2020-01-01 00:30', freq='T')) df2 = pd.DataFrame(data=np.random.standard_normal(61) * 4, columns=['df2'], index=pd.date_range('2020-01-01', '2020-01-01 01', freq='T')) fig, ax = plt.subplots(1, 1, figsize=(16, 9), dpi=90, tight_layout=True) df1.plot(ax=ax, color=cl1) ax.set_xlabel('time', color=cl3, fontsize=20) ax.tick_params(axis='x', rotation=0, labelcolor=cl3, labelsize=12) ax.set_ylabel('SEND', color=cl1, fontsize=20) ax.tick_params(axis='y', rotation=0, labelcolor=cl1) ax.grid(alpha=.4) ax.set_title('Title', color=cl3) ax2 = ax.twinx() ax2.tick_params(axis='x', rotation=0, labelcolor=cl3, labelsize=12) df2.plot(ax=ax2, color=cl2) ax2.set_ylabel('RECV', color=cl2, fontsize=20) ax2.tick_params(axis='y', labelcolor=cl2) # pandas sets the label to the column name so set labels here ax.legend(loc='upper left', labels=['leftfilter']) ax2.legend(loc='upper right', labels=['rightreceived']) # set x ticks and tick labels. Use start, end and freq values # valid for your data tiks = pd.date_range(start=df1.index.min(), end=df2.index.max(), freq='5T') ax.set_xlim(tiks[0], tiks[-1]) ax.set_xticks(tiks); ax.set_xticklabels(tiks.time) # set left y limits to the right y limit values that were automatically # set by df2.plot(). could also set both ax and ax2 y limits to the same # values you choose ax.set_ylim(ax2.get_ylim()); # ylimits = [0, 20] # ax.set_ylim(ylimits) # ax2.set_ylim(ylimits) > On Mar 25, 2020, at 7:05 AM, Duncan Kerr wrote: > > >> >> I have a couple of issues, trying to plot two y axes. How do I >> >> make grid cover whole area of plot >> >> make xaxis labels go all way to right >> >> make both y axes use same scale >> >> get a legend for both plots onto the graph. >> >> my graph and code are as follows: >> >> >> >> #!c:/python/python >> >> import >> sys >> >> import numpy as >> np >> >> import pandas as >> pd >> >> import matplotlib as >> mpl >> >> import matplotlib.pyplot as >> plt >> >> import seaborn as >> sns >> >> import >> warnings; >> >> warnings.filterwarnings( >> action='once' >> ) >> >> plt.style.use( >> 'seaborn-whitegrid' >> ) >> sns.set_style( >> "white" >> ) >> >> cl1= >> 'red' >> >> cl2= >> 'blue' >> >> cl3= >> 'grey' >> >> >> print("expected title filter1 filter3 file1 file2" >> ) >> >> print("called with "+sys.argv[1]+","+sys.argv[2]+","+sys.argv[3]+","+sys.argv[4 >> ]) >> >> # Version >> >> print(mpl.__version__) >> # > 3.0.0 >> >> print(sns.__version__) >> # > 0.9.0 >> >> # Import Data >> >> dfr = pd.read_csv(sys.argv[4 >> ]) >> dfs = pd.read_csv(sys.argv[ >> 5 >> ]) >> xyr = dfr.groupby([ >> 'c1']).count()['c2' >> ] >> xys = dfs.groupby([ >> 'c1']).count()['c2' >> ] >> >> fig, ax = plt.subplots( >> 1, 1, figsize=(16, 9), dpi=90 >> ) >> >> >> # print data for plots >> >> print(dfr.groupby('c1' >> ).count()) >> >> dfr.groupby([ >> 'c1']).count()['c2'].plot(ax=ax,color=cl1, label='leftfilter' >> ) >> >> >> # Decorations >> >> # ax1 (left Y axis) >> >> ax.set_xlabel('time', color=cl3, fontsize=20 >> ) >> ax.tick_params( >> axis='x', rotation=0, labelcolor=cl3, labelsize=12 >> ) >> ax.set_ylabel(sys.argv[ >> 2], color=cl1, fontsize=20 >> ) >> ax.tick_params( >> axis='y', rotation=0, labelcolor >> =cl1) >> ax.grid( >> alpha=.4 >> ) >> s = >> "%s min %d max %d avg %d std %d" >> % ( >> sys.argv[ >> 1], dfr.groupby('c1').count().min()['c2'], dfr.groupby('c1').count().max()['c2' >> ], >> dfr.groupby( >> 'c1').count().mean()['c2'], dfs.groupby('c1').count().std()['c2' >> ]) >> ax.set_title(s, >> color >> =cl3) >> >> >> >> # ax2 (right Y axis) >> >> ax2 = ax.twinx() >> # instantiate a second axes that shares the same x-axis >> >> ax2.tick_params(axis='x', rotation=0, labelcolor=cl3, labelsize=12 >> ) >> dfs.groupby([ >> 'c1']).count()['c2'].plot(ax=ax2, color >> =cl2) >> ax2.set_ylabel(sys.argv[ >> 3], color=cl2, fontsize=20 >> ) >> ax2.tick_params( >> axis='y', labelcolor >> =cl2) >> fig.tight_layout() >> >> # place legend in good spot >> >> #plt.legend(loc=0) >> >> plt.show() >> >> > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users