From ndbecker2 at gmail.com Fri Aug 2 07:32:13 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 02 Aug 2019 07:32:13 -0400 Subject: [Matplotlib-users] plotting distributions, direct input of histogram Message-ID: I'm frequently plotting distributions using e.g., boxplot, violinplot. But I've already binned my data using my own histogram class. So I already have an array of bins, and array of counts for each bin. I don't see any way to directly input this data to plotting routines such as boxplot or violinplot. What I've been doing is using collections.Counter to convert this into a single array, for example if the value '10' occurs '1000' times, I produce an array with [10]*1000. Obviously, this doesn't scale to 10's of millions of samples. Is there any way to input my data that already has been binned and counted? Thanks, Neal (Also, I really wish the same for seaborn) From elch.rz at ruetz-online.de Fri Aug 2 16:33:44 2019 From: elch.rz at ruetz-online.de (Elan Ernest) Date: Fri, 2 Aug 2019 22:33:44 +0200 Subject: [Matplotlib-users] plotting distributions, direct input of histogram In-Reply-To: References: Message-ID: For boxplots with predefined statistics consider the `ax.bxp` function, https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.bxp.html For violinplots, one can use `ax.violin`, https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.violin.html however, you would need to have calculated the kernel density estimate yourself, which is in general impossible with already aggregated statistics. Am 02.08.2019 um 13:32 schrieb Neal Becker: > I'm frequently plotting distributions using e.g., boxplot, violinplot. But > I've already binned my data using my own histogram class. So I already have > an array of bins, and array of counts for each bin. > > I don't see any way to directly input this data to plotting routines such as > boxplot or violinplot. What I've been doing is using collections.Counter to > convert this into a single array, for example if the value '10' occurs > '1000' times, I produce an array with [10]*1000. Obviously, this doesn't > scale to 10's of millions of samples. > > Is there any way to input my data that already has been binned and counted? > > Thanks, > Neal > > (Also, I really wish the same for seaborn) > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > From pmhobson at gmail.com Fri Aug 2 18:46:09 2019 From: pmhobson at gmail.com (Paul Hobson) Date: Fri, 2 Aug 2019 15:46:09 -0700 Subject: [Matplotlib-users] plotting distributions, direct input of histogram In-Reply-To: References: Message-ID: I don't see how a binned histogram results are compatible with a boxplot, which directly computes the quartiles and fences from raw data. I don't understand how we'd begin to infer what those value are. -paul On Fri, Aug 2, 2019 at 1:36 PM Elan Ernest wrote: > For boxplots with predefined statistics consider the `ax.bxp` function, > > https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.bxp.html > > For violinplots, one can use `ax.violin`, > > https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.violin.html > > however, you would need to have calculated the kernel density estimate > yourself, which is in general impossible with already aggregated > statistics. > > > Am 02.08.2019 um 13:32 schrieb Neal Becker: > > I'm frequently plotting distributions using e.g., boxplot, violinplot. > But > > I've already binned my data using my own histogram class. So I already > have > > an array of bins, and array of counts for each bin. > > > > I don't see any way to directly input this data to plotting routines > such as > > boxplot or violinplot. What I've been doing is using > collections.Counter to > > convert this into a single array, for example if the value '10' occurs > > '1000' times, I produce an array with [10]*1000. Obviously, this doesn't > > scale to 10's of millions of samples. > > > > Is there any way to input my data that already has been binned and > counted? > > > > Thanks, > > Neal > > > > (Also, I really wish the same for seaborn) > > > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pnsinha68 at gmail.com Sat Aug 3 01:04:48 2019 From: pnsinha68 at gmail.com (Partha Sinha) Date: Sat, 3 Aug 2019 10:34:48 +0530 Subject: [Matplotlib-users] Plot Message-ID: I want to plot a list of 10 numbers. I want to plot each point after 5 secs (first point in o sec and 2nd point after 5 sec anf so on) and want to plot them in same graph. How to do? Regards Parth -------------- next part -------------- An HTML attachment was scrubbed... URL: From Nicolas.Rougier at inria.fr Sat Aug 3 03:34:24 2019 From: Nicolas.Rougier at inria.fr (Nicolas Rougier) Date: Sat, 3 Aug 2019 09:34:24 +0200 Subject: [Matplotlib-users] Calendar heatmap Message-ID: <75AE462E-7D4E-4607-9BA5-8B3F8FBA0513@inria.fr> As an exercise, I?ve been trying to make a calendar heatmap. Here is the result if anyone interested: Source: https://github.com/rougier/calendar-heatmap Nicolas -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: calendar-heatmap.png Type: image/png Size: 53482 bytes Desc: not available URL: From selasley at icloud.com Sat Aug 3 03:47:45 2019 From: selasley at icloud.com (Scott Lasley) Date: Sat, 3 Aug 2019 03:47:45 -0400 Subject: [Matplotlib-users] Plot In-Reply-To: References: Message-ID: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> This should do what you want. It works in a jupyter notebook but not in jupyterlab. It also works as a standalone python script if you comment out the %matplotlib notebook line. Best regards, Scott # based on https://matplotlib.org/gallery/animation/animate_decay.html#sphx-glr-gallery-animation-animate-decay-py # but uses a zip iterator for the frames variable in FuncAnimation instead of the data_gen generator function # used in the example # comment out this line if you are not running this in a jupyter notebook %matplotlib notebook # %matplotlib nbagg import numpy as np from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation def init_plot(): # if you know the data ranges you can set fixed # xlim and ylim limits here, otherwise uncomment # the ax.relim and ax.autoscale_view calls in # draw_pts to rescale the axes based on the # last data point plotted ax.set(xlim=[0, 11], ylim=[0, 120]) return [] def update_pts(data): x.append(data[0]) y.append(data[1]) pts.set_data(x, y) # ax.relim() # ax.autoscale_view(scaley=True) return [pts] # data to plot. replace with your data values xvals = np.arange(1, 11) yvals = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) # zip xvals[1:] and yvals[1:] since we are plotting # xvals[0], yvals[0] at time 0 after we create the figure xy_points = zip(xvals[1:], yvals[1:]) # create x and y lists containing the first point to be plotted. # update_pts will append the next x and y values from the iterator xy_points # to x and y every 5000ms and update the pts being plotted x = [xvals[0]] y = [yvals[0]] # create a figure and plot the first x, y point at time 0 fig, ax = plt.subplots() pts = ax.plot(x, y, 'o')[0] # loop through the remaining points and update the plot every # 5000ms anim = FuncAnimation(fig=fig, func=update_pts, frames=xy_points, init_func=init_plot, interval=5000, blit=False, repeat=False) plt.show() > On Aug 3, 2019, at 1:04 AM, Partha Sinha wrote: > > I want to plot a list of 10 numbers. I want to plot each point after 5 secs (first point in o sec and 2nd point after 5 sec anf so on) and want to plot them in same graph. > How to do? > Regards > Parth > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From jfoxrabinovitz at gmail.com Sat Aug 3 15:56:52 2019 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Sat, 3 Aug 2019 15:56:52 -0400 Subject: [Matplotlib-users] Calendar heatmap In-Reply-To: <75AE462E-7D4E-4607-9BA5-8B3F8FBA0513@inria.fr> References: <75AE462E-7D4E-4607-9BA5-8B3F8FBA0513@inria.fr> Message-ID: This is a neat tool. Do you have the option to show a color bar? - Joe On Sat, Aug 3, 2019 at 3:35 AM Nicolas Rougier wrote: > > As an exercise, I?ve been trying to make a calendar heatmap. > Here is the result if anyone interested: > > > Source: https://github.com/rougier/calendar-heatmap > > > Nicolas > _______________________________________________ > 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: calendar-heatmap.png Type: image/png Size: 53482 bytes Desc: not available URL: From Nicolas.Rougier at inria.fr Sat Aug 3 16:29:59 2019 From: Nicolas.Rougier at inria.fr (Nicolas Rougier) Date: Sat, 3 Aug 2019 22:29:59 +0200 Subject: [Matplotlib-users] Calendar heatmap In-Reply-To: References: <75AE462E-7D4E-4607-9BA5-8B3F8FBA0513@inria.fr> Message-ID: <0D8B618C-D098-4F71-B64E-257E8EECA21E@inria.fr> Each plot is a regular subplot and the heatmap is an imshow such that it is easy to add a colormap if you want. I?ve also added a small script to show a user GitHub activity for those interested. Just replace my name with yours. > On 3 Aug 2019, at 21:56, Joseph Fox-Rabinovitz wrote: > > This is a neat tool. Do you have the option to show a color bar? > > - Joe > > On Sat, Aug 3, 2019 at 3:35 AM Nicolas Rougier wrote: > > As an exercise, I?ve been trying to make a calendar heatmap. > Here is the result if anyone interested: > > > > Source: https://github.com/rougier/calendar-heatmap > > > Nicolas > _______________________________________________ > 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: github-activity.png Type: image/png Size: 56115 bytes Desc: not available URL: From tcaswell at gmail.com Sat Aug 3 18:41:15 2019 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 3 Aug 2019 18:41:15 -0400 Subject: [Matplotlib-users] Calendar heatmap In-Reply-To: <0D8B618C-D098-4F71-B64E-257E8EECA21E@inria.fr> References: <75AE462E-7D4E-4607-9BA5-8B3F8FBA0513@inria.fr> <0D8B618C-D098-4F71-B64E-257E8EECA21E@inria.fr> Message-ID: Nicolas, That is super cool! Tom On Sat, Aug 3, 2019 at 4:30 PM Nicolas Rougier wrote: > Each plot is a regular subplot and the heatmap is an imshow such that it > is easy to add a colormap if you want. > > I?ve also added a small script to show a user GitHub activity for those > interested. Just replace my name with yours. > > > > > On 3 Aug 2019, at 21:56, Joseph Fox-Rabinovitz > wrote: > > This is a neat tool. Do you have the option to show a color bar? > > - Joe > > On Sat, Aug 3, 2019 at 3:35 AM Nicolas Rougier > wrote: > > As an exercise, I?ve been trying to make a calendar heatmap. > Here is the result if anyone interested: > > > > Source: https://github.com/rougier/calendar-heatmap > > > Nicolas > _______________________________________________ > 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 > -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: github-activity.png Type: image/png Size: 56115 bytes Desc: not available URL: From pnsinha68 at gmail.com Sun Aug 4 11:53:24 2019 From: pnsinha68 at gmail.com (Partha Sinha) Date: Sun, 4 Aug 2019 21:23:24 +0530 Subject: [Matplotlib-users] Plot In-Reply-To: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> References: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> Message-ID: Awesome, thanks! partha On Sat, 3 Aug 2019 at 13:17, Scott Lasley wrote: > This should do what you want. It works in a jupyter notebook but not in > jupyterlab. It also works as a standalone python script if you comment out > the %matplotlib notebook line. > > Best regards, > Scott > > > > # based on > https://matplotlib.org/gallery/animation/animate_decay.html#sphx-glr-gallery-animation-animate-decay-py > # but uses a zip iterator for the frames variable in FuncAnimation instead > of the data_gen generator function > # used in the example > > # comment out this line if you are not running this in a jupyter notebook > %matplotlib notebook > # %matplotlib nbagg > > import numpy as np > from matplotlib import pyplot as plt > from matplotlib.animation import FuncAnimation > > > def init_plot(): > # if you know the data ranges you can set fixed > # xlim and ylim limits here, otherwise uncomment > # the ax.relim and ax.autoscale_view calls in > # draw_pts to rescale the axes based on the > # last data point plotted > ax.set(xlim=[0, 11], ylim=[0, 120]) > return [] > > > def update_pts(data): > x.append(data[0]) > y.append(data[1]) > pts.set_data(x, y) > # ax.relim() > # ax.autoscale_view(scaley=True) > return [pts] > > > # data to plot. replace with your data values > xvals = np.arange(1, 11) > yvals = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) > > # zip xvals[1:] and yvals[1:] since we are plotting > # xvals[0], yvals[0] at time 0 after we create the figure > xy_points = zip(xvals[1:], yvals[1:]) > > # create x and y lists containing the first point to be plotted. > # update_pts will append the next x and y values from the iterator > xy_points > # to x and y every 5000ms and update the pts being plotted > x = [xvals[0]] > y = [yvals[0]] > > # create a figure and plot the first x, y point at time 0 > fig, ax = plt.subplots() > pts = ax.plot(x, y, 'o')[0] > > # loop through the remaining points and update the plot every > # 5000ms > anim = FuncAnimation(fig=fig, > func=update_pts, > frames=xy_points, > init_func=init_plot, > interval=5000, > blit=False, > repeat=False) > > plt.show() > > > > > On Aug 3, 2019, at 1:04 AM, Partha Sinha wrote: > > > > I want to plot a list of 10 numbers. I want to plot each point after 5 > secs (first point in o sec and 2nd point after 5 sec anf so on) and want to > plot them in same graph. > > How to do? > > Regards > > Parth > > _______________________________________________ > > 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 ndbecker2 at gmail.com Mon Aug 5 14:59:57 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Mon, 05 Aug 2019 14:59:57 -0400 Subject: [Matplotlib-users] plotting distributions, direct input of histogram References: Message-ID: Binning the data will of course results in some quantization error, but if the bins are small enough that would be acceptable in my application. Paul Hobson wrote: > I don't see how a binned histogram results are compatible with a boxplot, > which directly computes the quartiles and fences from raw data. > > I don't understand how we'd begin to infer what those value are. > -paul > > On Fri, Aug 2, 2019 at 1:36 PM Elan Ernest > wrote: > >> For boxplots with predefined statistics consider the `ax.bxp` function, >> >> https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.bxp.html >> >> For violinplots, one can use `ax.violin`, >> >> https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.violin.html >> >> however, you would need to have calculated the kernel density estimate >> yourself, which is in general impossible with already aggregated >> statistics. >> >> >> Am 02.08.2019 um 13:32 schrieb Neal Becker: >> > I'm frequently plotting distributions using e.g., boxplot, violinplot. >> But >> > I've already binned my data using my own histogram class. So I already >> have >> > an array of bins, and array of counts for each bin. >> > >> > I don't see any way to directly input this data to plotting routines >> such as >> > boxplot or violinplot. What I've been doing is using >> collections.Counter to >> > convert this into a single array, for example if the value '10' occurs >> > '1000' times, I produce an array with [10]*1000. Obviously, this >> > doesn't scale to 10's of millions of samples. >> > >> > Is there any way to input my data that already has been binned and >> counted? >> > >> > Thanks, >> > Neal >> > >> > (Also, I really wish the same for seaborn) >> > >> > _______________________________________________ >> > 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 pmhobson at gmail.com Mon Aug 5 16:39:44 2019 From: pmhobson at gmail.com (Paul Hobson) Date: Mon, 5 Aug 2019 13:39:44 -0700 Subject: [Matplotlib-users] plotting distributions, direct input of histogram In-Reply-To: References: Message-ID: In that case, I think you should take Elan's advice, compute the box stats from your histogram data however you feel is appropriate, and then feed that to Axes.bxp, which expects a list of dictionaries. we split up boxplot into the cbook.boxplot_stats and Axes.bxp for uses cases that we couldn't anticipate. -paul On Mon, Aug 5, 2019 at 12:00 PM Neal Becker wrote: > Binning the data will of course results in some quantization error, but if > the bins are small enough that would be acceptable in my application. > > Paul Hobson wrote: > > > I don't see how a binned histogram results are compatible with a boxplot, > > which directly computes the quartiles and fences from raw data. > > > > I don't understand how we'd begin to infer what those value are. > > -paul > > > > On Fri, Aug 2, 2019 at 1:36 PM Elan Ernest > > wrote: > > > >> For boxplots with predefined statistics consider the `ax.bxp` function, > >> > >> https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.bxp.html > >> > >> For violinplots, one can use `ax.violin`, > >> > >> > https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.violin.html > >> > >> however, you would need to have calculated the kernel density estimate > >> yourself, which is in general impossible with already aggregated > >> statistics. > >> > >> > >> Am 02.08.2019 um 13:32 schrieb Neal Becker: > >> > I'm frequently plotting distributions using e.g., boxplot, violinplot. > >> But > >> > I've already binned my data using my own histogram class. So I > already > >> have > >> > an array of bins, and array of counts for each bin. > >> > > >> > I don't see any way to directly input this data to plotting routines > >> such as > >> > boxplot or violinplot. What I've been doing is using > >> collections.Counter to > >> > convert this into a single array, for example if the value '10' occurs > >> > '1000' times, I produce an array with [10]*1000. Obviously, this > >> > doesn't scale to 10's of millions of samples. > >> > > >> > Is there any way to input my data that already has been binned and > >> counted? > >> > > >> > Thanks, > >> > Neal > >> > > >> > (Also, I really wish the same for seaborn) > >> > > >> > _______________________________________________ > >> > Matplotlib-users mailing list > >> > Matplotlib-users at python.org > >> > https://mail.python.org/mailman/listinfo/matplotlib-users > >> > > >> > > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Matplotlib-users at python.org > >> https://mail.python.org/mailman/listinfo/matplotlib-users > >> > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brenbarn at brenbarn.net Fri Aug 9 02:50:10 2019 From: brenbarn at brenbarn.net (Brendan Barnwell) Date: Thu, 08 Aug 2019 23:50:10 -0700 Subject: [Matplotlib-users] Is there any way to get interactive matplotlib in Jupyterlab without conda-forge? Message-ID: <5D4D17A2.9040106@brenbarn.net> I was recently told ( file:///C:/Users/BrenBarn/AppData/Roaming/jupyter/runtime/nbserver-6156-open.html ) that Jupyterlab is supposed to be ready for prime time. For me that would include interactive use of Matplotlib. Apparently the way to do this in Jupyterlab is with ipympl, aka "jupyter-matplotlib" at https://github.com/matplotlib/jupyter-matplotlib . Looking at the instructions, I see it tells me to install from conda-forge. However, I have found several warnings (e.g., here https://github.com/conda/conda/issues/8920#issuecomment-519105949 ) that mixing conda defaults and conda-forge channels can cause problems. I have experienced this myself with conda going crazy upgrading and downgrading packages due to slight version differences between the packages in different channels. I am going to be teaching a class using Python. I do not want to use conda-forge because I want to keep installation of everything as simple as possible for the students and avoid the possibility of such problems. So my question is: is it possible to get fully functional interactive Matplotlib in Jupyterlab WITHOUT ever using conda-forge? If not, I would say that Jupyterlab is not really ready for primetime! (I realize that, if the answer is no, that may be more an Anaconda issue than a Matplotlib or Jupyter issue, but I'm just trying to figure out whether it's actually possible to replicate my working Jupyter notebook environment in Jupyterlab using only the conda defaults channel.) Thanks, -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From jason at jasongrout.org Fri Aug 9 08:25:48 2019 From: jason at jasongrout.org (Jason Grout) Date: Fri, 9 Aug 2019 05:25:48 -0700 Subject: [Matplotlib-users] Is there any way to get interactive matplotlib in Jupyterlab without conda-forge? In-Reply-To: <5D4D17A2.9040106@brenbarn.net> References: <5D4D17A2.9040106@brenbarn.net> Message-ID: We can see from https://anaconda.org/search?q=ipympl that the Anaconda channel is not publishing ipympl. You can install everything in a new environment from conda-forge, which would avoid the problem of mixing channels. That is what I typically do, adding a couple of lines to the config file or a couple of command line switches to the install command. As you say, publishing this package is an Anaconda issue, totally outside of our control in developing and publishing JupyterLab. Maybe you could request Anaconda look into shipping ipympl? I suppose from your perspective it would be more correct to use the exact same logic to say that Anaconda's support for JupyterLab is not quite ready for prime time, given that shipping this package is an Anaconda issue and not a JupyterLab issue :). (I would not make that statement personally, but I understand your perspective.) Thanks, Jason On Thu, Aug 8, 2019 at 11:51 PM Brendan Barnwell wrote: > I was recently told ( > file:///C:/Users/BrenBarn/AppData/Roaming/jupyter/runtime/nbserver-6156-open.html > > ) that Jupyterlab is supposed to be ready for prime time. For me that > would include interactive use of Matplotlib. Apparently the way to do > this in Jupyterlab is with ipympl, aka "jupyter-matplotlib" at > https://github.com/matplotlib/jupyter-matplotlib . > > Looking at the instructions, I see it tells me to install from > conda-forge. However, I have found several warnings (e.g., here > https://github.com/conda/conda/issues/8920#issuecomment-519105949 ) that > mixing conda defaults and conda-forge channels can cause problems. I > have experienced this myself with conda going crazy upgrading and > downgrading packages due to slight version differences between the > packages in different channels. > > I am going to be teaching a class using Python. I do not want to > use > conda-forge because I want to keep installation of everything as simple > as possible for the students and avoid the possibility of such problems. > > So my question is: is it possible to get fully functional > interactive > Matplotlib in Jupyterlab WITHOUT ever using conda-forge? If not, I > would say that Jupyterlab is not really ready for primetime! (I realize > that, if the answer is no, that may be more an Anaconda issue than a > Matplotlib or Jupyter issue, but I'm just trying to figure out whether > it's actually possible to replicate my working Jupyter notebook > environment in Jupyterlab using only the conda defaults channel.) > > Thanks, > -- > Brendan Barnwell > "Do not follow where the path may lead. Go, instead, where there is no > path, and leave a trail." > --author unknown > _______________________________________________ > 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 sunshine.e4u at gmail.com Fri Aug 9 10:54:14 2019 From: sunshine.e4u at gmail.com (Henry Ekene) Date: Fri, 9 Aug 2019 15:54:14 +0100 Subject: [Matplotlib-users] Why are these plots different? Message-ID: Hello, Matplotlib Users, My challenge is that I saw this below image somewhere [image: Screenshot from 2019-08-09 15-24-34.png]and i decided to reproduce it using the same matplotlib codes but it turned out that my own image appear different as can be seen below [image: Screenshot from 2019-08-09 15-28-38.png]Please why is mine different in color, and what can I do to get the exact image as the other one? Thanks for your help. Henry -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-24-34.png Type: image/png Size: 102136 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-28-38.png Type: image/png Size: 53320 bytes Desc: not available URL: From bruno.pagani at astrophysics.eu Fri Aug 9 11:00:08 2019 From: bruno.pagani at astrophysics.eu (Bruno Pagani) Date: Fri, 9 Aug 2019 17:00:08 +0200 Subject: [Matplotlib-users] Why are these plots different? In-Reply-To: References: Message-ID: Hi, Le 09/08/2019 ? 16:54, Henry Ekene a ?crit?: > Hello, Matplotlib Users, > > My challenge is that I saw this below image somewhere? > Screenshot from 2019-08-09 15-24-34.pngand i decided to reproduce it > using the same matplotlib codes but it turned out that my own image > appear different as can be seen below? > Screenshot from 2019-08-09 15-28-38.pngPlease why is mine different in > color, and what can I do to get the exact image as the other one? > Thanks for your help. > > Henry You use a different version of matplotib than whoever made the first one. Lots of things have changed regarding defaults, including colormap. You are using the ?new? viridis colormap, the plot above looks like jet. This is not the only difference between the two plots (look at e.g. ticks direction, spine?). To reproduce the old plot, the easiest would be to use the classic stylesheet of matplotlib with `plt.style.use("classic")`, to be added after importing matplotlib. Regards, Bruno -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-24-34.png Type: image/png Size: 102136 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-28-38.png Type: image/png Size: 53320 bytes Desc: not available URL: From ben.v.root at gmail.com Fri Aug 9 11:17:08 2019 From: ben.v.root at gmail.com (Benjamin Root) Date: Fri, 9 Aug 2019 11:17:08 -0400 Subject: [Matplotlib-users] Why are these plots different? In-Reply-To: References: Message-ID: Indeed, this is the reason. Please note that there is a reason why the Jet colormap is no longer our default colormap. We aren't the only plotting system to drop Jet as the default colormap (matlab and some others switch away from it). Notice in the original image, the colormap would lead the viewer to believe that the gradients are larger than they actually are. This effect has been shown in studies to lead to incorrect conclusions about the data (particularly leading to incorrect medical diagnosis!). The viridis colormap, which has been matplotlib's default for a few years now, is considered to be among most "perceptually uniform" colormap out there. Cheers! Ben Root On Fri, Aug 9, 2019 at 11:07 AM Bruno Pagani wrote: > Hi, > > Le 09/08/2019 ? 16:54, Henry Ekene a ?crit : > > Hello, Matplotlib Users, > > My challenge is that I saw this below image somewhere > [image: Screenshot from 2019-08-09 15-24-34.png]and i decided to > reproduce it using the same matplotlib codes but it turned out that my own > image appear different as can be seen below > [image: Screenshot from 2019-08-09 15-28-38.png]Please why is mine > different in color, and what can I do to get the exact image as the other > one? Thanks for your help. > > Henry > > You use a different version of matplotib than whoever made the first one. > Lots of things have changed regarding defaults, including colormap. You are > using the ?new? viridis colormap, the plot above looks like jet. > > This is not the only difference between the two plots (look at e.g. ticks > direction, spine?). To reproduce the old plot, the easiest would be to use > the classic stylesheet of matplotlib with `plt.style.use("classic")`, to be > added after importing matplotlib. > > Regards, > Bruno > _______________________________________________ > 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: Screenshot from 2019-08-09 15-24-34.png Type: image/png Size: 102136 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-28-38.png Type: image/png Size: 53320 bytes Desc: not available URL: From elch.rz at ruetz-online.de Fri Aug 9 11:18:09 2019 From: elch.rz at ruetz-online.de (Elan Ernest) Date: Fri, 9 Aug 2019 17:18:09 +0200 Subject: [Matplotlib-users] Why are these plots different? In-Reply-To: References: Message-ID: The first plot uses the `jet` colormap, the second one the `viridis` colormap. You can set the colormap via the `cmap` argument (contourf(..., cmap="jet")) Note however, that we (more or less strongly) discourage the use of the jet colormap for heatmaps like this. This plot makes up a nice example for why: The jet colormap results in "features" being seen in the data, which aren't actually there. For more, check * the colormaps tutorial (https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html), * the API change note (https://matplotlib.org/users/dflt_style_changes.html?highlight=jet%20viridis#colormap), * this stackoverflow question https://stats.stackexchange.com/questions/223315/why-use-colormap-viridis-over-jet Am 09.08.2019 um 16:54 schrieb Henry Ekene: > Hello, Matplotlib Users, > > My challenge is that I saw this below image somewhere > Screenshot from 2019-08-09 15-24-34.pngand i decided to reproduce it > using the same matplotlib codes but it turned out that my own image > appear different as can be seen below > Screenshot from 2019-08-09 15-28-38.pngPlease why is mine different in > color, and what can I do to get the exact image as the other one? > Thanks for your help. > > Henry > > _______________________________________________ > 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: Screenshot from 2019-08-09 15-24-34.png Type: image/png Size: 102136 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2019-08-09 15-28-38.png Type: image/png Size: 53320 bytes Desc: not available URL: From sunshine.e4u at gmail.com Fri Aug 9 14:49:12 2019 From: sunshine.e4u at gmail.com (Henry Ekene) Date: Fri, 9 Aug 2019 19:49:12 +0100 Subject: [Matplotlib-users] Why are these plots different? In-Reply-To: References: Message-ID: Thank you so much! Bruno, Elan Ernest, and Ben Root, you guys are wonderful! I added the matplotlib's "classic style" option as suggested by Bruno, and to my surprise, it worked! On the other hand, the "jet" colormap as an added argument, suggested by Elan Ernest also produced what I was looking for. Meanwhile, I've also taken note that the result produced by the "jet" colormap may be misleading, the reason for its discontinued use as the default, as explained by Ben and Elan. You saved the day for me! And I've learnt a great deal from you guys. God bless you all! Henry On 8/9/19, Elan Ernest wrote: > The first plot uses the `jet` colormap, the second one the `viridis` > colormap. You can set the colormap via the `cmap` argument > (contourf(..., cmap="jet")) > > Note however, that we (more or less strongly) discourage the use of the > jet colormap for heatmaps like this. This plot makes up a nice example > for why: The jet colormap results in "features" being seen in the data, > which aren't actually there. > > For more, check > > * the colormaps tutorial > (https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html), > > * the API change note > (https://matplotlib.org/users/dflt_style_changes.html?highlight=jet%20viridis#colormap), > > * this stackoverflow question > https://stats.stackexchange.com/questions/223315/why-use-colormap-viridis-over-jet > > > > Am 09.08.2019 um 16:54 schrieb Henry Ekene: >> Hello, Matplotlib Users, >> >> My challenge is that I saw this below image somewhere >> Screenshot from 2019-08-09 15-24-34.pngand i decided to reproduce it >> using the same matplotlib codes but it turned out that my own image >> appear different as can be seen below >> Screenshot from 2019-08-09 15-28-38.pngPlease why is mine different in >> color, and what can I do to get the exact image as the other one? >> Thanks for your help. >> >> Henry >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > From Nicolas.Rougier at inria.fr Sun Aug 11 13:34:54 2019 From: Nicolas.Rougier at inria.fr (Nicolas Rougier) Date: Sun, 11 Aug 2019 19:34:54 +0200 Subject: [Matplotlib-users] Matplotlib 3.1 cheat sheet Message-ID: I just made a matplotlib cheat sheet that might come handy when you don?t remember the name of a function or a parameter. It?s available from https://github.com/rougier/matplotlib-cheatsheet Nicolas -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: matplotlib-cheatsheet.png Type: image/png Size: 805061 bytes Desc: not available URL: From nathan.goldbaum at gmail.com Sun Aug 11 13:42:31 2019 From: nathan.goldbaum at gmail.com (Nathan) Date: Sun, 11 Aug 2019 12:42:31 -0500 Subject: [Matplotlib-users] Matplotlib 3.1 cheat sheet In-Reply-To: References: Message-ID: Woah this is awesome! Thank you for sharing. On Sun, Aug 11, 2019 at 12:36 PM Nicolas Rougier wrote: > > I just made a matplotlib cheat sheet that might come handy when you don?t > remember the name of a function or a parameter. It?s available from > https://github.com/rougier/matplotlib-cheatsheet > > Nicolas > > _______________________________________________ > 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: matplotlib-cheatsheet.png Type: image/png Size: 805061 bytes Desc: not available URL: From story645 at gmail.com Sun Aug 11 13:58:23 2019 From: story645 at gmail.com (Hannah) Date: Sun, 11 Aug 2019 13:58:23 -0400 Subject: [Matplotlib-users] Matplotlib 3.1 cheat sheet In-Reply-To: References: Message-ID: This is the best! Any chance you'd be open to creating a PR for it? (Or let me put in the PR on your behalf). I'm trying to get a new cheetsheet section going in the docs and this would be beyond perfect for it. On Sun, Aug 11, 2019 at 1:43 PM Nathan wrote: > Woah this is awesome! Thank you for sharing. > > On Sun, Aug 11, 2019 at 12:36 PM Nicolas Rougier > wrote: > >> >> I just made a matplotlib cheat sheet that might come handy when you don?t >> remember the name of a function or a parameter. It?s available from >> https://github.com/rougier/matplotlib-cheatsheet >> >> Nicolas >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: matplotlib-cheatsheet.png Type: image/png Size: 805061 bytes Desc: not available URL: From Nicolas.Rougier at inria.fr Sun Aug 11 14:06:44 2019 From: Nicolas.Rougier at inria.fr (Nicolas Rougier) Date: Sun, 11 Aug 2019 20:06:44 +0200 Subject: [Matplotlib-users] Matplotlib 3.1 cheat sheet In-Reply-To: References: Message-ID: <1078653E-EE8B-43B4-B852-8AD28B592385@inria.fr> Sure, no problem. I?m not sure where to insert it as a PR so if you can do it that would be great. I uploaded all the sources on the repo but the matplotlib text, legend and window that I dseigned with some external tools. I think it might be possible to generate the whole cheatsheet using matplotlib only but this will need extra work. Nicolas > On 11 Aug 2019, at 19:58, Hannah wrote: > > This is the best! Any chance you'd be open to creating a PR for it? (Or let me put in the PR on your behalf). I'm trying to get a new cheetsheet section going in the docs and this would be beyond perfect for it. > > > On Sun, Aug 11, 2019 at 1:43 PM Nathan wrote: > Woah this is awesome! Thank you for sharing. > > On Sun, Aug 11, 2019 at 12:36 PM Nicolas Rougier wrote: > > I just made a matplotlib cheat sheet that might come handy when you don?t remember the name of a function or a parameter. It?s available from https://github.com/rougier/matplotlib-cheatsheet > > Nicolas > > > _______________________________________________ > 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 animatore.trps03000x at didasca.org Tue Aug 13 04:38:13 2019 From: animatore.trps03000x at didasca.org (Animatore. TRPS03000X) Date: Tue, 13 Aug 2019 10:38:13 +0200 Subject: [Matplotlib-users] Matplotlib-users Digest, Vol 48, Issue 2 In-Reply-To: References: Message-ID: Dears all, I solved the issue changing the command 'ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=5,repeat=True) ' and my Open Physics Laboratory works fine!! Thanks a bunch far all! Bye, Marco Il giorno mar 16 lug 2019 alle ore 18:02 < matplotlib-users-request at python.org> ha scritto: > Send Matplotlib-users mailing list submissions to > matplotlib-users at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/matplotlib-users > or, via email, send a message with subject or body 'help' to > matplotlib-users-request at python.org > > You can reach the person managing the list at > matplotlib-users-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Matplotlib-users digest..." > > > Today's Topics: > > 1. Help request serila data plot, Ubuntu 18 (Animatore. TRPS03000X) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 15 Jul 2019 21:05:16 +0200 > From: "Animatore. TRPS03000X" > To: matplotlib-users at python.org > Subject: [Matplotlib-users] Help request serila data plot, Ubuntu 18 > Message-ID: > uo_-vD6AoN6hw at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Dear matplot users, > > I have installed Ubuntu 18 on my computer and Matplotlib, I use it to graph > position vs. time of moving objects by serial data. > > The python script is the following: > > > import matplotlib > > matplotlib.use("Qt5Agg") > > import numpy as np > > import matplotlib.pyplot as plt > > import matplotlib.animation as animation > > from time import sleep > > import serial > > import time > > fine="c" > > pre="ciao" > > while (fine != "f"): > > raw_input("\n\n\n Premi Enter per far partire la registrazione dei > dati") > > xdata, ydata = [], [] > > ser = serial.Serial('/dev/ttyACM0', 9600) > > while (False): > > pre=ser.readline() > > pre=ser.readline() > > prec = float(pre) > > y=prec > > fig, ax = plt.subplots() > > line, = ax.plot([], [], lw=2) > > ax.set_ylim(0, 90) > > ax.set_xlim(0, 10) > > ax.grid() > > def data_gen(): > > t=0 > > y=0 > > cnt=0 > > p=0 > > a = ser.readline() > > while (True)&(t < 10): > > a = ser.readline() > > y = float(a) > > if (y != 0) : > > t = (time.time() - start) > > t = float(t) > > yield t, y > > def run(data): > > t,y = data > > xdata.append(t) > > ydata.append(y) > > ax.figure.canvas.draw() > > line.set_data(xdata, ydata) > > return line, > > data_gen.t = 0 > > while (abs(y-prec) < 2): > > if True: > > a = ser.readline() > > y = float(a) > > start = time.time() > > ani = animation.FuncAnimation(fig, run, data_gen, blit=True, > interval=5,repeat=False) > > plt.show() > > stop =0 > > fine=raw_input("Premi f per finire :") > > > It works fine, but after the plotting (10 seconds), there is a problem, I > cannnot use the tools of the matplot window, i.e. when I try to zoom, after > selecting the area, the plot desappear. > > Can you help me? > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/matplotlib-users/attachments/20190715/32c8e462/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ------------------------------ > > End of Matplotlib-users Digest, Vol 48, Issue 2 > *********************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pnsinha68 at gmail.com Wed Aug 14 00:47:20 2019 From: pnsinha68 at gmail.com (Partha Sinha) Date: Wed, 14 Aug 2019 10:17:20 +0530 Subject: [Matplotlib-users] Plot In-Reply-To: References: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> Message-ID: I got the solution as suggested by scott. My new problem is: Lets say I will generate lets two pairs of 10 random numbers, say x and y. When first pair of x and y is generated, it will be plotted. Again when second set of number is generated, it will appear on the same graph and not on 2nd graph. This will continue till 10th pair. How to do this? Regards Parth On 3 Aug 2019 1:17 pm, "Scott Lasley" wrote: This should do what you want. It works in a jupyter notebook but not in jupyterlab. It also works as a standalone python script if you comment out the %matplotlib notebook line. Best regards, Scott # based on https://matplotlib.org/gallery/animation/animate_ decay.html#sphx-glr-gallery-animation-animate-decay-py # but uses a zip iterator for the frames variable in FuncAnimation instead of the data_gen generator function # used in the example # comment out this line if you are not running this in a jupyter notebook %matplotlib notebook # %matplotlib nbagg import numpy as np from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation def init_plot(): # if you know the data ranges you can set fixed # xlim and ylim limits here, otherwise uncomment # the ax.relim and ax.autoscale_view calls in # draw_pts to rescale the axes based on the # last data point plotted ax.set(xlim=[0, 11], ylim=[0, 120]) return [] def update_pts(data): x.append(data[0]) y.append(data[1]) pts.set_data(x, y) # ax.relim() # ax.autoscale_view(scaley=True) return [pts] # data to plot. replace with your data values xvals = np.arange(1, 11) yvals = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) # zip xvals[1:] and yvals[1:] since we are plotting # xvals[0], yvals[0] at time 0 after we create the figure xy_points = zip(xvals[1:], yvals[1:]) # create x and y lists containing the first point to be plotted. # update_pts will append the next x and y values from the iterator xy_points # to x and y every 5000ms and update the pts being plotted x = [xvals[0]] y = [yvals[0]] # create a figure and plot the first x, y point at time 0 fig, ax = plt.subplots() pts = ax.plot(x, y, 'o')[0] # loop through the remaining points and update the plot every # 5000ms anim = FuncAnimation(fig=fig, func=update_pts, frames=xy_points, init_func=init_plot, interval=5000, blit=False, repeat=False) plt.show() > On Aug 3, 2019, at 1:04 AM, Partha Sinha wrote: > > I want to plot a list of 10 numbers. I want to plot each point after 5 secs (first point in o sec and 2nd point after 5 sec anf so on) and want to plot them in same graph. > How to do? > Regards > Parth > _______________________________________________ > 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 bruno.pagani at astrophysics.eu Wed Aug 14 10:00:06 2019 From: bruno.pagani at astrophysics.eu (Bruno Pagani) Date: Wed, 14 Aug 2019 16:00:06 +0200 Subject: [Matplotlib-users] Plot In-Reply-To: References: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> Message-ID: <3c6af95c-db5e-af24-5813-b5b35a564e09@astrophysics.eu> I guess adding a call to plt.figure() before each new figure should do it. Eventually plt.close() just before that if you want to close figures instead of keeping them open (but then you might also just be able to clear the current one instead of closing/opening). Le 14/08/2019 ? 06:47, Partha Sinha a ?crit?: > I got the solution as suggested by scott.? > My new problem is: > Lets say I will generate lets? two pairs of 10 random numbers, say x > and y. > When first pair of x and y is generated, it will be plotted. Again > when second set of number is generated, it will appear on the same > graph and not on 2nd graph. > This will continue till 10th pair. > How to do this? > Regards > Parth > > > On 3 Aug 2019 1:17 pm, "Scott Lasley" > wrote: > > This should do what you want.? ?It works in a jupyter notebook but > not in jupyterlab.? It also works as a standalone python script if > you comment out the %matplotlib notebook line. > > Best regards, > Scott > > > > # based on > https://matplotlib.org/gallery/animation/animate_decay.html#sphx-glr-gallery-animation-animate-decay-py > > # but uses a zip iterator for the frames variable in FuncAnimation > instead of the data_gen generator function > # used in the example > > # comment out this line if you are not running this in a jupyter > notebook > %matplotlib notebook > # %matplotlib nbagg > > import numpy as np > from matplotlib import pyplot as plt > from matplotlib.animation import FuncAnimation > > > def init_plot(): > ? ? # if you know the data ranges you can set fixed > ? ? # xlim and ylim limits here, otherwise uncomment > ? ? # the ax.relim and ax.autoscale_view calls in > ? ? # draw_pts to rescale the axes based on the > ? ? # last data point plotted > ? ? ax.set(xlim=[0, 11], ylim=[0, 120]) > ? ? return [] > > > def update_pts(data): > ? ? x.append(data[0]) > ? ? y.append(data[1]) > ? ? pts.set_data(x, y) > #? ? ?ax.relim() > #? ? ?ax.autoscale_view(scaley=True) > ? ? return [pts] > > > # data to plot.? replace with your data values > xvals = np.arange(1, 11) > yvals = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) > > # zip xvals[1:] and yvals[1:] since we are plotting > # xvals[0], yvals[0] at time 0 after we create the figure > xy_points = zip(xvals[1:], yvals[1:]) > > # create x and y lists containing the first point to be plotted. > # update_pts will append the next x and y values from the iterator > xy_points > # to x and y every 5000ms and update the pts being plotted > x = [xvals[0]] > y = [yvals[0]] > > # create a figure and plot the first x, y point at time 0 > fig, ax = plt.subplots() > pts = ax.plot(x, y, 'o')[0] > > # loop through the remaining points and update the plot every > # 5000ms > anim = FuncAnimation(fig=fig, > ? ? ? ? ? ? ? ? ? ? func=update_pts, > ? ? ? ? ? ? ? ? ? ? frames=xy_points, > ? ? ? ? ? ? ? ? ? ? init_func=init_plot, > ? ? ? ? ? ? ? ? ? ? interval=5000, > ? ? ? ? ? ? ? ? ? ? blit=False, > ? ? ? ? ? ? ? ? ? ? repeat=False) > > plt.show() > > > > > On Aug 3, 2019, at 1:04 AM, Partha Sinha > wrote: > > > > I want to plot a list of 10 numbers. I want to plot each point > after 5 secs (first point in o sec and 2nd point after 5 sec anf > so on) and want to plot them in same graph. > > How to do? > > Regards > > Parth > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pnsinha68 at gmail.com Wed Aug 14 12:09:37 2019 From: pnsinha68 at gmail.com (Partha Sinha) Date: Wed, 14 Aug 2019 21:39:37 +0530 Subject: [Matplotlib-users] Plot In-Reply-To: <3c6af95c-db5e-af24-5813-b5b35a564e09@astrophysics.eu> References: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> <3c6af95c-db5e-af24-5813-b5b35a564e09@astrophysics.eu> Message-ID: Can the codes be shared? On Wed, 14 Aug 2019 at 19:30, Bruno Pagani wrote: > I guess adding a call to plt.figure() before each new figure should do it. > Eventually plt.close() just before that if you want to close figures > instead of keeping them open (but then you might also just be able to clear > the current one instead of closing/opening). > > Le 14/08/2019 ? 06:47, Partha Sinha a ?crit : > > I got the solution as suggested by scott. > My new problem is: > Lets say I will generate lets two pairs of 10 random numbers, say x and y. > When first pair of x and y is generated, it will be plotted. Again when > second set of number is generated, it will appear on the same graph and not > on 2nd graph. > This will continue till 10th pair. > How to do this? > Regards > Parth > > > On 3 Aug 2019 1:17 pm, "Scott Lasley" wrote: > > This should do what you want. It works in a jupyter notebook but not in > jupyterlab. It also works as a standalone python script if you comment out > the %matplotlib notebook line. > > Best regards, > Scott > > > > # based on > https://matplotlib.org/gallery/animation/animate_decay.html#sphx-glr-gallery-animation-animate-decay-py > # but uses a zip iterator for the frames variable in FuncAnimation instead > of the data_gen generator function > # used in the example > > # comment out this line if you are not running this in a jupyter notebook > %matplotlib notebook > # %matplotlib nbagg > > import numpy as np > from matplotlib import pyplot as plt > from matplotlib.animation import FuncAnimation > > > def init_plot(): > # if you know the data ranges you can set fixed > # xlim and ylim limits here, otherwise uncomment > # the ax.relim and ax.autoscale_view calls in > # draw_pts to rescale the axes based on the > # last data point plotted > ax.set(xlim=[0, 11], ylim=[0, 120]) > return [] > > > def update_pts(data): > x.append(data[0]) > y.append(data[1]) > pts.set_data(x, y) > # ax.relim() > # ax.autoscale_view(scaley=True) > return [pts] > > > # data to plot. replace with your data values > xvals = np.arange(1, 11) > yvals = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) > > # zip xvals[1:] and yvals[1:] since we are plotting > # xvals[0], yvals[0] at time 0 after we create the figure > xy_points = zip(xvals[1:], yvals[1:]) > > # create x and y lists containing the first point to be plotted. > # update_pts will append the next x and y values from the iterator > xy_points > # to x and y every 5000ms and update the pts being plotted > x = [xvals[0]] > y = [yvals[0]] > > # create a figure and plot the first x, y point at time 0 > fig, ax = plt.subplots() > pts = ax.plot(x, y, 'o')[0] > > # loop through the remaining points and update the plot every > # 5000ms > anim = FuncAnimation(fig=fig, > func=update_pts, > frames=xy_points, > init_func=init_plot, > interval=5000, > blit=False, > repeat=False) > > plt.show() > > > > > On Aug 3, 2019, at 1:04 AM, Partha Sinha wrote: > > > > I want to plot a list of 10 numbers. I want to plot each point after 5 > secs (first point in o sec and 2nd point after 5 sec anf so on) and want to > plot them in same graph. > > How to do? > > Regards > > Parth > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From selasley at icloud.com Wed Aug 14 15:15:51 2019 From: selasley at icloud.com (Scott Lasley) Date: Wed, 14 Aug 2019 15:15:51 -0400 Subject: [Matplotlib-users] Plot In-Reply-To: References: <83E8CF3F-0B33-4F22-9E42-214D4B71F15C@icloud.com> Message-ID: <8FD0C80E-1559-4F6C-92D6-CE3E1D88E41F@icloud.com> Hi Partha, This stackoverflow answer should help you do what you want https://stackoverflow.com/questions/10944621/dynamically-updating-plot-in-matplotlib Here is some similar code. Run the code between the ...'s in a Jupiter notebook cell to create the first empty plot ... # comment out this line if you are not running this in a jupyter notebook %matplotlib notebook import numpy as np from matplotlib import pyplot as plt def update_points(fig, pts, new_data): # get the data for the points in the current plot pts_data = pts.get_data() # update the points using set_data with the # new_data values appended to the current values pts.set_data(np.append(pts_data[0], [new_data[0]]), np.append(pts_data[1], [new_data[1]])) # update the plot fig.canvas.draw_idle() # uncomment the next two lines if you want the plot to # automatically adjust its limits when you add data # ax.relim() # ax.autoscale_view(scaley=True) return # create a figure # if you are running the code in ipython you may need to # call plt.ion() after creating the figure fig, ax = plt.subplots() # set the plot's x and y limits if you know the range # of the data you will generate. otherwise let # update_plot adjust the limits ax.set(xlim=[0,100], ylim=[0,100]) # plot an empty list to create the pts Line2D array # with no data pts = ax.plot([], 'o')[0] ... Then in the next cell(s) call update_points for each new data point to be plotted ... new_data = [10, 10] update_points(fig=fig, pts=pts, new_data=new_data) ... new_data = [20, 40] update_points(fig=fig, pts=pts, new_data=new_data) ... Hope this helps, Scott > On Aug 14, 2019, at 12:47 AM, Partha Sinha wrote: > > I got the solution as suggested by scott. > My new problem is: > Lets say I will generate lets two pairs of 10 random numbers, say x and y. > When first pair of x and y is generated, it will be plotted. Again when second set of number is generated, it will appear on the same graph and not on 2nd graph. > This will continue till 10th pair. > How to do this? > Regards > Parth From ndbecker2 at gmail.com Thu Aug 15 18:43:52 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Thu, 15 Aug 2019 18:43:52 -0400 Subject: [Matplotlib-users] mplcairo multipage pdf and too many figures open Message-ID: I've been using mplcairo multipage pdf. The pattern I use is: from mplcairo.multipage import MultiPage cm = MultiPage(ap_args.output) with cm as pdf: fig,ax = plt.subplots() do something pdf.savefig(fig) fig2,ax2 = plt.subplots() do something pdf.savefig(fig2) ... after 20 figures: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). What is the proper way to use mplcairo.multipage to avoid this issue? Thanks, Neal From antony.lee at institutoptique.fr Fri Aug 16 04:46:13 2019 From: antony.lee at institutoptique.fr (Antony Lee) Date: Fri, 16 Aug 2019 10:46:13 +0200 Subject: [Matplotlib-users] mplcairo multipage pdf and too many figures open In-Reply-To: References: Message-ID: Hi, You can probably either call plt.close(fig) after savefig to close the figure (likely best), or adjust rcParams["figure.max_open_warning"] to a large enough number (at the risk of running out of memory). Antony On Fri, Aug 16, 2019 at 12:44 AM Neal Becker wrote: > I've been using mplcairo multipage pdf. The pattern I use is: > > from mplcairo.multipage import MultiPage > cm = MultiPage(ap_args.output) > > with cm as pdf: > fig,ax = plt.subplots() > do something > pdf.savefig(fig) > > fig2,ax2 = plt.subplots() > do something > pdf.savefig(fig2) > ... > > after 20 figures: > RuntimeWarning: More than 20 figures have been opened. Figures created > through the pyplot interface (`matplotlib.pyplot.figure`) are retained > until > explicitly closed and may consume too much memory. (To control this > warning, > see the rcParam `figure.max_open_warning`). > > What is the proper way to use mplcairo.multipage to avoid this issue? > > Thanks, > Neal > > _______________________________________________ > 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 ndbecker2 at gmail.com Fri Aug 16 07:16:41 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 16 Aug 2019 07:16:41 -0400 Subject: [Matplotlib-users] mplcairo multipage pdf and too many figures open In-Reply-To: References: Message-ID: I recoded as: if pdf: pdf.savefig (fig) and plt.close(fig) And I still get the same warning message. On Fri, Aug 16, 2019 at 4:46 AM Antony Lee wrote: > > Hi, > You can probably either call plt.close(fig) after savefig to close the figure (likely best), or adjust rcParams["figure.max_open_warning"] to a large enough number (at the risk of running out of memory). > Antony > > On Fri, Aug 16, 2019 at 12:44 AM Neal Becker wrote: >> >> I've been using mplcairo multipage pdf. The pattern I use is: >> >> from mplcairo.multipage import MultiPage >> cm = MultiPage(ap_args.output) >> >> with cm as pdf: >> fig,ax = plt.subplots() >> do something >> pdf.savefig(fig) >> >> fig2,ax2 = plt.subplots() >> do something >> pdf.savefig(fig2) >> ... >> >> after 20 figures: >> RuntimeWarning: More than 20 figures have been opened. Figures created >> through the pyplot interface (`matplotlib.pyplot.figure`) are retained until >> explicitly closed and may consume too much memory. (To control this warning, >> see the rcParam `figure.max_open_warning`). >> >> What is the proper way to use mplcairo.multipage to avoid this issue? >> >> Thanks, >> Neal >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users -- Those who don't understand recursion are doomed to repeat it From mobiusklein at gmail.com Fri Aug 16 07:24:53 2019 From: mobiusklein at gmail.com (Joshua Klein) Date: Fri, 16 Aug 2019 07:24:53 -0400 Subject: [Matplotlib-users] mplcairo multipage pdf and too many figures open In-Reply-To: References: Message-ID: `pdf.savefig` returns None (it has no explicit return value), which is a False-y value. This causes the `and` expression to short-circuit and the right-hand-side expression is never evaluated. You'll need to call them separately. On Fri, Aug 16, 2019 at 7:17 AM Neal Becker wrote: > I recoded as: > > if pdf: pdf.savefig (fig) and plt.close(fig) > > And I still get the same warning message. > > On Fri, Aug 16, 2019 at 4:46 AM Antony Lee > wrote: > > > > Hi, > > You can probably either call plt.close(fig) after savefig to close the > figure (likely best), or adjust rcParams["figure.max_open_warning"] to a > large enough number (at the risk of running out of memory). > > Antony > > > > On Fri, Aug 16, 2019 at 12:44 AM Neal Becker > wrote: > >> > >> I've been using mplcairo multipage pdf. The pattern I use is: > >> > >> from mplcairo.multipage import MultiPage > >> cm = MultiPage(ap_args.output) > >> > >> with cm as pdf: > >> fig,ax = plt.subplots() > >> do something > >> pdf.savefig(fig) > >> > >> fig2,ax2 = plt.subplots() > >> do something > >> pdf.savefig(fig2) > >> ... > >> > >> after 20 figures: > >> RuntimeWarning: More than 20 figures have been opened. Figures created > >> through the pyplot interface (`matplotlib.pyplot.figure`) are retained > until > >> explicitly closed and may consume too much memory. (To control this > warning, > >> see the rcParam `figure.max_open_warning`). > >> > >> What is the proper way to use mplcairo.multipage to avoid this issue? > >> > >> Thanks, > >> Neal > >> > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Matplotlib-users at python.org > >> https://mail.python.org/mailman/listinfo/matplotlib-users > > > > -- > Those who don't understand recursion are doomed to repeat it > _______________________________________________ > 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 ndbecker2 at gmail.com Fri Aug 16 07:26:09 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 16 Aug 2019 07:26:09 -0400 Subject: [Matplotlib-users] mplcairo multipage pdf and too many figures open In-Reply-To: References: Message-ID: Thanks! I rarely use this single line form of 'if' and screwed it up. On Fri, Aug 16, 2019 at 7:25 AM Joshua Klein wrote: > > `pdf.savefig` returns None (it has no explicit return value), which is a False-y value. This causes the `and` expression to short-circuit and the right-hand-side expression is never evaluated. You'll need to call them separately. > > On Fri, Aug 16, 2019 at 7:17 AM Neal Becker wrote: >> >> I recoded as: >> >> if pdf: pdf.savefig (fig) and plt.close(fig) >> >> And I still get the same warning message. >> >> On Fri, Aug 16, 2019 at 4:46 AM Antony Lee >> wrote: >> > >> > Hi, >> > You can probably either call plt.close(fig) after savefig to close the figure (likely best), or adjust rcParams["figure.max_open_warning"] to a large enough number (at the risk of running out of memory). >> > Antony >> > >> > On Fri, Aug 16, 2019 at 12:44 AM Neal Becker wrote: >> >> >> >> I've been using mplcairo multipage pdf. The pattern I use is: >> >> >> >> from mplcairo.multipage import MultiPage >> >> cm = MultiPage(ap_args.output) >> >> >> >> with cm as pdf: >> >> fig,ax = plt.subplots() >> >> do something >> >> pdf.savefig(fig) >> >> >> >> fig2,ax2 = plt.subplots() >> >> do something >> >> pdf.savefig(fig2) >> >> ... >> >> >> >> after 20 figures: >> >> RuntimeWarning: More than 20 figures have been opened. Figures created >> >> through the pyplot interface (`matplotlib.pyplot.figure`) are retained until >> >> explicitly closed and may consume too much memory. (To control this warning, >> >> see the rcParam `figure.max_open_warning`). >> >> >> >> What is the proper way to use mplcairo.multipage to avoid this issue? >> >> >> >> Thanks, >> >> Neal >> >> >> >> _______________________________________________ >> >> Matplotlib-users mailing list >> >> Matplotlib-users at python.org >> >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> >> >> -- >> Those who don't understand recursion are doomed to repeat it >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users -- Those who don't understand recursion are doomed to repeat it From mikejs at mbay.net Sun Aug 18 19:07:14 2019 From: mikejs at mbay.net (Mike Sacauskis) Date: Sun, 18 Aug 2019 16:07:14 -0700 Subject: [Matplotlib-users] Date/Time not displaying as expected. Message-ID: <20190818160714.3c9d5d96@raspberrypi> Hi I'm new to Matplotlib, I'm going to be plotting some temperature data over time and wrote a test program to see with Matplotlab can do for me. When I plot the the date the date time does not display as I would expect, the date is output but the time is some type of counter not the time of day as expected. What am I doing wrong? I've attached the code, data and the resulting image. Any help would be greatly appreciated. Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: Temp.py Type: text/x-python Size: 565 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: temps.png Type: image/png Size: 23389 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: temps.csv Type: text/csv Size: 492 bytes Desc: not available URL: From efiring at hawaii.edu Sun Aug 18 22:59:44 2019 From: efiring at hawaii.edu (Eric Firing) Date: Sun, 18 Aug 2019 16:59:44 -1000 Subject: [Matplotlib-users] Date/Time not displaying as expected. In-Reply-To: <20190818160714.3c9d5d96@raspberrypi> References: <20190818160714.3c9d5d96@raspberrypi> Message-ID: Mike, Your plot tick labels are displaying month, day, and hour (the first tick is at the start of August 16, the next is 3 hours later, etc.). This is the default format for an axis of the length in your example. The idea behind the scheme is to provide no more than 3 date time numbers per tick label so as to keep the label from being too long. You can override the default in two ways: by overriding one or more of the formats used by the rather complex AutoDateFormatter (which is designed to work with the default AutoDateLocator), or by specifying the use of your own DateFormatter in which you directly provide the strftime-style format string to use. Method 1: you can change the defaults used by AutoDateFormatter by specifying them in a matplotlibrc file, or by setting them in the rcParams dictionary. In the former case the change must be made before matplotlib is imported; in the latter, it must be before the plot is made. Here are commented-out values from the matplotlibrc template: #date.autoformatter.year : %Y #date.autoformatter.month : %Y-%m #date.autoformatter.day : %Y-%m-%d #date.autoformatter.hour : %m-%d %H #date.autoformatter.minute : %d %H:%M #date.autoformatter.second : %H:%M:%S #date.autoformatter.microsecond : %M:%S.%f In the case of your example the ticks are at intervals of 3 hours, so it is the '.hour' entry that would have to be changed. For example, in your script: plt.rcParams['date.autoformatter.hour'] = '%m-%d %H:%M' If you are plotting with a variety of axis spans, so that ticks are placed at day multiples, or minute multiples, for example, then you would have to use this method to change those corresponding defaults. Method 2: In your script you could add, for example: import matplotlib.dates as mdates ax = plt.gca() formatter = mdates.DateFormatter('%Y-%m-%d %H:%M:%S') ax.xaxis.set_major_formatter(ax.xaxis.set_major_formatter(formatter)) This way you will have the same standard format regardless of the time range spanned by your axis. Also, instead of specifying the tick label rotation yourself, you might want to use plt.gcf().autofmt_xdate() which will place the end of the rotated string just below the tick. Eric On 2019/08/18 1:07 PM, Mike Sacauskis wrote: > Hi > > I'm new to Matplotlib, I'm going to be plotting some temperature data > over time and wrote a test program to see with Matplotlab can do for > me. When I plot the the date the date time does not display as I would > expect, the date is output but the time is some type of counter not the > time of day as expected. What am I doing wrong? I've attached the > code, data and the resulting image. Any help would be greatly > appreciated. > > Mike > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From Nicolas.Rougier at inria.fr Mon Aug 19 05:16:15 2019 From: Nicolas.Rougier at inria.fr (Nicolas Rougier) Date: Mon, 19 Aug 2019 11:16:15 +0200 Subject: [Matplotlib-users] [ANN] "Scientific Visualization - Python & Matplotlib" book project Message-ID: <2959182A-5830-4A2F-9ABF-06DC2AC7E8BD@inria.fr> Dear all, The matplotlib cheat-sheet (https://github.com/rougier/matplotlib-cheatsheet) I posted a few days comes from a book project I?m starting, that is planned to be released (open access) on Summer 2020. You can follow the progress and support the project at: https://github.com/rougier/scientific-visualization-book Everything will be freely available at the end of the project (but the printed book). I hope this is not an inappropriate message for this mailing list. Nicolas Some teaser (made with matplotlib of course). -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: text-shadow.png Type: image/png Size: 54065 bytes Desc: not available URL: From subscription.gjl at icloud.com Wed Aug 21 14:17:59 2019 From: subscription.gjl at icloud.com (JL) Date: Wed, 21 Aug 2019 19:17:59 +0100 Subject: [Matplotlib-users] **Question post from Albert** Message-ID: Dear Matplotlib users, I am a matplotlib user from Leeds, UK. Recently, I struggle with a triangle surface plot (https://matplotlib.org/3.1.0/gallery/mplot3d/trisurf3d.html ) problem in matplotlib. As we know, if you have data x, y, z, you can directly call ax.plot_trisurf(x, y, z). However, the data set I have is only three lists of data and if you direct call so, you will find surface losses in the z axis. In MATLAB, you can add a boundary (K = boundary(X, Y, Z, 1);) and then call the function trisurf(K, X, Y, Z), while I cannot find an suitable way in matplotlib or in Python since I do not want to use MATLAB any more :) The details (including data and some codes) are post as follows, please kindly check, https://stackoverflow.com/questions/57481995/how-to-generate-a-3d-triangle-surface-trisurf-plot-in-python-with-matplotlib . Thanks, Albert -------------- next part -------------- An HTML attachment was scrubbed... URL: From newville at cars.uchicago.edu Thu Aug 29 10:16:50 2019 From: newville at cars.uchicago.edu (Matt Newville) Date: Thu, 29 Aug 2019 09:16:50 -0500 Subject: [Matplotlib-users] wxmplot 0.9.38: interactive plotting with wxPython + matplotlib Message-ID: Hello matplotlib users, wxmplot 0.9.38 is now available and can be installed with `pip install wxmplot`. Docs are at https://newville.github.io/wxmplot/ and code at https://github.com/newville/wxmplot/. I suspect many people here are not aware of this module that combines wxPython and matplotlib. I also think that some of you may find it very useful for making 2D line plots and image displays because the displays created are highly configurable and interactive. With 0.9.38, interactive plotting from the Python command line (that is, from a plain Python terminal or a Jupyter qtconsole, notebook, or Juptyerlab) can be done with: >>> import wxmplot.interactive as wi >>> import numpy as np >>> x = np.linspace(-5, 5, 101) >>> wi.plot(x, np.sin(x), label='sine') At first look, the results are similar to `pyplot.plot()` : a new Plot Window with the 2D Line Plot. From this window, not only can the user zoom in, adjust the margins, and save an image as with the Navigation Toolbar, but they can also change the styling/theming, labels and titles, configure the legend, and so on. They can also change the color, marker, linewidth, label, and style of each trace. With the legend displayed, clicking on a legend label will toggle whether the corresponding trace is displayed. Additional functions such as `wi.plot_text()`, `wi.plot_marker()`, and `wi.plot_axhline()` allow the user to add annotations to the 2D line plot. For image displays, `wi.imshow(image_data)` will display a false-color image of data, similar to `pyplot.imshow(image_data)`, but with widgets, menu items, and keyboard shortcuts to allow the user to rotate, flip, or smooth the image, change color tables and contrast thresholds, display as a contour map, draw a scalebar, and show slices through the image. The `wxmplot.interactive` module does not use a blocking `show()` function - the results are drawn immediately and are interactive, and the shell is not frozen while the plot is displayed. This means that from the Python shell, the user can additional traces to an existing plot, replace the current plot, or draw to a second (or more) separate Plotting or Image Display windows. When run with `python myscript.py`, a script that uses the `wxmplot.interactive` functions will show the displays, and these will persist (and be interactive) until closed. That is, the script will not finish and kill the displays until all displays are closed or until the script is explicitly killed with Ctrl-C. There are some specialty displays available (see examples), but there are many aspects of matplotlib that have no equivalent in wxmplot. Still, I invite anyone interested to try out the basic plotting and image display as I think some of you may find it very useful for exploratory data analysis. Wxmplot 0.9.38 uses and MIT license and supports Python 2.7, 3.5, 3.6, and 3.7, and requires matplotlib 2.0+, wxPython 4.0.2+, numpy, and six. Support for Python 2 will be dropped for the next release. Feedback, suggestions, and improvements are most welcome. Cheers, --Matt Newville -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent.adrien at gmail.com Thu Aug 29 11:58:38 2019 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Thu, 29 Aug 2019 17:58:38 +0200 Subject: [Matplotlib-users] wxmplot 0.9.38: interactive plotting with wxPython + matplotlib In-Reply-To: References: Message-ID: <3fe917b0-f1a1-dbeb-108e-15d29edd306a@gmail.com> Hello Matt, Thanks for the info :). I do not know what core devs may think about the idea but maybe it could be worth opening a ticket (or even a PR ;)!) for adding an entry about wxmplot on the [third-party packages webpage](https://matplotlib.org/thirdpartypackages/index.html). Best, Adrien Le 29/08/2019 ? 16:16, Matt Newville a ?crit?: > Hello matplotlib users, > > wxmplot 0.9.38 is now available and can be installed with `pip install > wxmplot`. ? > Docs are at https://newville.github.io/wxmplot/ and code at > https://github.com/newville/wxmplot/. > > I suspect many people here are not aware of this module that combines > wxPython and matplotlib.? I also think that some of you may find it very > useful for making 2D line plots and image displays because the displays > created are highly configurable and interactive.?? > > With 0.9.38, interactive plotting from the Python command line (that is, > from a plain Python terminal or a Jupyter qtconsole, notebook, or > Juptyerlab) can be done with: > > ? ? >>> import wxmplot.interactive as wi > ? ? >>> import numpy as np > ? ? >>> x = np.linspace(-5, 5, 101) > ? ? >>> wi.plot(x, np.sin(x), label='sine') > > At first look, the results are similar to `pyplot.plot()` : a new Plot > Window with the 2D Line Plot.? From this window, not only can the user > zoom in, adjust the margins, and save an image as with the Navigation > Toolbar, but they can also change the styling/theming, labels and > titles, configure the legend, and so on.? They can also change the > color, marker, linewidth, label, and style of each trace.? With the > legend displayed, clicking on a legend label will toggle whether the > corresponding trace is displayed.? Additional functions such as > `wi.plot_text()`, `wi.plot_marker()`, and `wi.plot_axhline()` allow the > user to add annotations to the 2D line plot. > > For image displays, `wi.imshow(image_data)` will display a false-color > image of data, similar to `pyplot.imshow(image_data)`, but with widgets, > menu items, and keyboard shortcuts to allow the user to rotate, flip, or > smooth the image, change color tables and contrast thresholds, display > as a contour map, draw a scalebar, and show slices through the image. > > The `wxmplot.interactive` module does not use a blocking `show()` > function - the results are drawn immediately and are interactive, and > the shell is not frozen while the plot is displayed.? This means that > from the Python shell, the user can additional traces to an existing > plot, replace the current plot, or draw to a second (or more) separate > Plotting or Image Display windows.? When run with `python myscript.py`, > a script that uses the `wxmplot.interactive` functions will show the > displays, and these will persist (and be interactive) until closed. That > is, the script will not finish and kill the displays until all displays > are closed or until the script is explicitly killed with Ctrl-C. > > There are some specialty displays available (see examples), but there > are many aspects of matplotlib that have no equivalent in wxmplot.? > Still, I invite anyone interested to try out the basic plotting and > image display as I think some of you may find it very useful for > exploratory data analysis. > > Wxmplot 0.9.38 uses and MIT license and supports Python 2.7, 3.5, 3.6, > and 3.7, and requires matplotlib 2.0+, wxPython 4.0.2+, numpy, and six.? > Support for Python 2 will be dropped for the next release.?? > > Feedback, suggestions, and improvements are most welcome. > Cheers, > > --Matt Newville? > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users >