From djpine at gmail.com Thu Jul 6 13:11:46 2017 From: djpine at gmail.com (David J Pine) Date: Thu, 6 Jul 2017 13:11:46 -0400 Subject: [Matplotlib-users] update axis numbers in animation with blitting Message-ID: In the MPL animation example animate_decay.py ( https://matplotlib.org/2.0.2/examples/animation/animate_decay.html), the x-axis numbers update when the plot dynamically rescales the x-axis, but this only works properly with blitting turned off. Is there simple a way to update the x-axis labels when blitting is turned on? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmay31 at gmail.com Thu Jul 6 14:24:58 2017 From: rmay31 at gmail.com (Ryan May) Date: Thu, 6 Jul 2017 12:24:58 -0600 Subject: [Matplotlib-users] update axis numbers in animation with blitting In-Reply-To: References: Message-ID: On Thu, Jul 6, 2017 at 11:11 AM, David J Pine wrote: > In the MPL animation example animate_decay.py ( > https://matplotlib.org/2.0.2/examples/animation/animate_decay.html), the > x-axis numbers update when the plot dynamically rescales the x-axis, but > this only works properly with blitting turned off. Is there simple a way > to update the x-axis labels when blitting is turned on? > David, Not easily, no. More importantly, if you're redrawing tick labels, you're really eliminating the performance boost blitting. Ryan -- Ryan May -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Thu Jul 13 12:55:22 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Thu, 13 Jul 2017 16:55:22 +0000 Subject: [Matplotlib-users] How to autoscale an animation? Message-ID: Hi I am having difficulty autoscaling a subplot in an animation. A snippet of my code is: fig, axarr = plt.subplots(nrows=2, ncols=5, figsize=(12, 6)) sc_dl_layer1 = axarr[0,4].scatter(x_data, y_data, c='r', s=4) def updatePlots(i): sc_dl_layer1.set_offsets(np.c_[i_data_layer_1, q_data_layer_1]) sc_dl_layer1.autoscale() ani = matplotlib.animation.FuncAnimation(fig, updatePlots, frames=None, interval=200, repeat=True) plt.show() This code returns: sc_dl_layer1.autoscale() File "C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\cm.py", line 334, in autoscale raise TypeError('You must first set_array for mappable') TypeError: You must first set_array for mappable How can I fix this please? Best regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Fri Jul 14 02:06:05 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 14 Jul 2017 06:06:05 +0000 Subject: [Matplotlib-users] How to autoscale an animation? In-Reply-To: References: Message-ID: You are calling auto scale on the scatter artist which is trying to scale the data for color mapping the scatter. You want to be calling auto scale on the Axes (in this case I think axarr[0, 4]). Tom On Thu, Jul 13, 2017, 12:40 David Aldrich wrote: > Hi > > > > I am having difficulty autoscaling a subplot in an animation. A snippet > of my code is: > > > > fig, axarr = plt.subplots(nrows=2, ncols=5, figsize=(12, 6)) > > sc_dl_layer1 = axarr[0,4].scatter(x_data, y_data, c='r', s=4) > > > > def updatePlots(i): > > > > sc_dl_layer1.set_offsets(np.c_[i_data_layer_1, > q_data_layer_1]) > > sc_dl_layer1.autoscale() > > > > ani = matplotlib.animation.FuncAnimation(fig, updatePlots, frames=None, > interval=200, repeat=True) > > plt.show() > > > > This code returns: > > > > sc_dl_layer1.autoscale() > > File "C:\Program Files > (x86)\Python36-32\lib\site-packages\matplotlib\cm.py", line 334, in > autoscale > > raise TypeError('You must first set_array for mappable') > > TypeError: You must first set_array for mappable > > > > How can I fix this please? > > > > Best regards > > > > David > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Mon Jul 17 11:39:19 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 17 Jul 2017 15:39:19 +0000 Subject: [Matplotlib-users] Exception with FuncAnimation Message-ID: <0af3dfdb7b70483eac30b7e9325ec18c@EUX13SRV1.EU.NEC.COM> Hi My matplotlib script, that runs on Windows, runs to annimations: anim = [] anim.append( matplotlib.animation.FuncAnimation(fig_ul, updatePlots_ul, frames=None, interval=100, repeat=True) ) anim.append( matplotlib.animation.FuncAnimation(fig_dl, updatePlots_dl, frames=None, interval=100, repeat=True) ) plt.show() # line 476 When I terminate the script by closing one of the figures I get an exception: Traceback (most recent call last): File "tcpClient.py", line 476, in plt.show() File "C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\pyplot.py", line 253, in show return _show(*args, **kw) File "C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\backend_bases.py", line 163, in __call__ manager.show() File "C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 610, in show self.canvas.manager.window.attributes('-topmost', 1) AttributeError: 'NoneType' object has no attribute 'attributes' How could I improve my code to avoid this untidy exception? Best regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfweber at berkeley.edu Thu Jul 20 15:04:12 2017 From: sfweber at berkeley.edu (SOPHIE FRANCES WEBER) Date: Thu, 20 Jul 2017 12:04:12 -0700 Subject: [Matplotlib-users] Error with LateX text rendering in matplotlib Message-ID: Hello, My mac laptop's operating system is OS X El Capitan. I use the PyCharm IDE and obtained python, with matplotlib installed, via Enthought Canopy. I am trying to create plots using LateX text rendering (rc('text',usetex=True)), but I keep getting an error saying "RuntimeError: LaTeX was not able to process the following string: 'lp'" I looked into the most common causes for this, and consequently double checked that my latex installation (with dvipng and ghostscript included) is included in my PATH, and it is; but I still get the error. Here is a minimal example script, taken from the matplotlib documentation site. import numpy as np import matplotlib.pyplot as plt # Example data t = np.arange(0.0, 1.0 + 0.01, 0.01) s = np.cos(4 * np.pi * t) + 2 plt.rc('text', usetex=True) plt.rc('font', family='serif') plt.plot(t, s) plt.xlabel(r'\textbf{time} (s)') plt.ylabel(r'\textit{voltage} (mV)',fontsize=16) plt.title(r"\TeX\ is Number " r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", fontsize=16, color='gray') # Make room for the ridiculously large title. plt.subplots_adjust(top=0.8) plt.show() Any help would be greatly appreciated. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Fri Jul 21 09:33:27 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Fri, 21 Jul 2017 13:33:27 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? Message-ID: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> Hi I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot data received over a network connection. New data arrives 4 times per second. I need to update two figures fig_A and fig_B, each containing 8 subplots. The hardware is a fast i7 laptop. My main execution loop is: plt.draw() while (True): fig_A.canvas.flush_events() fig_B.canvas.flush_events() updatePlots() # Polls socket for data and updates scatter collections fig_A.canvas.draw_idle() fig_B.canvas.draw_idle() plt.waitforbuttonpress() I have timed the code and found that the first flush_events() call in the loop takes 350ms. The second flush_events() call takes <1ms. 350ms seems very long and is restricting the update rate. Why might flush_events() be taking so long? (I have not changed the backend from the default, which I believe is TkAgg). Best regards David From jks at iki.fi Sat Jul 22 13:02:55 2017 From: jks at iki.fi (=?iso-8859-1?Q?Jouni_K=2E_Sepp=E4nen?=) Date: Sat, 22 Jul 2017 20:02:55 +0300 Subject: [Matplotlib-users] Error with LateX text rendering in matplotlib References: Message-ID: SOPHIE FRANCES WEBER writes: > Here is a minimal example script, taken from the matplotlib documentation > site. I suggest running your minimal test case with the --verbose-debug flag, and seeing if there is any clue in the messages that appear before the RuntimeError. In other words, try python testcase.py --verbose-debug to enable debugging output. -- Jouni K. Sepp?nen http://www.iki.fi/jks From mailinglists at xgm.de Mon Jul 24 01:35:51 2017 From: mailinglists at xgm.de (Florian Lindner) Date: Mon, 24 Jul 2017 13:35:51 +0800 Subject: [Matplotlib-users] Changing style after unpickle Message-ID: <7819a585-f0ae-6c5e-bace-4f21aa90f5e0@xgm.de> Hello, I can happily pickle plot objects: ax = plt.subplot(111) x = np.linspace(0, 10) y = np.exp(x) plt.plot(x, y) pickle.dump(ax, open('myplot.pickle', 'wb')) and unpickle them: ax = pickle.load(open('myplot.pickle', 'rb')) plt.savefig('pickerestore.pdf') My main use case for that is (should be) changing the style of the plots after creation. I have an appropriate function: def set_save_fig_params(fig_width_pt = 418.25555): """ From: http://scipy-cookbook.readthedocs.io/items/Matplotlib_LaTeX_Examples.html """ matplotlib.style.use('seaborn') inches_per_pt = 1.0 / 72.0 # Convert pt to inches golden_mean = (math.sqrt(5)-1.0) / 2.0 # Aesthetic ratio fig_width = fig_width_pt * inches_per_pt # width in inches fig_height = fig_width * golden_mean # height in inches fig_size = [fig_width, fig_height] params = {'backend': 'pdf', 'axes.labelsize': 8, 'font.size': 10, 'legend.fontsize': 7, 'xtick.labelsize': 8, 'ytick.labelsize': 8, 'text.usetex': True, 'figure.figsize': fig_size, "pgf.rcfonts" : False} plt.rcParams.update(params) However, calling this function after or before (or both) unpickling has no effect on the saved plot. The default style is still used. How can I change/update the style of unpickled objects? Thanks, Florian From ben.v.root at gmail.com Tue Jul 25 10:46:13 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 25 Jul 2017 10:46:13 -0400 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> Message-ID: When you say first and second flush_events(), do you mean the first and second iterations, or fig_A and fig_B? Ben Root On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich wrote: > Hi > > I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot > data received over a network connection. New data arrives 4 times per > second. I need to update two figures fig_A and fig_B, each containing 8 > subplots. The hardware is a fast i7 laptop. > > My main execution loop is: > > plt.draw() > > while (True): > fig_A.canvas.flush_events() > fig_B.canvas.flush_events() > updatePlots() # Polls socket for data and > updates scatter collections > fig_A.canvas.draw_idle() > fig_B.canvas.draw_idle() > > plt.waitforbuttonpress() > > I have timed the code and found that the first flush_events() call in the > loop takes 350ms. The second flush_events() call takes <1ms. > 350ms seems very long and is restricting the update rate. > > Why might flush_events() be taking so long? > > (I have not changed the backend from the default, which I believe is > TkAgg). > > Best regards > > David > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Tue Jul 25 10:49:37 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Tue, 25 Jul 2017 14:49:37 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> Message-ID: <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> Hi Ben >When you say first and second flush_events(), do you mean the >first and second iterations, or fig_A and fig_B? The latter: fig_A.canvas.flush_events() <-- 350ms fig_B.canvas.flush_events() <-- 1ms These timings repeat on each iteration. Best regards David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 25 July 2017 15:46 To: David Aldrich Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? When you say first and second flush_events(), do you mean the first and second iterations, or fig_A and fig_B? Ben Root On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich > wrote: Hi I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot data received over a network connection. New data arrives 4 times per second. I need to update two figures fig_A and fig_B, each containing 8 subplots. The hardware is a fast i7 laptop. My main execution loop is: plt.draw() while (True): fig_A.canvas.flush_events() fig_B.canvas.flush_events() updatePlots() # Polls socket for data and updates scatter collections fig_A.canvas.draw_idle() fig_B.canvas.draw_idle() plt.waitforbuttonpress() I have timed the code and found that the first flush_events() call in the loop takes 350ms. The second flush_events() call takes <1ms. 350ms seems very long and is restricting the update rate. Why might flush_events() be taking so long? (I have not changed the backend from the default, which I believe is TkAgg). Best regards David _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users Click here to report this email as spam. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfweber at berkeley.edu Tue Jul 25 12:59:29 2017 From: sfweber at berkeley.edu (SOPHIE FRANCES WEBER) Date: Tue, 25 Jul 2017 09:59:29 -0700 Subject: [Matplotlib-users] Error with LateX text rendering in matplotlib In-Reply-To: References: Message-ID: Hello, Thank you for your response. Sorry, this is probably a trivial question, but I'm not sure how to run the --verbose-debug option; I use the pycharm IDE and thus don't have access to the normal python terminal. Is there a workaround to this? On Sat, Jul 22, 2017 at 10:02 AM, Jouni K. Sepp?nen wrote: > SOPHIE FRANCES WEBER writes: > > > Here is a minimal example script, taken from the matplotlib documentation > > site. > > I suggest running your minimal test case with the --verbose-debug flag, > and seeing if there is any clue in the messages that appear before the > RuntimeError. > > In other words, try > > python testcase.py --verbose-debug > > to enable debugging output. > > -- > Jouni K. Sepp?nen > http://www.iki.fi/jks > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Jul 31 08:53:06 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 31 Jul 2017 12:53:06 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> Message-ID: Exactly what `flush_events` is doing depends on the backend, however I suspect that in most cases the events are handled in a process-level singleton so both calls are talking to event queue so the first one does all the work and the second one finds and empty queue, declares victory and returns. To test this switch the A/B order, I expect the first one to be slow in either case. As to why it is going slow, I suspect it is the text on your 16 axes. To get the speed you want you are probably are going to want to use 'blitting' which is a way of only re-drawing what has changed (rather than everything). See https://matplotlib.org/api/animation_api.html#funcanimation for more details. Tom On Tue, Jul 25, 2017 at 11:26 AM David Aldrich wrote: > Hi Ben > > > > >When you say first and second flush_events(), do you mean the > > >first and second iterations, or fig_A and fig_B? > > > > The latter: > > > > fig_A.canvas.flush_events() ? 350ms > fig_B.canvas.flush_events() ? 1ms > > > > These timings repeat on each iteration. > > > > Best regards > > > > David > > > > *From:* Benjamin Root [mailto:ben.v.root at gmail.com] > *Sent:* 25 July 2017 15:46 > *To:* David Aldrich > *Cc:* matplotlib-users at python.org > *Subject:* Re: [Matplotlib-users] Why is flush_events() taking longer > than expected? > > > > When you say first and second flush_events(), do you mean the first and > second iterations, or fig_A and fig_B? > > Ben Root > > > > On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich > wrote: > > Hi > > I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot > data received over a network connection. New data arrives 4 times per > second. I need to update two figures fig_A and fig_B, each containing 8 > subplots. The hardware is a fast i7 laptop. > > My main execution loop is: > > plt.draw() > > while (True): > fig_A.canvas.flush_events() > fig_B.canvas.flush_events() > updatePlots() # Polls socket for data and > updates scatter collections > fig_A.canvas.draw_idle() > fig_B.canvas.draw_idle() > > plt.waitforbuttonpress() > > I have timed the code and found that the first flush_events() call in the > loop takes 350ms. The second flush_events() call takes <1ms. > 350ms seems very long and is restricting the update rate. > > Why might flush_events() be taking so long? > > (I have not changed the backend from the default, which I believe is > TkAgg). > > Best regards > > David > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > > Click here > > to report this email as spam. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Jul 31 09:05:54 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 31 Jul 2017 13:05:54 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: <862438a7fa4d4d819aadd11e6a681056@EUX13SRV1.EU.NEC.COM> References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> <862438a7fa4d4d819aadd11e6a681056@EUX13SRV1.EU.NEC.COM> Message-ID: We have made an effort recently to make drawing as lazy as possible and not actually do the rendering until it as absolutely required. Ideally delayed off until the GUI needs the pixel values for the paint event. This lets you do many `art.update(...); fig.canvas.draw_idle()` and only pay the draw cost once when you need to show it on the screen (rather than on every update). Tom On Mon, Jul 31, 2017 at 9:00 AM David Aldrich wrote: > Hi Thomas > > > > Thanks for your reply. > > > > > To test this switch the A/B order, I expect the first one to be slow in > either case. > > > > Yes, I tried that and the first one is always slower, as you suggested. > > > > > To get the speed you want you are probably are going to want to use > 'blitting' > > > which is a way of only re-drawing what has changed (rather than > everything). > > > > I understand. However, I expected the redraw work to be done in the > plotting calls, not in `flush_events`. Do you think drawing may be done in > `flush_events`? > > > > Best regards > > > > David > > > > *From:* Thomas Caswell [mailto:tcaswell at gmail.com] > *Sent:* 31 July 2017 13:53 > *To:* David Aldrich ; Benjamin Root < > ben.v.root at gmail.com> > > > *Cc:* matplotlib-users at python.org > *Subject:* Re: [Matplotlib-users] Why is flush_events() taking longer > than expected? > > > > Exactly what `flush_events` is doing depends on the backend, however I > suspect that in most cases the events are handled in a process-level > singleton so both calls are talking to event queue so the first one does > all the work and the second one finds and empty queue, declares victory and > returns. To test this switch the A/B order, I expect the first one to be > slow in either case. > > > > As to why it is going slow, I suspect it is the text on your 16 axes. To > get the speed you want you are probably are going to want to use 'blitting' > which is a way of only re-drawing what has changed (rather than > everything). See > https://matplotlib.org/api/animation_api.html#funcanimation for more > details. > > > > Tom > > > > On Tue, Jul 25, 2017 at 11:26 AM David Aldrich > wrote: > > Hi Ben > > > > >When you say first and second flush_events(), do you mean the > > >first and second iterations, or fig_A and fig_B? > > > > The latter: > > > > fig_A.canvas.flush_events() ? 350ms > fig_B.canvas.flush_events() ? 1ms > > > > These timings repeat on each iteration. > > > > Best regards > > > > David > > > > *From:* Benjamin Root [mailto:ben.v.root at gmail.com] > *Sent:* 25 July 2017 15:46 > *To:* David Aldrich > *Cc:* matplotlib-users at python.org > *Subject:* Re: [Matplotlib-users] Why is flush_events() taking longer > than expected? > > > > When you say first and second flush_events(), do you mean the first and > second iterations, or fig_A and fig_B? > > Ben Root > > > > On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich > wrote: > > Hi > > I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot > data received over a network connection. New data arrives 4 times per > second. I need to update two figures fig_A and fig_B, each containing 8 > subplots. The hardware is a fast i7 laptop. > > My main execution loop is: > > plt.draw() > > while (True): > fig_A.canvas.flush_events() > fig_B.canvas.flush_events() > updatePlots() # Polls socket for data and > updates scatter collections > fig_A.canvas.draw_idle() > fig_B.canvas.draw_idle() > > plt.waitforbuttonpress() > > I have timed the code and found that the first flush_events() call in the > loop takes 350ms. The second flush_events() call takes <1ms. > 350ms seems very long and is restricting the update rate. > > Why might flush_events() be taking so long? > > (I have not changed the backend from the default, which I believe is > TkAgg). > > Best regards > > David > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > > > Click here > > to report this email as spam. > > _______________________________________________ > 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 David.Aldrich at EMEA.NEC.COM Mon Jul 31 09:07:36 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 31 Jul 2017 13:07:36 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> <862438a7fa4d4d819aadd11e6a681056@EUX13SRV1.EU.NEC.COM> Message-ID: <1f23cbd2ef374622b9e31dd8741e78e3@EUX13SRV1.EU.NEC.COM> Thanks, I understand. David From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: 31 July 2017 14:06 To: David Aldrich ; Benjamin Root Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? We have made an effort recently to make drawing as lazy as possible and not actually do the rendering until it as absolutely required. Ideally delayed off until the GUI needs the pixel values for the paint event. This lets you do many `art.update(...); fig.canvas.draw_idle()` and only pay the draw cost once when you need to show it on the screen (rather than on every update). Tom On Mon, Jul 31, 2017 at 9:00 AM David Aldrich > wrote: Hi Thomas Thanks for your reply. > To test this switch the A/B order, I expect the first one to be slow in either case. Yes, I tried that and the first one is always slower, as you suggested. > To get the speed you want you are probably are going to want to use 'blitting' > which is a way of only re-drawing what has changed (rather than everything). I understand. However, I expected the redraw work to be done in the plotting calls, not in `flush_events`. Do you think drawing may be done in `flush_events`? Best regards David From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: 31 July 2017 13:53 To: David Aldrich >; Benjamin Root > Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? Exactly what `flush_events` is doing depends on the backend, however I suspect that in most cases the events are handled in a process-level singleton so both calls are talking to event queue so the first one does all the work and the second one finds and empty queue, declares victory and returns. To test this switch the A/B order, I expect the first one to be slow in either case. As to why it is going slow, I suspect it is the text on your 16 axes. To get the speed you want you are probably are going to want to use 'blitting' which is a way of only re-drawing what has changed (rather than everything). See https://matplotlib.org/api/animation_api.html#funcanimation for more details. Tom On Tue, Jul 25, 2017 at 11:26 AM David Aldrich > wrote: Hi Ben >When you say first and second flush_events(), do you mean the >first and second iterations, or fig_A and fig_B? The latter: fig_A.canvas.flush_events() <-- 350ms fig_B.canvas.flush_events() <-- 1ms These timings repeat on each iteration. Best regards David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 25 July 2017 15:46 To: David Aldrich > Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? When you say first and second flush_events(), do you mean the first and second iterations, or fig_A and fig_B? Ben Root On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich > wrote: Hi I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot data received over a network connection. New data arrives 4 times per second. I need to update two figures fig_A and fig_B, each containing 8 subplots. The hardware is a fast i7 laptop. My main execution loop is: plt.draw() while (True): fig_A.canvas.flush_events() fig_B.canvas.flush_events() updatePlots() # Polls socket for data and updates scatter collections fig_A.canvas.draw_idle() fig_B.canvas.draw_idle() plt.waitforbuttonpress() I have timed the code and found that the first flush_events() call in the loop takes 350ms. The second flush_events() call takes <1ms. 350ms seems very long and is restricting the update rate. Why might flush_events() be taking so long? (I have not changed the backend from the default, which I believe is TkAgg). Best regards David _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users Click here to report this email as spam. _______________________________________________ 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 David.Aldrich at EMEA.NEC.COM Mon Jul 31 09:00:05 2017 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Mon, 31 Jul 2017 13:00:05 +0000 Subject: [Matplotlib-users] Why is flush_events() taking longer than expected? In-Reply-To: References: <57b905001eaa49a5b8875ed53f8c06ea@EUX13SRV1.EU.NEC.COM> <47c9aee58698434cae35831103fb8e41@EUX13SRV1.EU.NEC.COM> Message-ID: <862438a7fa4d4d819aadd11e6a681056@EUX13SRV1.EU.NEC.COM> Hi Thomas Thanks for your reply. > To test this switch the A/B order, I expect the first one to be slow in either case. Yes, I tried that and the first one is always slower, as you suggested. > To get the speed you want you are probably are going to want to use 'blitting' > which is a way of only re-drawing what has changed (rather than everything). I understand. However, I expected the redraw work to be done in the plotting calls, not in `flush_events`. Do you think drawing may be done in `flush_events`? Best regards David From: Thomas Caswell [mailto:tcaswell at gmail.com] Sent: 31 July 2017 13:53 To: David Aldrich ; Benjamin Root Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? Exactly what `flush_events` is doing depends on the backend, however I suspect that in most cases the events are handled in a process-level singleton so both calls are talking to event queue so the first one does all the work and the second one finds and empty queue, declares victory and returns. To test this switch the A/B order, I expect the first one to be slow in either case. As to why it is going slow, I suspect it is the text on your 16 axes. To get the speed you want you are probably are going to want to use 'blitting' which is a way of only re-drawing what has changed (rather than everything). See https://matplotlib.org/api/animation_api.html#funcanimation for more details. Tom On Tue, Jul 25, 2017 at 11:26 AM David Aldrich > wrote: Hi Ben >When you say first and second flush_events(), do you mean the >first and second iterations, or fig_A and fig_B? The latter: fig_A.canvas.flush_events() <-- 350ms fig_B.canvas.flush_events() <-- 1ms These timings repeat on each iteration. Best regards David From: Benjamin Root [mailto:ben.v.root at gmail.com] Sent: 25 July 2017 15:46 To: David Aldrich > Cc: matplotlib-users at python.org Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected? When you say first and second flush_events(), do you mean the first and second iterations, or fig_A and fig_B? Ben Root On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich > wrote: Hi I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot data received over a network connection. New data arrives 4 times per second. I need to update two figures fig_A and fig_B, each containing 8 subplots. The hardware is a fast i7 laptop. My main execution loop is: plt.draw() while (True): fig_A.canvas.flush_events() fig_B.canvas.flush_events() updatePlots() # Polls socket for data and updates scatter collections fig_A.canvas.draw_idle() fig_B.canvas.draw_idle() plt.waitforbuttonpress() I have timed the code and found that the first flush_events() call in the loop takes 350ms. The second flush_events() call takes <1ms. 350ms seems very long and is restricting the update rate. Why might flush_events() be taking so long? (I have not changed the backend from the default, which I believe is TkAgg). Best regards David _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users Click here to report this email as spam. _______________________________________________ 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 szymonzaczek at gmail.com Sat Jul 1 17:36:40 2017 From: szymonzaczek at gmail.com (szymonzaczek) Date: Sat, 01 Jul 2017 21:36:40 -0000 Subject: [Matplotlib-users] Contour plot issue Message-ID: <1498944998170-48075.post@n5.nabble.com> Hey guys. I am totally new to python programming and utilizing a matplot library. I would like to create a contour plot using matplot or seaborn library that would resemble this one made in Origin: AM1_2D_PMF1.tif basing on the file: pmf.xlsx . To be frank, I do not have a clue how to address it, so any help will be appreciated. I know how to make scatterplots and histograms in python, however contourplots have utterly defeated me. Therefore I ask for any assisstance. Kind regards, Szymon Zaczek -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Contour-plot-issue-tp48075.html Sent from the matplotlib - users mailing list archive at Nabble.com. From szymonzaczek at gmail.com Sat Jul 1 17:44:41 2017 From: szymonzaczek at gmail.com (szymonzaczek) Date: Sat, 01 Jul 2017 21:44:41 -0000 Subject: [Matplotlib-users] Contourplots Message-ID: <1498945480679-48076.post@n5.nabble.com> Hey guys, I want to create a contour plot using Python and most likely matplot library that would somehow resemble this one made in Origin: pmf.tif basing on this excel sheet: pmf.xlsx . I am new to Python. I know some of the basics, I am capable of creating histograms and scatterplots, though contourplots have utterly defeated me so far. Therefore, any kind of assistance would be much appreciated. How would you, experienced users, address this issue? Kind regards, Szymon Zaczek -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Contourplots-tp48076.html Sent from the matplotlib - users mailing list archive at Nabble.com. From sbuechele at albany.edu Mon Jul 10 15:26:58 2017 From: sbuechele at albany.edu (vaultron94) Date: Mon, 10 Jul 2017 19:26:58 -0000 Subject: [Matplotlib-users] Plotting dates on the y-axis of a contour map/ hovmoller Message-ID: <1499714810715-48081.post@n5.nabble.com> Hello all, So I ran into a snare when making a Hovmoller for a case study. I have everything done and colors picked out. But for the life of me cannot find a way to get the Y-axis to plot the dates provided in the data. Here is the script I have. import numpy as np import datetime import matplotlib.pyplot as plt import os import pandas as pd def cmap(cmap): cmap = plt.cm.get_cmap(cmap) data = pd.read_excel('/Users/operator/Documents/Hovmoller_dewpt.xlsx') a=np.array(data) time= (a[:,0]) lat= (a[:,1]) lon= (a[:,2]) BATA= (a[:,3]) BSPA= (a[:,4]) BUFF= (a[:,5]) CLIF= (a[:,6]) FAYE= (a[:,7]) HERK= (a[:,8]) JOHN= (a[:,9]) JORD= (a[:,10]) OPPE= (a[:,11]) WEST= (a[:,12]) timeZ= (a[:,13]) b=np.vstack((BUFF,BATA,CLIF,JORD,FAYE,WEST,HERK,OPPE,JOHN,BSPA)).T plt.contourf(b, np.arange(40,67), cmap=('jet')) plt.xlabel('BUFF BATA CLIF JORD FAYE WEST HERK OPPE JOHN BSPA') plt.ylabel('Time') plt.grid('off') plt.colorbar() plt.title('Dewpoint Hovmoller for Mesonet Sites') plt.figure() #timeZ contains the dates I want, and instead of having the number of rows as the y axis I want the dates there instead. Attached is the graphic I get as of now. Any thoughts or advice is much appreciated! Thank you -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Plotting-dates-on-the-y-axis-of-a-contour-map-hovmoller-tp48081.html Sent from the matplotlib - users mailing list archive at Nabble.com. From eric.emsellem at eso.org Wed Jul 12 11:22:15 2017 From: eric.emsellem at eso.org (rese) Date: Wed, 12 Jul 2017 15:22:15 -0000 Subject: [Matplotlib-users] Creating custom markers as the union of complex vertices Message-ID: <1499872934846-48083.post@n5.nabble.com> Hi I have been looking for an elegant/simple (working!) solution to create new complex markers for matplotlib. For example, I would like to design a new marker which is the union of a set of vertices, for example (just an example), two petals which are symmetric (see verts1 and verts2) and two lines above and below (see verts3, and verts4). I would also like to have the petal possibly filled (or not) and the edgecolor of each vertices with possibly various colours (one petal is blue, the other is orange). How should I proceed? A naive way forward is to do something like (for a double petal, the left one not being filled up, the right one being filled, see the definition for verts1, verts2, verts3, verts4 below): ## Code x = rand(10) y = rand(10) verts = [verts1, verts2, verts3, verts4] fc = ['k', 'None', 'None', 'None'] ec = ['b', 'orange', 'k', 'k'] for lverts, lfc, lec in list(zip(verts, fc, ec)) : scatter(x, y, marker= (lverts, 0), facecolor=lfc, edgecolor=lec, s=1000, label='My symbol') ==> HOWEVER, since these are done in a for loop, it is not considered as a single marker when I do, for example, : legend(loc=0) QUESTION: how should I manage this? (couldn't find the answer on the net) Suggestion are most welcome! Thanks! Eric ====================================== ###### Definition for the vertices if 1: # verts1: size, angrad = 10., 0. rx = 4. * size theta = np.linspace(-pi / 4., pi / 4., 151) x = rx*np.sqrt(cos(2.*theta))*cos(theta) y = rx*np.sqrt(cos(2.*theta))*sin(theta) rotx = x * cos(angrad) + y * sin(angrad) roty = -x * sin(angrad) + y * cos(angrad) verts1 = list(zip(rotx,roty)) # verts2: size, angrad = 10., np.pi rx = 4. * size theta = np.linspace(-pi / 4., pi / 4., 151) x = rx*np.sqrt(cos(2.*theta))*cos(theta) y = rx*np.sqrt(cos(2.*theta))*sin(theta) rotx = x * cos(angrad) + y * sin(angrad) roty = -x * sin(angrad) + y * cos(angrad) verts2 = list(zip(rotx,roty)) # verts3 verts3 = list(zip([0.,0.],[0,0.1])) # verts4 verts4 = list(zip([0.,0.],[-0.1,-0.03])) -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Creating-custom-markers-as-the-union-of-complex-vertices-tp48083.html Sent from the matplotlib - users mailing list archive at Nabble.com. From mihnea.saracin at rinftech.com Thu Jul 13 06:16:06 2017 From: mihnea.saracin at rinftech.com (Mihnea Saracin) Date: Thu, 13 Jul 2017 10:16:06 -0000 Subject: [Matplotlib-users] Building matplotlib on PyPy Message-ID: Hello everyone, I have recently managed to make Matplotlib work with PyPy 5.8.0 through CFFI bindings. I posted a step by step tutorial for this if anyone is interested: https://pythonfiles.wordpress.com/2017/06/28/making-matplotlib-work-with-pypy/ Best regards, Mihnea -------------- next part -------------- An HTML attachment was scrubbed... URL: From christopher.s.barnes at gmail.com Thu Jul 13 08:48:00 2017 From: christopher.s.barnes at gmail.com (Chris Barnes) Date: Thu, 13 Jul 2017 12:48:00 -0000 Subject: [Matplotlib-users] showcase example code: bachelors_degrees_by_gender.py Inbox x Message-ID: Good morning- I came across you data linked on Reddit this morning, and found it fascinating. I'm a high school history teacher, and "college" and "degrees" is very important and relevant to my classroom studies. Any chance you have any data similar to the one above...but only for men? Just thought I'd ask. Thanks! -Chris Barnes -------------- next part -------------- An HTML attachment was scrubbed... URL: From strozzi2 at llnl.gov Sat Jul 15 21:39:11 2017 From: strozzi2 at llnl.gov (Strozzi, David J.) Date: Sun, 16 Jul 2017 01:39:11 -0000 Subject: [Matplotlib-users] Windows7: figure window "not responding" Message-ID: This problem has been driving me nuts, posted it elsewhere, so far no one's been able to help. I am running Python 3.6.1 from Anaconda (all packages updated to latest and greatest) on Windows 7. ipython and mpl figure windows work fine from a console, or spyder. The problem is when I try running ipython within emacs using elpy. To back up, the workflow I'm shooting for is using emacs as my IDE, and running python within emacs. I've done this for many years with the Yorick interpreter, and it's quite addictive. I get the same problem whether I use the GNU windows build of emacs, or emacs -nw (terminal, no X) from cygwin (ver 25.2 both cases). elpy seems to be a good Python package for emacs, and nominally supports using ipython. OK, so - I can use ipython + emacs + elpy. The only problem is matplotlib figures. When I do figure(), a figure window appears, but is not fully rendered (e.g. no buttons), and the window title says "Not responding". If I do a plot(), nothing is plotted. Playing with ion() and show() doesn't help. I've posted this on the elpy github, various stackexchange forums, no one has had any ideas yet. Any help is greatly appreciated! Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: From aaq219 at nyu.edu Mon Jul 17 02:30:09 2017 From: aaq219 at nyu.edu (Ahlam Al Qasim) Date: Mon, 17 Jul 2017 06:30:09 -0000 Subject: [Matplotlib-users] GEOS installation for Basemap package Message-ID: To whom it may concern, I hope this email finds you well. I am trying to get the Basemap package on my mac, and have been following the instructions based on this webpage: https://matplotlib.org/basemap/users/installing.html. I don't have GEOS already installed so I tried following steps on the website to download it with Basemap: cd geos-3.3.3 export GEOS_DIR= # A reasonable choice on a Unix-like system is /usr/local, or # if you don't have permission to write there, your home directory. ./configure --prefix=$GEOS_DIR make; make install However, I am getting errors at the third step (make; make install). Attached is a copy of what I get on my python console, if it helps. I think the error occurs when trying to create the /include directory, but I'm not sure how to fix it. I'm still new to python so any help would be much appreciated! Best regards, Ahlam Al Qasim -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: python console.rtf Type: application/rtf Size: 7188 bytes Desc: not available URL: From danjames95 at live.co.uk Wed Jul 19 10:31:51 2017 From: danjames95 at live.co.uk (danjames95) Date: Wed, 19 Jul 2017 14:31:51 -0000 Subject: [Matplotlib-users] Single Colorbar for multiple subplots Message-ID: <1500474709725-48091.post@n5.nabble.com> Hi, I am trying to plot 4 subplots in a 2 by 2 grid for mean sea level pressure data over the four seasons. I have managed to plot all four in the same figure with their own individual colorbars, however, I would ideally like the figure to display one colorbar at the bottom to represent all four figures and I have been unsuccessful in doing this so far. There have been a few posts on this but as this is my first assignment (i'm a student at university) with python, I'm struggling to understand the answers! The section of my code which involves the plotting of data is as follows: ... #Select Projection lon_0= 0 lat_0=lats.mean() m = Basemap(projection = 'cyl', lat_0=lat_0, lon_0=lon_0, resolution = 'l') #Convert Lons and Lats x,y = np.meshgrid (lons_shifted,lats) xx,yy= m(x,y) v = np.linspace(980, 1030, 11, endpoint=True) fig = plt.figure() plt.subplot(2, 2, 1) set1 = m.contourf(xx,yy,MSLP_WINTER, v) m.drawmapboundary() m.drawcoastlines() plt.title('Winter') bar = plt.colorbar(orientation = 'horizontal', ticks = v, format = '%.0f') plt.xlim(-80,20) plt.ylim (20,70) plt.subplot(2, 2, 2) set2 = m.contourf(xx,yy,MSLP_SPRING, v) m.drawmapboundary() m.drawcoastlines() plt.title('Spring') bar = plt.colorbar(orientation = 'horizontal', ticks = v) plt.xlim(-80,20) plt.ylim (20,70) plt.subplot(2, 2, 3) set3 = m.contourf(xx,yy,MSLP_SUMMER, v) m.drawmapboundary() m.drawcoastlines() plt.title('Summer') bar = plt.colorbar(orientation = 'horizontal', ticks = v) plt.xlim(-80,20) plt.ylim (20,70) plt.subplot(2, 2, 4) set4 = m.contourf(xx,yy,MSLP_AUTUMN, v) m.drawmapboundary() m.drawcoastlines() plt.title('Autumn') bar = plt.colorbar(orientation = 'horizontal', ticks = v) plt.xlim(-80,20) plt.ylim (20,70) plt.suptitle("Seasonally Averaged Mean Sea Level Pressure between 2006 to 2016") plt.show() This creates the following image: Any help would be very much appreciated. Also, if there any obvious bad habits within this code, please feel free to point them out! Thanks, Dan -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Single-Colorbar-for-multiple-subplots-tp48091.html Sent from the matplotlib - users mailing list archive at Nabble.com. From cdpnepal594 at gmail.com Thu Jul 27 12:08:18 2017 From: cdpnepal594 at gmail.com (cdpnepal) Date: Thu, 27 Jul 2017 09:08:18 -0700 (MST) Subject: [Matplotlib-users] 3D sphere plot from (N,N,N) array Message-ID: <1501171698702-48102.post@n5.nabble.com> Dear All, I have an array of shape (N,N,N) of intensity values. How can I plot those intensity values in form of sphere. Can I show a cut of quadrant of that sphere, so that I can visualize intensity not only on the surface but also inside the sphere. Thanks -- View this message in context: http://matplotlib.1069221.n5.nabble.com/3D-sphere-plot-from-N-N-N-array-tp48102.html Sent from the matplotlib - users mailing list archive at Nabble.com. From cdpnepal594 at gmail.com Thu Jul 27 12:15:47 2017 From: cdpnepal594 at gmail.com (cdpnepal) Date: Thu, 27 Jul 2017 09:15:47 -0700 (MST) Subject: [Matplotlib-users] Plot of array of shape (N, N, N) in form of sphere Message-ID: <1501172147860-48103.post@n5.nabble.com> Dear All, I have an array of shape (N,N,N) of intensity values. How can I plot those intensity values in form of sphere. Can I show a cut of quadrant of that sphere, so that I can visualize intensity not only on the surface but also inside the sphere. Thanks -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Plot-of-array-of-shape-N-N-N-in-form-of-sphere-tp48103.html Sent from the matplotlib - users mailing list archive at Nabble.com.