From tcaswell at gmail.com Sat Sep 2 00:34:21 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 02 Sep 2017 04:34:21 +0000 Subject: [Matplotlib-users] [ANN]: Matplotlib 2.1.0rc1 Message-ID: Folks, We are happy to announce 2.1.0rc1! Wheels and and source on pypi and as a conda package via conda-forge. Please try it out and report any issues! See http://matplotlib.org/devdocs/users/whats_new.html for a draft of the release notes. This represents ~2 years of work and includes many new features and bug fixes. Please checkout our updated documentation ( http://matplotlib.org/devdocs/index.html), particularly the examples ( http://matplotlib.org/devdocs/gallery/index.html ) and tutorials ( http://matplotlib.org/devdocs/tutorials/index.html) . Re-organizing, updating, and migrating the examples to sphinx-gallery was a huge effort led by Nelle Varoquaux and Chris Holdgraf. A big thanks to the many (~280) people who contributed to this release. Installation instructions (via pip into existing venv): pip install --upgrade --pre matplotlib or (via conda into a new venv) conda create -n mpl_rc matplotlib ipython -c conda-forge/label/rc -c conda-forge or(via conda into an existing venv) conda install -c conda-forge/label/rc matplotlib -c conda-forge Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From short.chrisd at gmail.com Sat Sep 2 01:55:24 2017 From: short.chrisd at gmail.com (Christopher Short) Date: Sat, 2 Sep 2017 13:55:24 +0800 Subject: [Matplotlib-users] [ANN]: Matplotlib 2.1.0rc1 In-Reply-To: References: Message-ID: <50D46065-D42E-4B62-B919-9E2BC4C549C3@gmail.com> Tom Is the conda package formula correct? The following packages will be DOWNGRADED: matplotlib: 2.0.2-np112py36_0 conda-forge --> 2.0.0-np111py36_1 conda-forge/label/rc Or am I misreading? thanks Chris > On 2 Sep 2017, at 12:34 pm, Thomas Caswell wrote: > > Folks, > > We are happy to announce 2.1.0rc1! > > Wheels and and source on pypi and as a conda package via conda-forge. Please try it out and report any issues! > > See http://matplotlib.org/devdocs/users/whats_new.html for a draft of the release notes. This represents ~2 years of work and includes many new features and bug fixes. > > Please checkout our updated documentation (http://matplotlib.org/devdocs/index.html ), particularly the examples (http://matplotlib.org/devdocs/gallery/index.html ) and tutorials (http://matplotlib.org/devdocs/tutorials/index.html ) . Re-organizing, updating, and migrating the examples to sphinx-gallery was a huge effort led by Nelle Varoquaux and Chris Holdgraf. > > A big thanks to the many (~280) people who contributed to this release. > > Installation instructions (via pip into existing venv): > > pip install --upgrade --pre matplotlib > > or (via conda into a new venv) > > conda create -n mpl_rc matplotlib ipython -c conda-forge/label/rc -c conda-forge > > or(via conda into an existing venv) > > conda install -c conda-forge/label/rc matplotlib -c conda-forge > > Tom > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From short.chrisd at gmail.com Sat Sep 2 02:00:04 2017 From: short.chrisd at gmail.com (Christopher Short) Date: Sat, 2 Sep 2017 14:00:04 +0800 Subject: [Matplotlib-users] [ANN]: Matplotlib 2.1.0rc1 In-Reply-To: <50D46065-D42E-4B62-B919-9E2BC4C549C3@gmail.com> References: <50D46065-D42E-4B62-B919-9E2BC4C549C3@gmail.com> Message-ID: <4B71A6E9-2E28-47CE-9509-A3B21BDF8BBF@gmail.com> And apologies - I neglected to thank you and the rest of the team/contributors. Fantastic work. And from the download list: The following packages will be downloaded: package | build ---------------------------|----------------- matplotlib-2.0.0 | np111py36_1 6.6 MB conda-forge/label/rc cheers Chris > On 2 Sep 2017, at 1:55 pm, Christopher Short wrote: > > Tom > > Is the conda package formula correct? > > The following packages will be DOWNGRADED: > > matplotlib: 2.0.2-np112py36_0 conda-forge --> 2.0.0-np111py36_1 conda-forge/label/rc > > Or am I misreading? > > thanks > Chris > > > > >> On 2 Sep 2017, at 12:34 pm, Thomas Caswell > wrote: >> >> Folks, >> >> We are happy to announce 2.1.0rc1! >> >> Wheels and and source on pypi and as a conda package via conda-forge. Please try it out and report any issues! >> >> See http://matplotlib.org/devdocs/users/whats_new.html for a draft of the release notes. This represents ~2 years of work and includes many new features and bug fixes. >> >> Please checkout our updated documentation (http://matplotlib.org/devdocs/index.html ), particularly the examples (http://matplotlib.org/devdocs/gallery/index.html ) and tutorials (http://matplotlib.org/devdocs/tutorials/index.html ) . Re-organizing, updating, and migrating the examples to sphinx-gallery was a huge effort led by Nelle Varoquaux and Chris Holdgraf. >> >> A big thanks to the many (~280) people who contributed to this release. >> >> Installation instructions (via pip into existing venv): >> >> pip install --upgrade --pre matplotlib >> >> or (via conda into a new venv) >> >> conda create -n mpl_rc matplotlib ipython -c conda-forge/label/rc -c conda-forge >> >> or(via conda into an existing venv) >> >> conda install -c conda-forge/label/rc matplotlib -c conda-forge >> >> Tom >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Sat Sep 2 04:43:11 2017 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Sat, 2 Sep 2017 11:43:11 +0300 Subject: [Matplotlib-users] [ANN]: Matplotlib 2.1.0rc1 In-Reply-To: <4B71A6E9-2E28-47CE-9509-A3B21BDF8BBF@gmail.com> References: <50D46065-D42E-4B62-B919-9E2BC4C549C3@gmail.com> <4B71A6E9-2E28-47CE-9509-A3B21BDF8BBF@gmail.com> Message-ID: <5017da9c-01f3-4623-ab4d-e0bb0c6b4dab@Spark> >?Axes3D now has a voxels method, for visualizing boolean 3d data. Uses could include plotting a sparse 3D heat map, or visualizing a volumetric model. ??? I have wanted this since forever. Thank you to all the contributors and of course to Tom. Incidentally, if there is a guide for producing conda-forge pre-releases, I would avidly read it! Google finds this unconclusive thread: https://github.com/conda-forge/conda-forge.github.io/issues/147 Juan. On 2 Sep 2017, 9:00 AM +0300, Christopher Short , wrote: > And apologies - I neglected to thank you and the rest of the team/contributors. > > Fantastic work. > > > And from the download list: > > The following packages will be downloaded: > > ? ? package? ? ? ? ? ? ? ? ? ? |? ? ? ? ? ? build > ? ? ---------------------------|----------------- > > ? ? matplotlib-2.0.0 ? ? ? ? ? |? ? ? np111py36_1 ? ? ? ? 6.6 MB? conda-forge/label/rc > > > cheers > Chris > > > On 2 Sep 2017, at 1:55 pm, Christopher Short wrote: > > > > Tom > > > > Is the conda package formula correct? > > > > The following packages will be DOWNGRADED: > > > > ? ? matplotlib: ? 2.0.2-np112py36_0? ? ? ? ? ? ? ? ? conda-forge --> 2.0.0-np111py36_1 ? ? ? ? ? ? conda-forge/label/rc > > > > Or am I misreading? > > > > thanks > > Chris > > > > > > > > > > > On 2 Sep 2017, at 12:34 pm, Thomas Caswell wrote: > > > > > > Folks, > > > > > > We are happy to announce 2.1.0rc1! > > > > > > Wheels and and source on pypi and as a conda package via conda-forge.? Please try it out and report any issues! > > > > > > See?http://matplotlib.org/devdocs/users/whats_new.html?for a draft of the release notes. ? This represents ~2 years of work and includes many new features and bug fixes. > > > > > > Please checkout our updated documentation (http://matplotlib.org/devdocs/index.html), particularly the ?examples (http://matplotlib.org/devdocs/gallery/index.html?) and tutorials (http://matplotlib.org/devdocs/tutorials/index.html) .? Re-organizing, updating, and migrating the examples to sphinx-gallery was a huge effort led by Nelle Varoquaux and ?Chris Holdgraf. > > > > > > A big thanks to the many (~280) people who contributed to this release. > > > > > > Installation instructions (via pip into existing venv): > > > > > > ? pip install --upgrade --pre matplotlib > > > > > > or (via conda into a new venv) > > > > > > ??conda create -n mpl_rc matplotlib ipython -c conda-forge/label/rc -c conda-forge > > > > > > or(via conda into an existing venv) > > > > > > ?conda install -c conda-forge/label/rc matplotlib -c conda-forge > > > > > > Tom > > > > > > _______________________________________________ > > > Matplotlib-users mailing list > > > Matplotlib-users at python.org > > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sat Sep 2 09:59:25 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Sat, 02 Sep 2017 13:59:25 +0000 Subject: [Matplotlib-users] [ANN]: Matplotlib 2.1.0rc1 In-Reply-To: <5017da9c-01f3-4623-ab4d-e0bb0c6b4dab@Spark> References: <50D46065-D42E-4B62-B919-9E2BC4C549C3@gmail.com> <4B71A6E9-2E28-47CE-9509-A3B21BDF8BBF@gmail.com> <5017da9c-01f3-4623-ab4d-e0bb0c6b4dab@Spark> Message-ID: Chris: Due to some issues with conda-forge's upload process, the RC got pushed to the main channel, the windows and linux packages got manually fixed, but the mac build were so backed up they went out ~10-14 hours later and have not been fixed yet. I assume you are on a mac, if so just installing from the conda-forge channel will work until it gets fixed! Juan: There is also https://github.com/conda-forge/conda-forge-enhancement-proposals/pull/3 and looking at https://github.com/conda-forge/matplotlib-feedstock/tree/devel . I suspect those questions would be better directed to the conda-forge mailing list / gitter room. Tom On Sat, Sep 2, 2017 at 4:45 AM Juan Nunez-Iglesias wrote: > > Axes3D now has a voxels method, for visualizing boolean 3d data. Uses > could include plotting a sparse 3D heat map, or visualizing a volumetric > model. > > ??? > > I have wanted this since forever. > > Thank you to all the contributors and of course to Tom. > > Incidentally, if there is a guide for producing conda-forge pre-releases, > I would avidly read it! Google finds this unconclusive thread: > https://github.com/conda-forge/conda-forge.github.io/issues/147 > > Juan. > > On 2 Sep 2017, 9:00 AM +0300, Christopher Short , > wrote: > > And apologies - I neglected to thank you and the rest of the > team/contributors. > > Fantastic work. > > > And from the download list: > > The following packages will be downloaded: > > package | build > ---------------------------|----------------- > > matplotlib-2.0.0 | np111py36_1 6.6 MB > conda-forge/label/rc > > > cheers > Chris > > On 2 Sep 2017, at 1:55 pm, Christopher Short > wrote: > > Tom > > Is the conda package formula correct? > > The following packages will be DOWNGRADED: > > matplotlib: 2.0.2-np112py36_0 conda-forge --> > 2.0.0-np111py36_1 conda-forge/label/rc > > Or am I misreading? > > thanks > Chris > > > > > On 2 Sep 2017, at 12:34 pm, Thomas Caswell wrote: > > Folks, > > We are happy to announce 2.1.0rc1! > > Wheels and and source on pypi and as a conda package via conda-forge. > Please try it out and report any issues! > > See http://matplotlib.org/devdocs/users/whats_new.html for a draft of the > release notes. This represents ~2 years of work and includes many new > features and bug fixes. > > Please checkout our updated documentation ( > http://matplotlib.org/devdocs/index.html), particularly the examples ( > http://matplotlib.org/devdocs/gallery/index.html ) and tutorials ( > http://matplotlib.org/devdocs/tutorials/index.html) . Re-organizing, > updating, and migrating the examples to sphinx-gallery was a huge effort > led by Nelle Varoquaux and Chris Holdgraf. > > A big thanks to the many (~280) people who contributed to this release. > > Installation instructions (via pip into existing venv): > > pip install --upgrade --pre matplotlib > > or (via conda into a new venv) > > conda create -n mpl_rc matplotlib ipython -c conda-forge/label/rc -c > conda-forge > > or(via conda into an existing venv) > > conda install -c conda-forge/label/rc matplotlib -c conda-forge > > Tom > > _______________________________________________ > 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 jean-philippe.grivet at wanadoo.fr Sat Sep 2 10:01:17 2017 From: jean-philippe.grivet at wanadoo.fr (Jean-Philippe Grivet) Date: Sat, 2 Sep 2017 16:01:17 +0200 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> Message-ID: <59AAB9AD.6080407@wanadoo.fr> Hi Thank you for the very interesting refeerences. However, I find that the various programs are rather involved and that they do not exactly answer my needs. The simplest program is probably the following (from the boook by B. Root). It seems to be a step in the right direction! import matplotlib.pyplot as plt def process_key(event): print("Key:", event.key) def process_button(event): print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) fig, ax = plt.subplots(1, 1) fig.canvas.mpl_connect('key_press_event', process_key) fig.canvas.mpl_connect('button_press_event', process_button) plt.show() So now, how do I retrieve the values event.xdata, event.ydata s(everal times) in order to use them in the main program ? (By the way, this is pretty easy in Matlab: the function xclick the mouse coordinates and index of the button pressed). Thank you soluch for your help. JP Grivet Le 30/08/2017 04:13, Thomas Caswell a ?crit : > Jean, > > What you want to do is totally possible! > > I suggest having a look at the examples in > https://matplotlib.org/examples/widgets/index.html the `ginput` > method, https://github.com/tacaswell/interactive_mpl_tutorial and Ben > Root's book > https://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843 > > > Tom > --- L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. https://www.avast.com/antivirus From jklymak at uvic.ca Sat Sep 2 10:30:23 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sat, 02 Sep 2017 07:30:23 -0700 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: <59AAB9AD.6080407@wanadoo.fr> References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> Message-ID: Hi Jean-Philippe There may be a fancier way, but you can just declare a global in `process_button` to pass the value to a global variable. Cheers, Jody ``` import matplotlib.pyplot as plt x = [] def process_key(event): print("Key:", event.key) def process_button(event): global x print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) x += [event.xdata] fig, ax = plt.subplots(1, 1) fig.canvas.mpl_connect('key_press_event', process_key) fig.canvas.mpl_connect('button_press_event', process_button) plt.show() print(x) ``` On 2 Sep 2017, at 7:01, Jean-Philippe Grivet wrote: > Hi > Thank you for the very interesting refeerences. However, I find that > the various programs are rather > involved and that they do not exactly answer my needs. The simplest > program is probably the following > (from the boook by B. Root). It seems to be a step in the right > direction! > > import matplotlib.pyplot as plt > > def process_key(event): > print("Key:", event.key) > def process_button(event): > print("Button:", event.x, event.y, event.xdata, event.ydata, > event.button) > > fig, ax = plt.subplots(1, 1) > fig.canvas.mpl_connect('key_press_event', process_key) > fig.canvas.mpl_connect('button_press_event', process_button) > plt.show() > > So now, how do I retrieve the values event.xdata, event.ydata s(everal > times) in > order to use them in the main program ? (By the way, this is pretty > easy > in Matlab: the function xclick the mouse coordinates and index of the > button > pressed). > Thank you soluch for your help. > JP Grivet > > > Le 30/08/2017 04:13, Thomas Caswell a ?crit : >> Jean, >> >> What you want to do is totally possible! >> >> I suggest having a look at the examples in >> https://matplotlib.org/examples/widgets/index.html the `ginput` >> method, https://github.com/tacaswell/interactive_mpl_tutorial and Ben >> Root's book >> https://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843 >> >> Tom >> > > > --- > L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e > par le logiciel antivirus Avast. > https://www.avast.com/antivirus > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Sat Sep 2 21:08:03 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Sat, 2 Sep 2017 21:08:03 -0400 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> Message-ID: If you assign a class method as the callbacks, such as process_button(self, event), then that method could save the relevant values to itself. I show how to do this in my book (as well as the global approach, too). Cheers! Ben Root On Sat, Sep 2, 2017 at 10:30 AM, Jody Klymak wrote: > Hi Jean-Philippe > > There may be a fancier way, but you can just declare a global in > process_button to pass the value to a global variable. > > Cheers, Jody > > import matplotlib.pyplot as plt > > x = [] > > def process_key(event): > print("Key:", event.key) > def process_button(event): > global x > print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) > x += [event.xdata] > > fig, ax = plt.subplots(1, 1) > fig.canvas.mpl_connect('key_press_event', process_key) > fig.canvas.mpl_connect('button_press_event', process_button) > plt.show() > > print(x) > > > On 2 Sep 2017, at 7:01, Jean-Philippe Grivet wrote: > > Hi > Thank you for the very interesting refeerences. However, I find that the > various programs are rather > involved and that they do not exactly answer my needs. The simplest > program is probably the following > (from the boook by B. Root). It seems to be a step in the right direction! > > import matplotlib.pyplot as plt > > def process_key(event): > print("Key:", event.key) > def process_button(event): > print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) > > fig, ax = plt.subplots(1, 1) > fig.canvas.mpl_connect('key_press_event', process_key) > fig.canvas.mpl_connect('button_press_event', process_button) > plt.show() > > So now, how do I retrieve the values event.xdata, event.ydata s(everal > times) in > order to use them in the main program ? (By the way, this is pretty easy > in Matlab: the function xclick the mouse coordinates and index of the > button > pressed). > Thank you soluch for your help. > JP Grivet > > > Le 30/08/2017 04:13, Thomas Caswell a ?crit : > > Jean, > > What you want to do is totally possible! > > I suggest having a look at the examples in https://matplotlib.org/ > examples/widgets/index.html the `ginput` method, > https://github.com/tacaswell/interactive_mpl_tutorial and Ben Root's book > https://www.amazon.com/Interactive-Applications- > using-Matplotlib-Benjamin/dp/1783988843 > > Tom > > --- > L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le > logiciel antivirus Avast. > https://www.avast.com/antivirus > > _______________________________________________ > 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 jklymak at uvic.ca Sun Sep 3 11:28:35 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Sun, 03 Sep 2017 08:28:35 -0700 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> Message-ID: Hi Jean-Philippe, Just to explicitly implement Ben?s suggestion? Cheers, Jody ```python import matplotlib matplotlib.use('Qt5Agg') import matplotlib.pyplot as plt import numpy as np class Picker(object): def __init__(self): self.x = np.array([]) self.y = np.array([]) def process_key(self, event): print("Key:", event.key) def process_button(self, event): print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) self.x = np.append(self.x, event.xdata) self.y = np.append(self.y, event.ydata) def get_x(self): return self.x def get_y(self): return self.y fig, ax = plt.subplots(1, 1) picker = Picker() fig.canvas.mpl_connect('key_press_event', picker.process_key) fig.canvas.mpl_connect('button_press_event', picker.process_button) plt.show() print(picker.x) # print(picker.get_x()) # the same print(picker.get_x().mean()) # returns the mean of x. print(picker.get_y()) print(picker.get_y().mean()) ``` On 2 Sep 2017, at 18:08, Benjamin Root wrote: > If you assign a class method as the callbacks, such as > process_button(self, > event), then that method could save the relevant values to itself. I > show > how to do this in my book (as well as the global approach, too). > > Cheers! > Ben Root > > On Sat, Sep 2, 2017 at 10:30 AM, Jody Klymak wrote: > >> Hi Jean-Philippe >> >> There may be a fancier way, but you can just declare a global in >> process_button to pass the value to a global variable. >> >> Cheers, Jody >> >> import matplotlib.pyplot as plt >> >> x = [] >> >> def process_key(event): >> print("Key:", event.key) >> def process_button(event): >> global x >> print("Button:", event.x, event.y, event.xdata, event.ydata, >> event.button) >> x += [event.xdata] >> >> fig, ax = plt.subplots(1, 1) >> fig.canvas.mpl_connect('key_press_event', process_key) >> fig.canvas.mpl_connect('button_press_event', process_button) >> plt.show() >> >> print(x) >> >> >> On 2 Sep 2017, at 7:01, Jean-Philippe Grivet wrote: >> >> Hi >> Thank you for the very interesting refeerences. However, I find that >> the >> various programs are rather >> involved and that they do not exactly answer my needs. The simplest >> program is probably the following >> (from the boook by B. Root). It seems to be a step in the right >> direction! >> >> import matplotlib.pyplot as plt >> >> def process_key(event): >> print("Key:", event.key) >> def process_button(event): >> print("Button:", event.x, event.y, event.xdata, event.ydata, >> event.button) >> >> fig, ax = plt.subplots(1, 1) >> fig.canvas.mpl_connect('key_press_event', process_key) >> fig.canvas.mpl_connect('button_press_event', process_button) >> plt.show() >> >> So now, how do I retrieve the values event.xdata, event.ydata >> s(everal >> times) in >> order to use them in the main program ? (By the way, this is pretty >> easy >> in Matlab: the function xclick the mouse coordinates and index of the >> button >> pressed). >> Thank you soluch for your help. >> JP Grivet >> >> >> Le 30/08/2017 04:13, Thomas Caswell a ?crit : >> >> Jean, >> >> What you want to do is totally possible! >> >> I suggest having a look at the examples in https://matplotlib.org/ >> examples/widgets/index.html the `ginput` method, >> https://github.com/tacaswell/interactive_mpl_tutorial and Ben Root's >> book >> https://www.amazon.com/Interactive-Applications- >> using-Matplotlib-Benjamin/dp/1783988843 >> >> Tom >> >> --- >> L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e >> par le >> logiciel antivirus Avast. >> https://www.avast.com/antivirus >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Sep 4 04:16:25 2017 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Mon, 4 Sep 2017 11:16:25 +0300 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> Message-ID: For what it?s worth, I highly recommend picking up a copy of Ben?s book. It helped me to understand not just interactive matplotlib, but interactive GUI programming in general. Thanks, Ben! ;) On 3 Sep 2017, 6:33 PM +0300, Jody Klymak , wrote: > Hi Jean-Philippe, > Just to explicitly implement Ben?s suggestion? > Cheers, Jody > import matplotlib > matplotlib.use('Qt5Agg') > > import matplotlib.pyplot as plt > import numpy as np > > class Picker(object): > > def __init__(self): > self.x = np.array([]) > self.y = np.array([]) > > def process_key(self, event): > print("Key:", event.key) > > def process_button(self, event): > print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) > self.x = np.append(self.x, event.xdata) > self.y = np.append(self.y, event.ydata) > > def get_x(self): > return self.x > > def get_y(self): > return self.y > > fig, ax = plt.subplots(1, 1) > picker = Picker() > fig.canvas.mpl_connect('key_press_event', picker.process_key) > fig.canvas.mpl_connect('button_press_event', picker.process_button) > plt.show() > > print(picker.x) # > print(picker.get_x()) # the same > print(picker.get_x().mean()) # returns the mean of x. > print(picker.get_y()) > print(picker.get_y().mean()) > On 2 Sep 2017, at 18:08, Benjamin Root wrote: > > If you assign a class method as the callbacks, such as process_button(self, event), then that method could save the relevant values to itself. I show how to do this in my book (as well as the global approach, too). > > > > Cheers! > > Ben Root > > > > > On Sat, Sep 2, 2017 at 10:30 AM, Jody Klymak wrote: > > > > Hi Jean-Philippe > > > > There may be a fancier way, but you can just declare a global in process_button to pass the value to a global variable. > > > > Cheers, Jody > > > > import matplotlib.pyplot as plt > > > > > > > > x = [] > > > > > > > > def process_key(event): > > > > print("Key:", event.key) > > > > def process_button(event): > > > > global x > > > > print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) > > > > x += [event.xdata] > > > > > > > > fig, ax = plt.subplots(1, 1) > > > > fig.canvas.mpl_connect('key_press_event', process_key) > > > > fig.canvas.mpl_connect('button_press_event', process_button) > > > > plt.show() > > > > > > > > print(x) > > > > > > > > On 2 Sep 2017, at 7:01, Jean-Philippe Grivet wrote: > > > > > Hi > > > > > Thank you for the very interesting refeerences. However, I find that the various programs are rather > > > > > involved and that they do not exactly answer my needs. The simplest program is probably the following > > > > > (from the boook by B. Root). It seems to be a step in the right direction! > > > > > > > > > > import matplotlib.pyplot as plt > > > > > > > > > > def process_key(event): > > > > > print("Key:", event.key) > > > > > def process_button(event): > > > > > print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) > > > > > > > > > > fig, ax = plt.subplots(1, 1) > > > > > fig.canvas.mpl_connect('key_press_event', process_key) > > > > > fig.canvas.mpl_connect('button_press_event', process_button) > > > > > plt.show() > > > > > > > > > > So now, how do I retrieve the values event.xdata, event.ydata s(everal times) in > > > > > order to use them in the main program ? (By the way, this is pretty easy > > > > > in Matlab: the function xclick the mouse coordinates and index of the button > > > > > pressed). > > > > > Thank you soluch for your help. > > > > > JP Grivet > > > > > > > > > > > > > > > Le 30/08/2017 04:13, Thomas Caswell a ?crit : > > > > > > Jean, > > > > > > > > > > > > What you want to do is totally possible! > > > > > > > > > > > > I suggest having a look at the examples in https://matplotlib.org/examples/widgets/index.html the `ginput` method, https://github.com/tacaswell/interactive_mpl_tutorial and Ben Root's book https://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843 > > > > > > > > > > > > Tom > > > > > --- > > > > > L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. > > > > > https://www.avast.com/antivirus > > > > > > > > > > _______________________________________________ > > > > > 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 jean-philippe.grivet at wanadoo.fr Tue Sep 5 09:33:42 2017 From: jean-philippe.grivet at wanadoo.fr (Jean-Philippe Grivet) Date: Tue, 5 Sep 2017 15:33:42 +0200 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> Message-ID: <59AEA7B6.6000307@wanadoo.fr> Thank you Benjamin and Jody for your sugestions. Due to my scanty knwledge of Python, I unfortunately can't get these programs to do what I want. Referring to Jody's code, the statement "print(x)" is executed only once, upon lauching the program. Then, the various xdata values are stored in x but nothing more happens, until I close the graphic window. This termintes execution. If I issue print(x) in the console, I recover the values of interest. My attempts to plot a dot where the button was clicked have failed. Ben's code behaves similarly, except that it starts by attempting to compute the average of some undefined values. Can this poor performance be due to the fact that I work inside Spyder ? I am sorry that I keep trying your patience but I will be grateful for any suggestion. Sincetrely, Jean-Philippe > |import matplotlib matplotlib.use('Qt5Agg') import matplotlib.pyplot as > plt import numpy as np class Picker(object): def __init__(self): > self.x = np.array([]) self.y = np.array([]) def process_key(self, > event): print("Key:", event.key) def process_button(self, event): > print("Button:", event.x, event.y, event.xdata, event.ydata, > event.button) self.x = np.append(self.x, event.xdata) self.y = > np.append(self.y, event.ydata) def get_x(self): return self.x def > get_y(self): return self.y fig, ax = plt.subplots(1, 1) picker = > Picker() fig.canvas.mpl_connect('key_press_event', picker.process_key) > fig.canvas.mpl_connect('button_press_event', picker.process_button) > plt.show() print(picker.x) # print(picker.get_x()) # the same > print(picker.get_x().mean()) # returns the mean of x. > print(picker.get_y()) print(picker.get_y().mean()) | > > On 2 Sep 2017, at 18:08, Benjamin Root wrote: > > If you assign a class method as the callbacks, such as > process_button(self, event), then that method could save the > relevant values to itself. I show how to do this in my book (as > well as the global approach, too). > > Cheers! > Ben Root > > On Sat, Sep 2, 2017 at 10:30 AM, Jody Klymak > wrote: > > Hi Jean-Philippe > > There may be a fancier way, but you can just declare a global > in |process_button| to pass the value to a global variable. > > Cheers, Jody > > |import matplotlib.pyplot as plt x = [] def process_key(event): > print("Key:", event.key) def process_button(event): global x > print("Button:", event.x, event.y, event.xdata, event.ydata, > event.button) x += [event.xdata] fig, ax = plt.subplots(1, 1) > fig.canvas.mpl_connect('key_press_event', process_key) > fig.canvas.mpl_connect('button_press_event', process_button) > plt.show() print(x) | > --- L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Tue Sep 5 13:36:17 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Tue, 05 Sep 2017 10:36:17 -0700 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: <59AEA7B6.6000307@wanadoo.fr> References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> <59AEA7B6.6000307@wanadoo.fr> Message-ID: OK, I think you want the equivalent of matlab?s ``` plot(something) x,y = ginput(?Click the figure?) plot(x, y) ``` *and* you want it to execute in an interactive session in `ipython` (spyder) I don?t think you can do that, though there may be some new widgets that will let it happen these days. Historically, it is better to think of any graphical interaction as a separate program. If you are willing to do that, then plotting the data as you click is very simple: ```python import matplotlib matplotlib.use('Qt5Agg') import matplotlib.pyplot as plt import numpy as np class Picker(object): def __init__(self, ax=None): self.x = np.array([]) self.y = np.array([]) self.ax = ax self.dots, = ax.plot(1, 1, marker='o') self.dots.set_xdata(self.x) self.dots.set_ydata(self.y) self.fig = self.ax.get_figure() def process_key(self, event): print("Key:", event.key) def process_button(self, event): print("Button:", event.x, event.y, event.xdata, event.ydata, event.button) self.x = np.append(self.x, event.xdata) self.y = np.append(self.y, event.ydata) self.dots.set_xdata(self.x) self.dots.set_ydata(self.y) plt.draw() def get_x(self): return self.x def get_y(self): return self.y fig, ax = plt.subplots(1, 1) picker = Picker(ax=ax) fig.canvas.mpl_connect('key_press_event', picker.process_key) fig.canvas.mpl_connect('button_press_event', picker.process_button) plt.show() print(picker.x) # print(picker.get_x()) # the same print(picker.get_x().mean()) # returns the mean of x. print(picker.get_y()) print(picker.get_y().mean()) ``` You save the above as a file (`mypicker.py`) and in `ipython` you execute `run mypicker.py`. Note that after you have executed it, `picker` is still in your workspace to access. I hope that helps. Jody On 5 Sep 2017, at 6:33, Jean-Philippe Grivet wrote: > Thank you Benjamin and Jody for your sugestions. Due to my scanty > knwledge of Python, > I unfortunately can't get these programs to do what I want. > Referring to Jody's code, the statement "print(x)" is executed only > once, upon > lauching the program. Then, the various xdata values are stored in x > but nothing more > happens, until I close the graphic window. This termintes execution. > If I issue print(x) > in the console, I recover the values of interest. My attempts to plot > a dot where the > button was clicked have failed. > Ben's code behaves similarly, except that it starts by attempting to > compute the > average of some undefined values. > Can this poor performance be due to the fact that I work inside Spyder > ? > I am sorry that I keep trying your patience but I will be grateful for > any > suggestion. > Sincetrely, > Jean-Philippe >> |import matplotlib matplotlib.use('Qt5Agg') import matplotlib.pyplot >> as plt import numpy as np class Picker(object): def __init__(self): >> self.x = np.array([]) self.y = np.array([]) def process_key(self, >> event): print("Key:", event.key) def process_button(self, event): >> print("Button:", event.x, event.y, event.xdata, event.ydata, >> event.button) self.x = np.append(self.x, event.xdata) self.y = >> np.append(self.y, event.ydata) def get_x(self): return self.x def >> get_y(self): return self.y fig, ax = plt.subplots(1, 1) picker = >> Picker() fig.canvas.mpl_connect('key_press_event', >> picker.process_key) fig.canvas.mpl_connect('button_press_event', >> picker.process_button) plt.show() print(picker.x) # >> print(picker.get_x()) # the same print(picker.get_x().mean()) # >> returns the mean of x. print(picker.get_y()) >> print(picker.get_y().mean()) | >> >> On 2 Sep 2017, at 18:08, Benjamin Root wrote: >> >> If you assign a class method as the callbacks, such as >> process_button(self, event), then that method could save the >> relevant values to itself. I show how to do this in my book (as >> well as the global approach, too). >> >> Cheers! >> Ben Root >> >> On Sat, Sep 2, 2017 at 10:30 AM, Jody Klymak > > wrote: >> >> Hi Jean-Philippe >> >> There may be a fancier way, but you can just declare a global >> in |process_button| to pass the value to a global variable. >> >> Cheers, Jody >> >> |import matplotlib.pyplot as plt x = [] def >> process_key(event): >> print("Key:", event.key) def process_button(event): global x >> print("Button:", event.x, event.y, event.xdata, event.ydata, >> event.button) x += [event.xdata] fig, ax = plt.subplots(1, 1) >> fig.canvas.mpl_connect('key_press_event', process_key) >> fig.canvas.mpl_connect('button_press_event', process_button) >> plt.show() print(x) | >> > > > --- > L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e > par le logiciel antivirus Avast. > https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From amit at phpandmore.net Tue Sep 5 14:04:17 2017 From: amit at phpandmore.net (Amit Yaron) Date: Tue, 5 Sep 2017 21:04:17 +0300 Subject: [Matplotlib-users] Circular Arrow Closed Path Message-ID: Hi, Does this shape already exist in Matplotlib modules? I've attached an example prepared with LibreOffice Draw. -------------- next part -------------- A non-text attachment was scrubbed... Name: arrowExample.png Type: image/png Size: 15001 bytes Desc: not available URL: From vincent.adrien at gmail.com Tue Sep 5 14:47:19 2017 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Tue, 5 Sep 2017 11:47:19 -0700 Subject: [Matplotlib-users] Circular Arrow Closed Path In-Reply-To: References: Message-ID: <7005b981-79f9-9663-71aa-4fd72a9602b5@gmail.com> Hi Amit, You may find usseful ressources about arrow shapes in Matplotlib at https://matplotlib.org/users/annotations.html, with examples on how to use the `matplotlib.axes.Axes.annotate` method(, which heavily relies on the `matplotlib.patches.FancyArrowPatch` if you are actually more interested in how things are done under the hood). Here is a quick example of what you can expect more or less out-of-the-box from `ax.annotate`: ```python import matplotlib.pyplot as plt fig, ax = plt.subplots(num='demo_arrow_with_annotate.png', figsize=(3, 3)) ax.annotate("", xy=(0.5, 0.8), xycoords='data', xytext=(0.5, 0.2), textcoords='data', size=40, va="center", ha="center", arrowprops=dict(arrowstyle="simple", # <-- ~ LO style facecolor="DeepPink", edgecolor="none", connectionstyle="arc3,rad=1"), ) plt.show() ``` If you really want a specific patch shape that you cannot get by tweaking the existing arrow shapes, it should still be possible to define a patch directly with vertices and B?zier curves. Best regards, Adrien On 09/05/2017 11:04 AM, Amit Yaron wrote: > Hi, > > Does this shape already exist in Matplotlib modules? > I've attached an example prepared with LibreOffice Draw. > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- A non-text attachment was scrubbed... Name: demo_arrow_with_annotate.png Type: image/png Size: 8900 bytes Desc: not available URL: From amit at phpandmore.net Thu Sep 7 15:11:31 2017 From: amit at phpandmore.net (Amit Yaron) Date: Thu, 7 Sep 2017 22:11:31 +0300 Subject: [Matplotlib-users] Circular Arrow Closed Path In-Reply-To: <7005b981-79f9-9663-71aa-4fd72a9602b5@gmail.com> References: <7005b981-79f9-9663-71aa-4fd72a9602b5@gmail.com> Message-ID: <8b3f5924-e711-0c76-13ce-5201bd05ab9e@phpandmore.net> Thanks, Adrien I'm going to use the B?zier curves for interactivity. Class 'FancyArrowPatch' has the method 'get_path()' , which is helpful in creating the approximation. Best regards, Amit On 05.09.2017 21:47, vincent.adrien at gmail.com wrote: > Hi Amit, > > You may find usseful ressources about arrow shapes in Matplotlib at > https://matplotlib.org/users/annotations.html, with examples on how to > use the `matplotlib.axes.Axes.annotate` method(, which heavily relies on > the `matplotlib.patches.FancyArrowPatch` if you are actually more > interested in how things are done under the hood). > > Here is a quick example of what you can expect more or less > out-of-the-box from `ax.annotate`: > ```python > import matplotlib.pyplot as plt > > fig, ax = plt.subplots(num='demo_arrow_with_annotate.png', > figsize=(3, 3)) > > ax.annotate("", > xy=(0.5, 0.8), xycoords='data', > xytext=(0.5, 0.2), textcoords='data', > size=40, va="center", ha="center", > arrowprops=dict(arrowstyle="simple", # <-- ~ LO style > facecolor="DeepPink", edgecolor="none", > connectionstyle="arc3,rad=1"), > ) > > plt.show() > ``` > > If you really want a specific patch shape that you cannot get by > tweaking the existing arrow shapes, it should still be possible to > define a patch directly with vertices and B?zier curves. > > Best regards, > Adrien > > On 09/05/2017 11:04 AM, Amit Yaron wrote: >> Hi, >> >> Does this shape already exist in Matplotlib modules? >> I've attached an example prepared with LibreOffice Draw. >> >> >> _______________________________________________ >> 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 jean-philippe.grivet at wanadoo.fr Fri Sep 8 11:41:46 2017 From: jean-philippe.grivet at wanadoo.fr (Jean-Philippe Grivet) Date: Fri, 8 Sep 2017 17:41:46 +0200 Subject: [Matplotlib-users] selecting points inside plot In-Reply-To: References: <59A57869.3010807@wanadoo.fr> <59AAB9AD.6080407@wanadoo.fr> <59AEA7B6.6000307@wanadoo.fr> Message-ID: <59B2BA3A.7070109@wanadoo.fr> Thank you Jody, I'll try work my way starting with your ode. Jean-Philippe > OK, I think you want the equivalent of matlab?s > > |plot(something) x,y = ginput(?Click the figure?) plot(x, y) | > > /and/ you want it to execute in an interactive session in |ipython| > (spyder) > > I don?t think you can do that, though there may be some new widgets > that will let it happen these days. > > Historically, it is better to think of any graphical interaction as a > separate program. If you are willing to do that, then plotting the > data as you click is very simple: > > |import matplotlib matplotlib.use('Qt5Agg') import matplotlib.pyplot as > plt import numpy as np class Picker(object): def __init__(self, > ax=None): self.x = np.array([]) self.y = np.array([]) self.ax = ax > self.dots, = ax.plot(1, 1, marker='o') self.dots.set_xdata(self.x) > self.dots.set_ydata(self.y) self.fig = self.ax.get_figure() def > process_key(self, event): print("Key:", event.key) def > process_button(self, event): print("Button:", event.x, event.y, > event.xdata, event.ydata, event.button) self.x = np.append(self.x, > event.xdata) self.y = np.append(self.y, event.ydata) > self.dots.set_xdata(self.x) self.dots.set_ydata(self.y) plt.draw() def > get_x(self): return self.x def get_y(self): return self.y fig, ax = > plt.subplots(1, 1) picker = Picker(ax=ax) > fig.canvas.mpl_connect('key_press_event', picker.process_key) > fig.canvas.mpl_connect('button_press_event', picker.process_button) > plt.show() print(picker.x) # print(picker.get_x()) # the same > print(picker.get_x().mean()) # returns the mean of x. > print(picker.get_y()) print(picker.get_y().mean(| --- L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From cdpnepal594 at gmail.com Fri Sep 8 15:31:34 2017 From: cdpnepal594 at gmail.com (cdpnepal) Date: Fri, 8 Sep 2017 12:31:34 -0700 (MST) Subject: [Matplotlib-users] Saving interactive plot Message-ID: <1504899094062-0.post@n5.nabble.com> Is there a way to save interactive plot in matplotlib -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From vincent.adrien at gmail.com Fri Sep 8 16:20:03 2017 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Fri, 8 Sep 2017 13:20:03 -0700 Subject: [Matplotlib-users] Saving interactive plot In-Reply-To: <1504899094062-0.post@n5.nabble.com> References: <1504899094062-0.post@n5.nabble.com> Message-ID: <32364dcf-6184-b57e-6923-3406b5579a4b@gmail.com> Hi, I am not sure that I understand the question. If by interactive you mean in a interactive session, then the following in your shell should do what you want: ```python plt.savefig("my_figure.png", dpi=300) # save a PNG of the last active figure with 300 DPI fig.savefig("my_figure.png", dpi=300) # does as above but one explicitely specifies the figure to save ``` Yet another option is to directly use the ?Save? button (pictured as a stylised floppy drive) in the figure window. Best, Adrien On 09/08/2017 12:31 PM, cdpnepal wrote: > Is there a way to save interactive plot in matplotlib > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From ben.v.root at gmail.com Fri Sep 8 16:36:16 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Fri, 8 Sep 2017 16:36:16 -0400 Subject: [Matplotlib-users] Saving interactive plot In-Reply-To: <1504899094062-0.post@n5.nabble.com> References: <1504899094062-0.post@n5.nabble.com> Message-ID: You can press the floppy-disk icon in the figure window to bring up a save-file dialog. Ben Root On Fri, Sep 8, 2017 at 3:31 PM, cdpnepal wrote: > Is there a way to save interactive plot in matplotlib > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erdal2052 at gmail.com Sun Sep 10 03:20:15 2017 From: erdal2052 at gmail.com (erzdemir) Date: Sun, 10 Sep 2017 00:20:15 -0700 (MST) Subject: [Matplotlib-users] Ticks at fixed locations with uneven interval Message-ID: <1505028015776-0.post@n5.nabble.com> I would like to keep ticks at locations evenly spaced but keep their values uneven. Is it possible to do it in matplotlib. -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From pmhobson at gmail.com Sun Sep 10 11:38:27 2017 From: pmhobson at gmail.com (Paul Hobson) Date: Sun, 10 Sep 2017 08:38:27 -0700 Subject: [Matplotlib-users] Ticks at fixed locations with uneven interval In-Reply-To: <1505028015776-0.post@n5.nabble.com> References: <1505028015776-0.post@n5.nabble.com> Message-ID: You could do this as categorical (string) variables. Otherwise you might need to write your own scale. -Paul On Sun, Sep 10, 2017 at 12:20 AM, erzdemir wrote: > I would like to keep ticks at locations evenly spaced but keep their values > uneven. Is it possible to do it in matplotlib. > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users- > f3.html > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Wed Sep 13 16:58:04 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Wed, 13 Sep 2017 16:58:04 -0400 Subject: [Matplotlib-users] Ticks at fixed locations with uneven interval In-Reply-To: References: <1505028015776-0.post@n5.nabble.com> Message-ID: The tick labels and the tick locations are two separate things (but often conflated). By default, the tick label is the string representation of its location, but it doesn't have to be that. You can call `ax.set_xticklabels(['1', '20', '-5', 'foo'])`, assuming you know the number of ticks that will appear. Cheers! Ben Root On Sun, Sep 10, 2017 at 11:38 AM, Paul Hobson wrote: > You could do this as categorical (string) variables. > > Otherwise you might need to write your own scale. > -Paul > > On Sun, Sep 10, 2017 at 12:20 AM, erzdemir wrote: > >> I would like to keep ticks at locations evenly spaced but keep their >> values >> uneven. Is it possible to do it in matplotlib. >> >> >> >> -- >> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3. >> html >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > _______________________________________________ > 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 emlyn.je.price at gmail.com Wed Sep 13 18:17:01 2017 From: emlyn.je.price at gmail.com (Emlyn Price) Date: Wed, 13 Sep 2017 23:17:01 +0100 Subject: [Matplotlib-users] matplotlibrc prop_cycle error Message-ID: Hi, I have been trying to set up a custom color cycle in matplotlib using the matplotlibrc file. I have encountered a problem with the default matplotlibrc file provided with the installation from Arch llinux's package manager and the example provided in the online documentation at: https://matplotlib.org/users/customizing.html When the lines controlling the axes.prop_cycle are uncommented: axes.prop_cycle : cycler('color', ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', '9467bd', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf']) the following message is generated when I import matplotlib: /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #338 " ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', " in file "/home/ejp/mpl_test/matplotlibrc" warnings.warn('Illegal %s' % error_details) /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #339 " '9467bd', '8c564b', 'e377c2', '7f7f7f', " in file "/home/ejp/mpl_test/matplotlibrc" warnings.warn('Illegal %s' % error_details) /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #340 " 'bcbd22', '17becf']) " in file "/home/ejp/mpl_test/matplotlibrc" warnings.warn('Illegal %s' % error_details) /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1120: UserWarning: Bad val "cycler('color'," on line #337 "axes.prop_cycle : cycler('color', " in file "/home/ejp/mpl_test/matplotlibrc" Key axes.prop_cycle: 'cycler('color',' is not a valid cycler construction: unexpected EOF while parsing (, line 1) (val, error_details, msg)) The same error is generated if I import cycler using import cycler or from cycler import cycler I am using matplotlib 2.0.2 in python version 3.6.2 installed from the Arch Linux repositories. The ouput of uname -a is :Linux tinker 4.12.12-1-ARCH #1 SMP PREEMPT Sun Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux To reproduce: Copy the default matplotlibrc Uncomment the lines containing axes.prop_cycle : cycler('color', ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', '9467bd', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf']) Run python in the directory containing the matplotlibrc file Import matplotlib Am I missing something obvious? Thanks, Emlyn -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Wed Sep 13 21:27:29 2017 From: efiring at hawaii.edu (Eric Firing) Date: Wed, 13 Sep 2017 15:27:29 -1000 Subject: [Matplotlib-users] matplotlibrc prop_cycle error In-Reply-To: References: Message-ID: On 2017/09/13 12:17 PM, Emlyn Price wrote: > Hi, > > I have been trying to set up a custom color cycle in matplotlib using > the matplotlibrc file. I have encountered a problem with the default > matplotlibrc file provided with the installation from Arch llinux's > package manager and the example provided in the online documentation at: > https://matplotlib.org/users/customizing.html > > When the lines controlling the axes.prop_cycle are uncommented: > > axes.prop_cycle??? : cycler('color', > ??????????????????????????? ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > ????????????????????????????? '9467bd', '8c564b', 'e377c2', '7f7f7f', > ????????????????????????????? 'bcbd22', '17becf']) > > > the following message is generated when I import matplotlib: > > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: > UserWarning: Illegal line #338 > ??? "??????????????????????????? ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > " > ??? in file "/home/ejp/mpl_test/matplotlibrc" > ? warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: > UserWarning: Illegal line #339 > ??? "????????????????????????????? '9467bd', '8c564b', 'e377c2', '7f7f7f', > " > ??? in file "/home/ejp/mpl_test/matplotlibrc" > ? warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: > UserWarning: Illegal line #340 > ??? "????????????????????????????? 'bcbd22', '17becf']) > " > ??? in file "/home/ejp/mpl_test/matplotlibrc" > ? warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1120: > UserWarning: Bad val "cycler('color'," on line #337 > ??? "axes.prop_cycle??? : cycler('color', > " > ??? in file "/home/ejp/mpl_test/matplotlibrc" > ??? Key axes.prop_cycle: 'cycler('color',' is not a valid cycler > construction: unexpected EOF while parsing (, line 1) > ? (val, error_details, msg)) > > The same error is generated if I import cycler using > > import cycler > > or > > from cycler import cycler > > I am using matplotlib 2.0.2 in python version 3.6.2 installed from the > Arch Linux repositories. > The ouput of uname -a is :Linux tinker 4.12.12-1-ARCH #1 SMP PREEMPT Sun > Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux > > To reproduce: > > Copy the default matplotlibrc > Uncomment the lines containing > axes.prop_cycle??? : cycler('color', > ??????????????????????????? ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > ????????????????????????????? '9467bd', '8c564b', 'e377c2', '7f7f7f', > ????????????????????????????? 'bcbd22', '17becf']) > Run python in the directory containing the matplotlibrc file > Import matplotlib > > Am I missing something obvious? > Thanks, > Emlyn Emlyn, The matplotlibrc parser is not very smart; it is parsing each line independently, but our matplotlibrc.template is giving a commented-out example like what you show--with multiple lines to the entry. This is a bug. The workaround is to concatenate the lines so that the axes.prop_cycle entry is a single line. Thank you for the report, which I have copied to the issue tracker: https://github.com/matplotlib/matplotlib/issues/9184 Eric From selasley at icloud.com Wed Sep 13 21:08:34 2017 From: selasley at icloud.com (Scott Lasley) Date: Wed, 13 Sep 2017 21:08:34 -0400 Subject: [Matplotlib-users] matplotlibrc prop_cycle error In-Reply-To: References: Message-ID: <3164E4DD-1AAC-400B-89F4-AB62EBF7CF08@icloud.com> It works if you remove the line breaks and have the axes.prop_cycle on one line instead of multiple lines. axes.prop_cycle : cycler('color', ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', '9467bd', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf']) # color cycle for plot lines # as list of string colorspecs: # single letter, long name, or # web-style hex > On Sep 13, 2017, at 6:17 PM, Emlyn Price wrote: > > Hi, > > I have been trying to set up a custom color cycle in matplotlib using the matplotlibrc file. I have encountered a problem with the default matplotlibrc file provided with the installation from Arch llinux's package manager and the example provided in the online documentation at: https://matplotlib.org/users/customizing.html > > When the lines controlling the axes.prop_cycle are uncommented: > > axes.prop_cycle : cycler('color', > ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > '9467bd', '8c564b', 'e377c2', '7f7f7f', > 'bcbd22', '17becf']) > > > the following message is generated when I import matplotlib: > > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #338 > " ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > " > in file "/home/ejp/mpl_test/matplotlibrc" > warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #339 > " '9467bd', '8c564b', 'e377c2', '7f7f7f', > " > in file "/home/ejp/mpl_test/matplotlibrc" > warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: UserWarning: Illegal line #340 > " 'bcbd22', '17becf']) > " > in file "/home/ejp/mpl_test/matplotlibrc" > warnings.warn('Illegal %s' % error_details) > /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1120: UserWarning: Bad val "cycler('color'," on line #337 > "axes.prop_cycle : cycler('color', > " > in file "/home/ejp/mpl_test/matplotlibrc" > Key axes.prop_cycle: 'cycler('color',' is not a valid cycler construction: unexpected EOF while parsing (, line 1) > (val, error_details, msg)) > > The same error is generated if I import cycler using > > import cycler > > or > > from cycler import cycler > > I am using matplotlib 2.0.2 in python version 3.6.2 installed from the Arch Linux repositories. > The ouput of uname -a is :Linux tinker 4.12.12-1-ARCH #1 SMP PREEMPT Sun Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux > > To reproduce: > > Copy the default matplotlibrc > Uncomment the lines containing > axes.prop_cycle : cycler('color', > ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', > '9467bd', '8c564b', 'e377c2', '7f7f7f', > 'bcbd22', '17becf']) > Run python in the directory containing the matplotlibrc file > Import matplotlib > > Am I missing something obvious? > Thanks, > Emlyn > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From nunzio.losacco at uniroma2.it Wed Sep 20 10:06:07 2017 From: nunzio.losacco at uniroma2.it (Nunzio Losacco) Date: Wed, 20 Sep 2017 16:06:07 +0200 Subject: [Matplotlib-users] Understanding axes position Message-ID: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> Hi all, what I?m trying to do here is having third plot with its base aligned with the others and with reduced height (the final aim is custom positioning a colorbar). As you can see I?m getting the wrong position. What am I missing? Thanks for any help NL # -*- coding: utf-8 -*- from __future__ import unicode_literals import numpy as np from scipy.interpolate import griddata import matplotlib import matplotlib.pyplot as plt from matplotlib.patches import Circle from matplotlib.pylab import cm import matplotlib.colors as colors from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size matplotlib.rcParams.update({'font.size': 8}) fig = plt.figure() fig.set_size_inches(6.3,6.3) ax1 = plt.subplot(111) divider = make_axes_locatable(ax1) ax2 = divider.append_axes('right', size='100%', pad=0.3) axes = [ax1, ax2] ltypes = ['dashed', 'solid'] xi = np.linspace(-18.125, 18.125, 11) yi = np.linspace(0, 28, 9) xv, yv = np.meshgrid(xi, yi) xcOdd = 0.2 zcOdd = 0.725 xcEven = 0.6 zcEven = 0.725 maskRadius = 0.15 for i in range(2): ax = axes[i] ax.set_xlabel('distance [m]') if i == 0: ax.set_ylabel('depth [m]') if i == 1: ax.set_yticklabels([]) ax.invert_yaxis() ax.tick_params(direction='in') ax.set_aspect('equal') odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', fill=False) even = Circle((xcEven, zcEven), .15, linewidth=1.2, linestyle=ltypes[i], color='k', fill=False) vmax = 15. vmin = 0. norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) color_map = matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, 5)), "name") ax.add_patch(odd) ax.add_patch(even) pad = 0.03 width = 0.03 pos = ax2.get_position() ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, 0.7*(pos.ymax-pos.ymin) ]) plt.savefig('prova-vect-paper-test-2.eps', format='eps') From vincent.adrien at gmail.com Wed Sep 20 13:03:01 2017 From: vincent.adrien at gmail.com (Adrien VINCENT) Date: Wed, 20 Sep 2017 10:03:01 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> Message-ID: <2A9FCAB6-1320-4175-8337-FF6EF75D77BE@gmail.com> Hi Nunzio, Quick comment because I do not have much time unfortunately : did you think about using Gridspec (there is a nice tutorial on the Matplotlib website). You may have to set one extra axes instance to "not visible" but overall it may be easier. Playing a bit with your code, I cannot tell why but when printing `pos` and `ax2.get_position()`, I do not get the same thing, which puzzles me. Maybe somebody else will know why. Regards, Adrien On September 20, 2017 7:06:07 AM PDT, Nunzio Losacco wrote: >Hi all, > >what I?m trying to do here is having third plot with its base aligned >with the others and with reduced height (the final aim is custom >positioning a colorbar). >As you can see I?m getting the wrong position. What am I missing? > >Thanks for any help > >NL > ># -*- coding: utf-8 -*- > >from __future__ import unicode_literals >import numpy as np >from scipy.interpolate import griddata >import matplotlib >import matplotlib.pyplot as plt >from matplotlib.patches import Circle >from matplotlib.pylab import cm >import matplotlib.colors as colors >from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size > >matplotlib.rcParams.update({'font.size': 8}) > >fig = plt.figure() >fig.set_size_inches(6.3,6.3) > >ax1 = plt.subplot(111) >divider = make_axes_locatable(ax1) >ax2 = divider.append_axes('right', size='100%', pad=0.3) > >axes = [ax1, ax2] >ltypes = ['dashed', 'solid'] > >xi = np.linspace(-18.125, 18.125, 11) >yi = np.linspace(0, 28, 9) >xv, yv = np.meshgrid(xi, yi) > >xcOdd = 0.2 >zcOdd = 0.725 >xcEven = 0.6 >zcEven = 0.725 > >maskRadius = 0.15 > >for i in range(2): > ax = axes[i] > ax.set_xlabel('distance [m]') > if i == 0: > ax.set_ylabel('depth [m]') > if i == 1: > ax.set_yticklabels([]) > ax.invert_yaxis() > ax.tick_params(direction='in') > ax.set_aspect('equal') >odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', fill=False) >even = Circle((xcEven, zcEven), .15, linewidth=1.2, >linestyle=ltypes[i], color='k', fill=False) > > vmax = 15. > vmin = 0. > norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) > >color_map = >matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, 5)), >"name") > > ax.add_patch(odd) > ax.add_patch(even) > >pad = 0.03 >width = 0.03 > >pos = ax2.get_position() > >ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, >0.7*(pos.ymax-pos.ymin) ]) > >plt.savefig('prova-vect-paper-test-2.eps', format='eps') > >_______________________________________________ >Matplotlib-users mailing list >Matplotlib-users at python.org >https://mail.python.org/mailman/listinfo/matplotlib-users -- Envoy? de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma bri?vet?. From jklymak at uvic.ca Wed Sep 20 14:07:38 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Wed, 20 Sep 2017 11:07:38 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> Message-ID: <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> Hi Nunzio, The issue is that you call `ax.set_aspect(?equal?)`, and that changes the axes box. However, `ax.get_position` returns the `frozen` position, i.e. the old position. I don?t see a method to return the new position (and I wonder why `get_position` behaves this way). As a work around, you can get the aspect-ratio changed position as: ```python figW, figH = fig.get_size_inches() fig_aspect = figH / figW newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), pp, fig_aspect).anchored(ax.get_anchor(), pp)) ``` which I appreciate is a bit of a pain?. Cheers, Jody On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: > Hi all, > > what I?m trying to do here is having third plot with its base > aligned with the others and with reduced height (the final aim is > custom positioning a colorbar). > As you can see I?m getting the wrong position. What am I missing? > > Thanks for any help > > NL > > # -*- coding: utf-8 -*- > > from __future__ import unicode_literals > import numpy as np > from scipy.interpolate import griddata > import matplotlib > import matplotlib.pyplot as plt > from matplotlib.patches import Circle > from matplotlib.pylab import cm > import matplotlib.colors as colors > from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size > > matplotlib.rcParams.update({'font.size': 8}) > > fig = plt.figure() > fig.set_size_inches(6.3,6.3) > > ax1 = plt.subplot(111) > divider = make_axes_locatable(ax1) > ax2 = divider.append_axes('right', size='100%', pad=0.3) > > axes = [ax1, ax2] > ltypes = ['dashed', 'solid'] > > xi = np.linspace(-18.125, 18.125, 11) > yi = np.linspace(0, 28, 9) > xv, yv = np.meshgrid(xi, yi) > > xcOdd = 0.2 > zcOdd = 0.725 > xcEven = 0.6 > zcEven = 0.725 > > maskRadius = 0.15 > > for i in range(2): > ax = axes[i] > ax.set_xlabel('distance [m]') > if i == 0: > ax.set_ylabel('depth [m]') > if i == 1: > ax.set_yticklabels([]) > ax.invert_yaxis() > ax.tick_params(direction='in') > ax.set_aspect('equal') > odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', > fill=False) > even = Circle((xcEven, zcEven), .15, linewidth=1.2, > linestyle=ltypes[i], color='k', fill=False) > > vmax = 15. > vmin = 0. > norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) > > color_map = > matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, > 5)), "name") > > ax.add_patch(odd) > ax.add_patch(even) > > pad = 0.03 > width = 0.03 > > pos = ax2.get_position() > > ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, > 0.7*(pos.ymax-pos.ymin) ]) > > plt.savefig('prova-vect-paper-test-2.eps', format='eps') > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From jklymak at uvic.ca Wed Sep 20 14:32:11 2017 From: jklymak at uvic.ca (Klymak Jody) Date: Wed, 20 Sep 2017 11:32:11 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> Message-ID: Oops. Just realized you can also just do Pos =ax._postion To get the current position. Of course this could break because you are accessing a private variable. Cheers. Jody Sent from my iPhone > On Sep 20, 2017, at 11:07, Jody Klymak wrote: > > Hi Nunzio, > > The issue is that you call ax.set_aspect(?equal?), and that changes the axes box. However, ax.get_position returns the frozen position, i.e. the old position. I don?t see a method to return the new position (and I wonder why get_position behaves this way). > > As a work around, you can get the aspect-ratio changed position as: > > figW, figH = fig.get_size_inches() > fig_aspect = figH / figW > newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), pp, fig_aspect).anchored(ax.get_anchor(), pp)) > which I appreciate is a bit of a pain?. > > Cheers, Jody > > On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: > > Hi all, > > what I?m trying to do here is having third plot with its base aligned with the others and with reduced height (the final aim is custom positioning a colorbar). > As you can see I?m getting the wrong position. What am I missing? > > Thanks for any help > > NL > > # -*- coding: utf-8 -*- > > from __future__ import unicode_literals > import numpy as np > from scipy.interpolate import griddata > import matplotlib > import matplotlib.pyplot as plt > from matplotlib.patches import Circle > from matplotlib.pylab import cm > import matplotlib.colors as colors > from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size > > matplotlib.rcParams.update({'font.size': 8}) > > fig = plt.figure() > fig.set_size_inches(6.3,6.3) > > ax1 = plt.subplot(111) > divider = make_axes_locatable(ax1) > ax2 = divider.append_axes('right', size='100%', pad=0.3) > > axes = [ax1, ax2] > ltypes = ['dashed', 'solid'] > > xi = np.linspace(-18.125, 18.125, 11) > yi = np.linspace(0, 28, 9) > xv, yv = np.meshgrid(xi, yi) > > xcOdd = 0.2 > zcOdd = 0.725 > xcEven = 0.6 > zcEven = 0.725 > > maskRadius = 0.15 > > for i in range(2): > ax = axes[i] > ax.set_xlabel('distance [m]') > if i == 0: > ax.set_ylabel('depth [m]') > if i == 1: > ax.set_yticklabels([]) > ax.invert_yaxis() > ax.tick_params(direction='in') > ax.set_aspect('equal') > odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', fill=False) > even = Circle((xcEven, zcEven), .15, linewidth=1.2, linestyle=ltypes[i], color='k', fill=False) > > vmax = 15. > vmin = 0. > norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) > > color_map = matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, 5)), "name") > > ax.add_patch(odd) > ax.add_patch(even) > > pad = 0.03 > width = 0.03 > > pos = ax2.get_position() > > ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, 0.7*(pos.ymax-pos.ymin) ]) > > plt.savefig('prova-vect-paper-test-2.eps', format='eps') > > _______________________________________________ > 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 jklymak at uvic.ca Wed Sep 20 15:30:01 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Wed, 20 Sep 2017 12:30:01 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> Message-ID: <14E40CAB-BFFE-4565-957D-8586D113C761@uvic.ca> On 20 Sep 2017, at 11:32, Klymak Jody wrote: > Oops. Just realized you can also just do > > Pos =ax._postion > > To get the current position. Of course this could break because you > are accessing a private variable. oops again, no you can?t, you need to use the formula below. The reason is that `apply_aspect` doesn?t get called until the axes is drawn, so the new `_position` isn?t set until then. Sorry, I should have checked before I wrote?. Cheers, Jody > > Cheers. Jody > > Sent from my iPhone > >> On Sep 20, 2017, at 11:07, Jody Klymak wrote: >> >> Hi Nunzio, >> >> The issue is that you call ax.set_aspect(?equal?), and that >> changes the axes box. However, ax.get_position returns the frozen >> position, i.e. the old position. I don?t see a method to return the >> new position (and I wonder why get_position behaves this way). >> >> As a work around, you can get the aspect-ratio changed position as: >> >> figW, figH = fig.get_size_inches() >> fig_aspect = figH / figW >> newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), >> pp, fig_aspect).anchored(ax.get_anchor(), pp)) >> which I appreciate is a bit of a pain?. >> >> Cheers, Jody >> >> On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: >> >> Hi all, >> >> what I?m trying to do here is having third plot with its base >> aligned with the others and with reduced height (the final aim is >> custom positioning a colorbar). >> As you can see I?m getting the wrong position. What am I missing? >> >> Thanks for any help >> >> NL >> >> # -*- coding: utf-8 -*- >> >> from __future__ import unicode_literals >> import numpy as np >> from scipy.interpolate import griddata >> import matplotlib >> import matplotlib.pyplot as plt >> from matplotlib.patches import Circle >> from matplotlib.pylab import cm >> import matplotlib.colors as colors >> from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size >> >> matplotlib.rcParams.update({'font.size': 8}) >> >> fig = plt.figure() >> fig.set_size_inches(6.3,6.3) >> >> ax1 = plt.subplot(111) >> divider = make_axes_locatable(ax1) >> ax2 = divider.append_axes('right', size='100%', pad=0.3) >> >> axes = [ax1, ax2] >> ltypes = ['dashed', 'solid'] >> >> xi = np.linspace(-18.125, 18.125, 11) >> yi = np.linspace(0, 28, 9) >> xv, yv = np.meshgrid(xi, yi) >> >> xcOdd = 0.2 >> zcOdd = 0.725 >> xcEven = 0.6 >> zcEven = 0.725 >> >> maskRadius = 0.15 >> >> for i in range(2): >> ax = axes[i] >> ax.set_xlabel('distance [m]') >> if i == 0: >> ax.set_ylabel('depth [m]') >> if i == 1: >> ax.set_yticklabels([]) >> ax.invert_yaxis() >> ax.tick_params(direction='in') >> ax.set_aspect('equal') >> odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', >> fill=False) >> even = Circle((xcEven, zcEven), .15, linewidth=1.2, >> linestyle=ltypes[i], color='k', fill=False) >> >> vmax = 15. >> vmin = 0. >> norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) >> >> color_map = >> matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, >> 5)), "name") >> >> ax.add_patch(odd) >> ax.add_patch(even) >> >> pad = 0.03 >> width = 0.03 >> >> pos = ax2.get_position() >> >> ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, >> 0.7*(pos.ymax-pos.ymin) ]) >> >> plt.savefig('prova-vect-paper-test-2.eps', format='eps') >> >> _______________________________________________ >> 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 jklymak at uvic.ca Wed Sep 20 15:57:35 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Wed, 20 Sep 2017 12:57:35 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <14E40CAB-BFFE-4565-957D-8586D113C761@uvic.ca> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> <14E40CAB-BFFE-4565-957D-8586D113C761@uvic.ca> Message-ID: <208E344D-6F1B-45BC-8EAF-004257C45701@uvic.ca> As pointed out by Eric Firing ([here](https://github.com/matplotlib/matplotlib/issues/9207)) you can also do: ```python ax.set_aspect(1.) ax.apply_aspect() pos = ax.get_position(original=False) ``` Cheers, Jody On 20 Sep 2017, at 12:30, Jody Klymak wrote: > On 20 Sep 2017, at 11:32, Klymak Jody wrote: > >> Oops. Just realized you can also just do >> >> Pos =ax._postion >> >> To get the current position. Of course this could break because you >> are accessing a private variable. > > oops again, no you can?t, you need to use the formula below. The > reason is that `apply_aspect` doesn?t get called until the axes is > drawn, so the new `_position` isn?t set until then. > > Sorry, I should have checked before I wrote?. > > Cheers, Jody > > > >> >> Cheers. Jody >> >> Sent from my iPhone >> >>> On Sep 20, 2017, at 11:07, Jody Klymak wrote: >>> >>> Hi Nunzio, >>> >>> The issue is that you call ax.set_aspect(?equal?), and that >>> changes the axes box. However, ax.get_position returns the frozen >>> position, i.e. the old position. I don?t see a method to return >>> the new position (and I wonder why get_position behaves this way). >>> >>> As a work around, you can get the aspect-ratio changed position as: >>> >>> figW, figH = fig.get_size_inches() >>> fig_aspect = figH / figW >>> newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), >>> pp, fig_aspect).anchored(ax.get_anchor(), pp)) >>> which I appreciate is a bit of a pain?. >>> >>> Cheers, Jody >>> >>> On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: >>> >>> Hi all, >>> >>> what I?m trying to do here is having third plot with its base >>> aligned with the others and with reduced height (the final aim is >>> custom positioning a colorbar). >>> As you can see I?m getting the wrong position. What am I missing? >>> >>> Thanks for any help >>> >>> NL >>> >>> # -*- coding: utf-8 -*- >>> >>> from __future__ import unicode_literals >>> import numpy as np >>> from scipy.interpolate import griddata >>> import matplotlib >>> import matplotlib.pyplot as plt >>> from matplotlib.patches import Circle >>> from matplotlib.pylab import cm >>> import matplotlib.colors as colors >>> from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size >>> >>> matplotlib.rcParams.update({'font.size': 8}) >>> >>> fig = plt.figure() >>> fig.set_size_inches(6.3,6.3) >>> >>> ax1 = plt.subplot(111) >>> divider = make_axes_locatable(ax1) >>> ax2 = divider.append_axes('right', size='100%', pad=0.3) >>> >>> axes = [ax1, ax2] >>> ltypes = ['dashed', 'solid'] >>> >>> xi = np.linspace(-18.125, 18.125, 11) >>> yi = np.linspace(0, 28, 9) >>> xv, yv = np.meshgrid(xi, yi) >>> >>> xcOdd = 0.2 >>> zcOdd = 0.725 >>> xcEven = 0.6 >>> zcEven = 0.725 >>> >>> maskRadius = 0.15 >>> >>> for i in range(2): >>> ax = axes[i] >>> ax.set_xlabel('distance [m]') >>> if i == 0: >>> ax.set_ylabel('depth [m]') >>> if i == 1: >>> ax.set_yticklabels([]) >>> ax.invert_yaxis() >>> ax.tick_params(direction='in') >>> ax.set_aspect('equal') >>> odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', >>> fill=False) >>> even = Circle((xcEven, zcEven), .15, linewidth=1.2, >>> linestyle=ltypes[i], color='k', fill=False) >>> >>> vmax = 15. >>> vmin = 0. >>> norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) >>> >>> color_map = >>> matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, >>> 5)), "name") >>> >>> ax.add_patch(odd) >>> ax.add_patch(even) >>> >>> pad = 0.03 >>> width = 0.03 >>> >>> pos = ax2.get_position() >>> >>> ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, >>> 0.7*(pos.ymax-pos.ymin) ]) >>> >>> plt.savefig('prova-vect-paper-test-2.eps', format='eps') >>> >>> _______________________________________________ >>> 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 nunzio.losacco at uniroma2.it Wed Sep 20 17:23:36 2017 From: nunzio.losacco at uniroma2.it (Nunzio Losacco) Date: Wed, 20 Sep 2017 23:23:36 +0200 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <208E344D-6F1B-45BC-8EAF-004257C45701@uvic.ca> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> <14E40CAB-BFFE-4565-957D-8586D113C761@uvic.ca> <208E344D-6F1B-45BC-8EAF-004257C45701@uvic.ca> Message-ID: <0B8274A6-6738-48EE-931F-D7FCA385ED1A@uniroma2.it> Thank you so much for your help, in fact, as `ax.set_aspect(?equal?)` changes the bounding box at drawing time, others pointed out here that I should do: ```python fig.canvas.draw() ``` before getting the position of the axes. I assume that ```python ax.apply_aspect() ``` does the same. I also found out that this does not work properly with the default MacOSX backend on a Mac, with TkAgg produces a slight offset of the new axis wrt the desird position, but only in the interactive window, with the qt5Agg backend it gives correct results both in the interactive window and in the output file. Best, Nunzio > On 20 Sep 2017, at 21:57, Jody Klymak wrote: > > As pointed out by Eric Firing (here ) you can also do: > > ax.set_aspect(1.) > ax.apply_aspect() > pos = ax.get_position(original=False) > Cheers, Jody > > On 20 Sep 2017, at 12:30, Jody Klymak wrote: > > > On 20 Sep 2017, at 11:32, Klymak Jody wrote: > > > Oops. Just realized you can also just do > > Pos =ax._postion > > To get the current position. Of course this could break because you are accessing a private variable. > > oops again, no you can?t, you need to use the formula below. The reason is that apply_aspect doesn?t get called until the axes is drawn, so the new _position isn?t set until then. > > Sorry, I should have checked before I wrote?. > > Cheers, Jody > > > Cheers. Jody > > Sent from my iPhone > On Sep 20, 2017, at 11:07, Jody Klymak wrote: > > Hi Nunzio, > > The issue is that you call ax.set_aspect(?equal?), and that changes the axes box. However, ax.get_position returns the frozen position, i.e. the old position. I don?t see a method to return the new position (and I wonder why get_position behaves this way). > > As a work around, you can get the aspect-ratio changed position as: > > figW, figH = fig.get_size_inches() > fig_aspect = figH / figW > newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), pp, fig_aspect).anchored(ax.get_anchor(), pp)) > which I appreciate is a bit of a pain?. > > Cheers, Jody > > On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: > > Hi all, > > what I?m trying to do here is having third plot with its base aligned with the others and with reduced height (the final aim is custom positioning a colorbar). > As you can see I?m getting the wrong position. What am I missing? > > Thanks for any help > > NL > > # -*- coding: utf-8 -*- > > from __future__ import unicode_literals > import numpy as np > from scipy.interpolate import griddata > import matplotlib > import matplotlib.pyplot as plt > from matplotlib.patches import Circle > from matplotlib.pylab import cm > import matplotlib.colors as colors > from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size > > matplotlib.rcParams.update({'font.size': 8}) > > fig = plt.figure() > fig.set_size_inches(6.3,6.3) > > ax1 = plt.subplot(111) > divider = make_axes_locatable(ax1) > ax2 = divider.append_axes('right', size='100%', pad=0.3) > > axes = [ax1, ax2] > ltypes = ['dashed', 'solid'] > > xi = np.linspace(-18.125, 18.125, 11) > yi = np.linspace(0, 28, 9) > xv, yv = np.meshgrid(xi, yi) > > xcOdd = 0.2 > zcOdd = 0.725 > xcEven = 0.6 > zcEven = 0.725 > > maskRadius = 0.15 > > for i in range(2): > ax = axes[i] > ax.set_xlabel('distance [m]') > if i == 0: > ax.set_ylabel('depth [m]') > if i == 1: > ax.set_yticklabels([]) > ax.invert_yaxis() > ax.tick_params(direction='in') > ax.set_aspect('equal') > odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', fill=False) > even = Circle((xcEven, zcEven), .15, linewidth=1.2, linestyle=ltypes[i], color='k', fill=False) > > vmax = 15. > vmin = 0. > norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) > > color_map = matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, 5)), "name") > > ax.add_patch(odd) > ax.add_patch(even) > > pad = 0.03 > width = 0.03 > > pos = ax2.get_position() > > ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, 0.7*(pos.ymax-pos.ymin) ]) > > plt.savefig('prova-vect-paper-test-2.eps', format='eps') > > _______________________________________________ > 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 jklymak at uvic.ca Wed Sep 20 17:42:28 2017 From: jklymak at uvic.ca (Jody Klymak) Date: Wed, 20 Sep 2017 14:42:28 -0700 Subject: [Matplotlib-users] Understanding axes position In-Reply-To: <0B8274A6-6738-48EE-931F-D7FCA385ED1A@uniroma2.it> References: <288EA973-BFE8-4C9D-AA32-3808CE6F3CAD@uniroma2.it> <18B94A60-7A04-4FE7-8505-5B6C672EDAD3@uvic.ca> <14E40CAB-BFFE-4565-957D-8586D113C761@uvic.ca> <208E344D-6F1B-45BC-8EAF-004257C45701@uvic.ca> <0B8274A6-6738-48EE-931F-D7FCA385ED1A@uniroma2.it> Message-ID: <5C6BCD10-0BEC-480D-A0D6-25C2BB5B19F7@uvic.ca> This is something funky in `append_axes` and `make_axes_locatable`. If you instead just use subplots it behaves OK on OSX. Not sure if you have a good reason for using `append_axes`. ``` fig, axes = plt.subplots(1, 2, figsize=(6.3, 6.3)) ax1 = axes[0] ax2 = axes[1] ``` Cheers, Jody On 20 Sep 2017, at 14:23, Nunzio Losacco wrote: > Thank you so much for your help, > > in fact, as `ax.set_aspect(?equal?)` changes the bounding box at > drawing time, others pointed out here > > that I should do: > > ```python > fig.canvas.draw() > ``` > before getting the position of the axes. I assume that > > ```python > ax.apply_aspect() > ``` > does the same. > > I also found out that this does not work properly with the default > MacOSX backend on a Mac, > with TkAgg produces a slight offset of the new axis wrt the desird > position, but only in the interactive window, > with the qt5Agg backend it gives correct results both in the > interactive window and in the output file. > > Best, > > Nunzio > >> On 20 Sep 2017, at 21:57, Jody Klymak wrote: >> >> As pointed out by Eric Firing (here >> ) you can also >> do: >> >> ax.set_aspect(1.) >> ax.apply_aspect() >> pos = ax.get_position(original=False) >> Cheers, Jody >> >> On 20 Sep 2017, at 12:30, Jody Klymak wrote: >> >> >> On 20 Sep 2017, at 11:32, Klymak Jody wrote: >> >> >> Oops. Just realized you can also just do >> >> Pos =ax._postion >> >> To get the current position. Of course this could break because you >> are accessing a private variable. >> >> oops again, no you can?t, you need to use the formula below. The >> reason is that apply_aspect doesn?t get called until the axes is >> drawn, so the new _position isn?t set until then. >> >> Sorry, I should have checked before I wrote?. >> >> Cheers, Jody >> >> >> Cheers. Jody >> >> Sent from my iPhone >> On Sep 20, 2017, at 11:07, Jody Klymak wrote: >> >> Hi Nunzio, >> >> The issue is that you call ax.set_aspect(?equal?), and that >> changes the axes box. However, ax.get_position returns the frozen >> position, i.e. the old position. I don?t see a method to return the >> new position (and I wonder why get_position behaves this way). >> >> As a work around, you can get the aspect-ratio changed position as: >> >> figW, figH = fig.get_size_inches() >> fig_aspect = figH / figW >> newpos = pp.shrunk_to_aspect(ax.get_aspect() * ax.get_data_ratio(), >> pp, fig_aspect).anchored(ax.get_anchor(), pp)) >> which I appreciate is a bit of a pain?. >> >> Cheers, Jody >> >> On 20 Sep 2017, at 7:06, Nunzio Losacco wrote: >> >> Hi all, >> >> what I?m trying to do here is having third plot with its base >> aligned with the others and with reduced height (the final aim is >> custom positioning a colorbar). >> As you can see I?m getting the wrong position. What am I missing? >> >> Thanks for any help >> >> NL >> >> # -*- coding: utf-8 -*- >> >> from __future__ import unicode_literals >> import numpy as np >> from scipy.interpolate import griddata >> import matplotlib >> import matplotlib.pyplot as plt >> from matplotlib.patches import Circle >> from matplotlib.pylab import cm >> import matplotlib.colors as colors >> from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size >> >> matplotlib.rcParams.update({'font.size': 8}) >> >> fig = plt.figure() >> fig.set_size_inches(6.3,6.3) >> >> ax1 = plt.subplot(111) >> divider = make_axes_locatable(ax1) >> ax2 = divider.append_axes('right', size='100%', pad=0.3) >> >> axes = [ax1, ax2] >> ltypes = ['dashed', 'solid'] >> >> xi = np.linspace(-18.125, 18.125, 11) >> yi = np.linspace(0, 28, 9) >> xv, yv = np.meshgrid(xi, yi) >> >> xcOdd = 0.2 >> zcOdd = 0.725 >> xcEven = 0.6 >> zcEven = 0.725 >> >> maskRadius = 0.15 >> >> for i in range(2): >> ax = axes[i] >> ax.set_xlabel('distance [m]') >> if i == 0: >> ax.set_ylabel('depth [m]') >> if i == 1: >> ax.set_yticklabels([]) >> ax.invert_yaxis() >> ax.tick_params(direction='in') >> ax.set_aspect('equal') >> odd = Circle((xcOdd, zcOdd), .15, linewidth=1.2, color='k', >> fill=False) >> even = Circle((xcEven, zcEven), .15, linewidth=1.2, >> linestyle=ltypes[i], color='k', fill=False) >> >> vmax = 15. >> vmin = 0. >> norm = matplotlib.colors.Normalize(vmin,vmax, clip=False) >> >> color_map = >> matplotlib.colors.ListedColormap(plt.cm.Greys(np.linspace(0.25, 1, >> 5)), "name") >> >> ax.add_patch(odd) >> ax.add_patch(even) >> >> pad = 0.03 >> width = 0.03 >> >> pos = ax2.get_position() >> >> ax3 = fig.add_axes([pos.xmax + pad, pos.ymin, width, >> 0.7*(pos.ymax-pos.ymin) ]) >> >> plt.savefig('prova-vect-paper-test-2.eps', format='eps') >> >> _______________________________________________ >> 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 jni.soma at gmail.com Thu Sep 21 01:01:53 2017 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Thu, 21 Sep 2017 15:01:53 +1000 Subject: [Matplotlib-users] Window flickering with Tk backend (was: Subplot x-axis shared with other subplots y-axis) In-Reply-To: References: <85a1d34b-065e-4cc5-9f9c-f68c796c2802@Spark> Message-ID: <01bb9415-4bff-4efa-a74f-9b8ed75d9ca7@Spark> Oops, revisiting this thread now, it looks like I only replied to Ben, instead of the list. Full thread below, but TL;DR: my 3D orthogonal views project: https://github.com/jni/mpl-volume-viewer is working (thanks to all on this list who helped so far!), but has the following problems: - Experiences flickering when panning in the Tk backend - Has no flickering with the MacOS backend, but then the keyboard bindings don?t work at all - Is dog-slow in the nbagg backend. Any suggestions to help with this would be much appreciated! To recap, here are the steps to reproduce: - Download slice_view.py and put it in your PYTHONPATH or current working directory - Download this example dataset: https://www.dropbox.com/s/dj3oarx7bqx4us2/E_z2_512_1um_CONTROL.tif?dl=1 - Run this code: import matplotlib matplotlib.use('TkAgg?) ?# change this to whatever you want to test from skimage import io import slice_view as sv filename = '/path/to/E_z2_512_1um_CONTROL.tif' image = io.imread(filename) / 4096 v = sv.SliceViewer(image, spacing=[5, 1, 1]) matplotlib.pyplot.show(block=True) Thanks! Juan. ---------- Forwarded message ---------- From: Juan Nunez-Iglesias Date: 11 Jul 2017, 12:06 PM +1000 To: Benjamin Root Subject: Re: [Matplotlib-users] Subplot x-axis shared with other subplots y-axis > Hi Ben, thanks for the tip! The point of using the ToolManager would be to get cross-backend support, so it might be easier for me to implement the backends I want with if-else statements, or some other kludgey way? > > I just thought I?d update the list with the status of my orthogonal views mini-project, which is backend-dependent: > > - working on Tk except for the flickering > - working on macOS except the keyboard bindings don?t work ? they go straight to the Terminal. > - working on Notebook (Nbagg?), except it?s dog-slow. > > If anyone has suggestions for any of these problems, I would be very grateful! > > Juan. > > On 28 Jun 2017, 1:08 AM +1000, Benjamin Root , wrote: > > re: cross-backend way to add buttons: There is experimental feature called "ToolManager", but I think it is only implemented for a couple of backends currently. You can see an example here: > > > > http://matplotlib.org/examples/user_interfaces/toolmanager.html > > > > > On Fri, Jun 23, 2017 at 12:17 AM, Juan Nunez-Iglesias wrote: > > > > Hey Tom, > > > > > > > > Thanks for that response, it was just what I needed! I had a fun infinite loop where the x-axis was updating the y-axis which was updating the x-axis which... =P But it was easy enough to sort out. =) > > > > > > > > I have a working orthogonal slice viewer here: > > > > https://github.com/jni/mpl-volume-viewer/ > > > > > > > > The problem I have now is that, if I set a mouse-click callback (this line and this line), and then I select any other tool from the toolbar, I get this super-obnoxious flickering, recorded here (macOS 10.12, Tk backend): > > > > https://www.dropbox.com/s/qvfmgp0x36p6rb9/mpl-click-bug.mov?dl=0 > > > > > > > > To reproduce: > > > > > > > > - Download slice_view.py and put it in your PYTHONPATH or current working directory > > > > - Download this example dataset: > > > > https://www.dropbox.com/s/dj3oarx7bqx4us2/E_z2_512_1um_CONTROL.tif?dl=1 > > > > - Run this code: > > > > > > > > import matplotlib > > > > matplotlib.use('TkAgg') > > > > > > > > from skimage import io > > > > import slice_view as sv > > > > > > > > filename = '/path/to/E_z2_512_1um_CONTROL.tif' > > > > image = io.imread(filename) / 4096 > > > > > > > > v = sv.SliceViewer(image, spacing=[5, 1, 1]) > > > > matplotlib.pyplot.show(block=True) > > > > > > > > Questions: > > > > 1) Any ideas about how to fix the flickering? > > > > 2) Is there a cross-backend way to add buttons to the toolbar? All the examples I've found online were backend-specific. (This way I could at least disable the callback at will.) > > > > > > > > Thanks! > > > > > > > > Juan. > > > > > > > > On 16 May 2017, 1:43 AM +1000, Thomas Caswell , wrote: > > > > > There are callbacks that fire when the limits are changed.? See > > > > > > > > > > https://matplotlib.org/examples/event_handling/viewlims.html > > > > > > > > > > for an example. > > > > > > > > > > This is probably the best route to go down as you can do other interesting things as the event goes by (like triggering computation, updating a openGL view window, etc) as well as updating the Matplotlib limits. > > > > > > > > > > Tom > > > > > > > > > > > On Mon, May 15, 2017 at 3:29 AM Juan Nunez-Iglesias wrote: > > > > > > > Hello, > > > > > > > > > > > > > > I?m trying to build an orthogonal-views volume viewer in Matplotlib like this one: > > > > > > > https://imagej.nih.gov/ij/docs/guide/images/OrthogonalViews.png > > > > > > > > > > > > > > For this to work, I need to share the y-axis of the YZ (right) view/subplot with the x-axis of the XZ (bottom) view/subplot. Is this possible? > > > > > > > > > > > > > > Juan. > > > > > > > > > > > > > > _______________________________________________ > > > > > > > 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 wrw at mac.com Tue Sep 26 17:04:36 2017 From: wrw at mac.com (William Ray Wing) Date: Tue, 26 Sep 2017 17:04:36 -0400 Subject: [Matplotlib-users] Problem doing multiple independent plots Message-ID: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> Below is a simplified version of a much more elaborate analysis code, but it will illustrate the problem I?m having. What I want to do is repetitively call an analysis function from my main code and plot the results of that analysis (a curve fit, although thats immaterial here) while in that function. Back in the main code, I want to plot the results of all the curve fits on a single plot. They share a common x axis, but appear at different points along it. What seems to be happening is that the gets set in the function, and doesn?t get set back in the main code. Note that there are two versions of the ?problem? function, problem and problem_alt. If you change the main code (move the #), you get the plot I want at the end of the main. There must be something I can call or set to recover the settings associated with figure(2), but I can?t seem to figure it out. Any help would be appreciated. Thanks, Bill Wing #! /usr/bin/env python # -*- coding: utf-8 -*- # # A simple skeleton of the program to work out the plotting problem # import numpy as np, matplotlib.pyplot as plt # # skeleton subroutines # def problem(xdata, ydata, i): color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} plt.figure(1) fig1, ax1 = plt.subplots() plt.subplot() plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) plt.savefig('Plot for run_num ' + str(i)) return def problem_alt(xdata, ydata, i): return t = np.arange(0.0, 2.0, 0.01) plt.figure(2) fig2, ax2 = plt.subplots() for i in range(0,4): i = i+1 problem(t, np.sin(i*np.pi*3*t), i) problem_alt(t, np.sin(i*np.pi*3*t), i) ax2.set_xlim(xmin = 0.0, xmax = 20.0) plt.subplot() plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) plt.savefig("Global Plot") From rmay31 at gmail.com Tue Sep 26 18:20:08 2017 From: rmay31 at gmail.com (Ryan May) Date: Tue, 26 Sep 2017 16:20:08 -0600 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> Message-ID: William, Don't use plt to call all of the methods, but directly use them off of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: import numpy as np, matplotlib.pyplot as plt def problem(xdata, ydata, i): color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} fig1, ax1 = plt.subplots() ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) fig1.savefig('Plot for run_num ' + str(i)) return def problem_alt(xdata, ydata, i): return t = np.arange(0.0, 2.0, 0.01) fig2, ax2 = plt.subplots() for i in range(0,4): i = i+1 problem(t, np.sin(i*np.pi*3*t), i) problem_alt(t, np.sin(i*np.pi*3*t), i) ax2.set_xlim(xmin = 0.0, xmax = 20.0) ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) fig2.savefig("Global Plot") At least, I think that's what you're going for. Note I removed some extra calls to figure() and subplot() that I don't think were helping you. Ryan On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing wrote: > Below is a simplified version of a much more elaborate analysis code, but > it will illustrate the problem I?m having. What I want to do is > repetitively call an analysis function from my main code and plot the > results of that analysis (a curve fit, although thats immaterial here) > while in that function. Back in the main code, I want to plot the results > of all the curve fits on a single plot. They share a common x axis, but > appear at different points along it. What seems to be happening is that > the gets set in the function, and doesn?t get set back in the main code. > > Note that there are two versions of the ?problem? function, problem and > problem_alt. If you change the main code (move the #), you get the plot I > want at the end of the main. > > There must be something I can call or set to recover the settings > associated with figure(2), but I can?t seem to figure it out. Any help > would be appreciated. > > Thanks, > Bill Wing > > #! /usr/bin/env python > # -*- coding: utf-8 -*- > # > # A simple skeleton of the program to work out the plotting problem > # > import numpy as np, matplotlib.pyplot as plt > # > # skeleton subroutines > # > > def problem(xdata, ydata, i): > color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} > plt.figure(1) > fig1, ax1 = plt.subplots() > plt.subplot() > plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) > plt.savefig('Plot for run_num ' + str(i)) > return > > def problem_alt(xdata, ydata, i): > return > > > t = np.arange(0.0, 2.0, 0.01) > plt.figure(2) > fig2, ax2 = plt.subplots() > > for i in range(0,4): > i = i+1 > problem(t, np.sin(i*np.pi*3*t), i) > problem_alt(t, np.sin(i*np.pi*3*t), i) > ax2.set_xlim(xmin = 0.0, xmax = 20.0) > plt.subplot() > plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) > > plt.savefig("Global Plot") > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -- Ryan May -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Wed Sep 27 08:37:06 2017 From: wrw at mac.com (William Ray Wing) Date: Wed, 27 Sep 2017 08:37:06 -0400 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> Message-ID: <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> > On Sep 26, 2017, at 6:20 PM, Ryan May wrote: > > William, > > Don't use plt to call all of the methods, but directly use them off of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: > Thanks, that did it. Very grateful. Parenthetically, I wish there were a matplotlib book that explained the underlying logic of mil plotting. Every one I?ve looked into so far is full of specific cookbook examples, but they don?t explain what the various calls really do, what order they need to be called in (and why), and how they affect each other. Cookbooks are fine for doing things by rote, but they don?t provide understanding. If anyone on this list knows of such a book, I?d really appreciate hearing. Thanks, Bill > import numpy as np, matplotlib.pyplot as plt > > def problem(xdata, ydata, i): > color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} > fig1, ax1 = plt.subplots() > ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) > fig1.savefig('Plot for run_num ' + str(i)) > return > > def problem_alt(xdata, ydata, i): > return > > t = np.arange(0.0, 2.0, 0.01) > fig2, ax2 = plt.subplots() > > for i in range(0,4): > i = i+1 > problem(t, np.sin(i*np.pi*3*t), i) > problem_alt(t, np.sin(i*np.pi*3*t), i) > ax2.set_xlim(xmin = 0.0, xmax = 20.0) > ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) > > fig2.savefig("Global Plot") > > At least, I think that's what you're going for. Note I removed some extra calls to figure() and subplot() that I don't think were helping you. > > Ryan > > On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing > wrote: > Below is a simplified version of a much more elaborate analysis code, but it will illustrate the problem I?m having. What I want to do is repetitively call an analysis function from my main code and plot the results of that analysis (a curve fit, although thats immaterial here) while in that function. Back in the main code, I want to plot the results of all the curve fits on a single plot. They share a common x axis, but appear at different points along it. What seems to be happening is that the gets set in the function, and doesn?t get set back in the main code. > > Note that there are two versions of the ?problem? function, problem and problem_alt. If you change the main code (move the #), you get the plot I want at the end of the main. > > There must be something I can call or set to recover the settings associated with figure(2), but I can?t seem to figure it out. Any help would be appreciated. > > Thanks, > Bill Wing > > #! /usr/bin/env python > # -*- coding: utf-8 -*- > # > # A simple skeleton of the program to work out the plotting problem > # > import numpy as np, matplotlib.pyplot as plt > # > # skeleton subroutines > # > > def problem(xdata, ydata, i): > color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} > plt.figure(1) > fig1, ax1 = plt.subplots() > plt.subplot() > plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) > plt.savefig('Plot for run_num ' + str(i)) > return > > def problem_alt(xdata, ydata, i): > return > > > t = np.arange(0.0, 2.0, 0.01) > plt.figure(2) > fig2, ax2 = plt.subplots() > > for i in range(0,4): > i = i+1 > problem(t, np.sin(i*np.pi*3*t), i) > problem_alt(t, np.sin(i*np.pi*3*t), i) > ax2.set_xlim(xmin = 0.0, xmax = 20.0) > plt.subplot() > plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) > > plt.savefig("Global Plot") > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > -- > Ryan May > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Wed Sep 27 09:44:58 2017 From: ben.v.root at gmail.com (Benjamin Root) Date: Wed, 27 Sep 2017 09:44:58 -0400 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> Message-ID: You might want to check out my Anatomy of Matplotlib tutorial: https://github.com/matplotlib/AnatomyOfMatplotlib You can use the Jupyter notebooks and follow along with the recordings available on YouTube: https://www.youtube.com/watch?v=rARMKS8jE9g (Scipy 2017) and https://www.youtube.com/watch?v=MKucn8NtVeI (Scipy 2015 - which covered more, but spent less time on each aspect). There is also a book, "Mastering Matplotlib", which goes into deep depths with respect to the API and logic behind the library: https://www.amazon.com/Mastering-matplotlib-Duncan-M-McGreggor/dp/1783987545 I hope that helps! Ben Root On Wed, Sep 27, 2017 at 8:37 AM, William Ray Wing wrote: > > On Sep 26, 2017, at 6:20 PM, Ryan May wrote: > > William, > > Don't use plt to call all of the methods, but directly use them off of the > Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: > > > Thanks, that did it. Very grateful. > > Parenthetically, I wish there were a matplotlib book that explained the > underlying logic of mil plotting. Every one I?ve looked into so far is > full of specific cookbook examples, but they don?t explain what the various > calls really do, what order they need to be called in (and why), and how > they affect each other. Cookbooks are fine for doing things by rote, but > they don?t provide understanding. If anyone on this list knows of such a > book, I?d really appreciate hearing. > > Thanks, > Bill > > import numpy as np, matplotlib.pyplot as plt > > def problem(xdata, ydata, i): > color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} > fig1, ax1 = plt.subplots() > ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) > fig1.savefig('Plot for run_num ' + str(i)) > return > > def problem_alt(xdata, ydata, i): > return > > t = np.arange(0.0, 2.0, 0.01) > fig2, ax2 = plt.subplots() > > for i in range(0,4): > i = i+1 > problem(t, np.sin(i*np.pi*3*t), i) > problem_alt(t, np.sin(i*np.pi*3*t), i) > ax2.set_xlim(xmin = 0.0, xmax = 20.0) > ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) > > fig2.savefig("Global Plot") > > At least, I think that's what you're going for. Note I removed some extra > calls to figure() and subplot() that I don't think were helping you. > > Ryan > > On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing wrote: > >> Below is a simplified version of a much more elaborate analysis code, but >> it will illustrate the problem I?m having. What I want to do is >> repetitively call an analysis function from my main code and plot the >> results of that analysis (a curve fit, although thats immaterial here) >> while in that function. Back in the main code, I want to plot the results >> of all the curve fits on a single plot. They share a common x axis, but >> appear at different points along it. What seems to be happening is that >> the gets set in the function, and doesn?t get set back in the main code. >> >> Note that there are two versions of the ?problem? function, problem and >> problem_alt. If you change the main code (move the #), you get the plot I >> want at the end of the main. >> >> There must be something I can call or set to recover the settings >> associated with figure(2), but I can?t seem to figure it out. Any help >> would be appreciated. >> >> Thanks, >> Bill Wing >> >> #! /usr/bin/env python >> # -*- coding: utf-8 -*- >> # >> # A simple skeleton of the program to work out the plotting problem >> # >> import numpy as np, matplotlib.pyplot as plt >> # >> # skeleton subroutines >> # >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> plt.figure(1) >> fig1, ax1 = plt.subplots() >> plt.subplot() >> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> plt.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> >> t = np.arange(0.0, 2.0, 0.01) >> plt.figure(2) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> plt.subplot() >> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> plt.savefig("Global Plot") >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > > -- > Ryan May > > > > _______________________________________________ > 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 vincent.adrien at gmail.com Wed Sep 27 10:42:12 2017 From: vincent.adrien at gmail.com (Adrien VINCENT) Date: Wed, 27 Sep 2017 07:42:12 -0700 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> Message-ID: Hi William, Did you see the tutorials and the external ressources pages on the Matplotlib website? http://matplotlib.org/devdocs/tutorials/index.html http://matplotlib.org/devdocs/resources/index.html I am giving you the "testing" (devdocs) version because the documentation went through a lot of improvements (IMO ;)) for our incoming 2.1 version. But you should be able to find similar pages even on the non-devdocs web site if you prefer to use this one. Besides, with an interactive shell like IPython, you can easily get the documentation associated with a peculiar command by postpending a question mark to it (`command_i_want_to_better_know?`) and if you are using an IDE like Spyder, this kind of software usually provides a way to display the same information (click on the command and then Ctrl-I if I remember correctly in the case of Spyder). Hopefully this will help you. Regards, Adrien On September 27, 2017 5:37:06 AM PDT, William Ray Wing wrote: > >> On Sep 26, 2017, at 6:20 PM, Ryan May wrote: >> >> William, >> >> Don't use plt to call all of the methods, but directly use them off >of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: >> > >Thanks, that did it. Very grateful. > >Parenthetically, I wish there were a matplotlib book that explained the >underlying logic of mil plotting. Every one I?ve looked into so far is >full of specific cookbook examples, but they don?t explain what the >various calls really do, what order they need to be called in (and >why), and how they affect each other. Cookbooks are fine for doing >things by rote, but they don?t provide understanding. If anyone on this >list knows of such a book, I?d really appreciate hearing. > >Thanks, >Bill > >> import numpy as np, matplotlib.pyplot as plt >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> fig1, ax1 = plt.subplots() >> ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> fig1.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> t = np.arange(0.0, 2.0, 0.01) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> fig2.savefig("Global Plot") >> >> At least, I think that's what you're going for. Note I removed some >extra calls to figure() and subplot() that I don't think were helping >you. >> >> Ryan >> >> On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing > wrote: >> Below is a simplified version of a much more elaborate analysis code, >but it will illustrate the problem I?m having. What I want to do is >repetitively call an analysis function from my main code and plot the >results of that analysis (a curve fit, although thats immaterial here) >while in that function. Back in the main code, I want to plot the >results of all the curve fits on a single plot. They share a common x >axis, but appear at different points along it. What seems to be >happening is that the gets set in the function, and doesn?t get set >back in the main code. >> >> Note that there are two versions of the ?problem? function, problem >and problem_alt. If you change the main code (move the #), you get the >plot I want at the end of the main. >> >> There must be something I can call or set to recover the settings >associated with figure(2), but I can?t seem to figure it out. Any help >would be appreciated. >> >> Thanks, >> Bill Wing >> >> #! /usr/bin/env python >> # -*- coding: utf-8 -*- >> # >> # A simple skeleton of the program to work out the plotting problem >> # >> import numpy as np, matplotlib.pyplot as plt >> # >> # skeleton subroutines >> # >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> plt.figure(1) >> fig1, ax1 = plt.subplots() >> plt.subplot() >> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> plt.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> >> t = np.arange(0.0, 2.0, 0.01) >> plt.figure(2) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> plt.subplot() >> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> plt.savefig("Global Plot") >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > >> >> >> >> -- >> Ryan May >> -- Envoy? de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma bri?vet?. From wrw at mac.com Wed Sep 27 10:23:02 2017 From: wrw at mac.com (William Ray Wing) Date: Wed, 27 Sep 2017 10:23:02 -0400 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> Message-ID: <05EBB0A8-DD7B-42A5-93CA-B3D4B5B5D53B@mac.com> > On Sep 27, 2017, at 9:44 AM, Benjamin Root wrote: > > You might want to check out my Anatomy of Matplotlib tutorial: https://github.com/matplotlib/AnatomyOfMatplotlib > > You can use the Jupyter notebooks and follow along with the recordings available on YouTube: https://www.youtube.com/watch?v=rARMKS8jE9g (Scipy 2017) and https://www.youtube.com/watch?v=MKucn8NtVeI (Scipy 2015 - which covered more, but spent less time on each aspect). > > There is also a book, "Mastering Matplotlib", which goes into deep depths with respect to the API and logic behind the library: https://www.amazon.com/Mastering-matplotlib-Duncan-M-McGreggor/dp/1783987545 > Thanks, that book may be just what I?ve been searching for. I?ll check it out. Bill > I hope that helps! > Ben Root > > > On Wed, Sep 27, 2017 at 8:37 AM, William Ray Wing > wrote: > >> On Sep 26, 2017, at 6:20 PM, Ryan May > wrote: >> >> William, >> >> Don't use plt to call all of the methods, but directly use them off of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: >> > > Thanks, that did it. Very grateful. > > Parenthetically, I wish there were a matplotlib book that explained the underlying logic of mil plotting. Every one I?ve looked into so far is full of specific cookbook examples, but they don?t explain what the various calls really do, what order they need to be called in (and why), and how they affect each other. Cookbooks are fine for doing things by rote, but they don?t provide understanding. If anyone on this list knows of such a book, I?d really appreciate hearing. > > Thanks, > Bill > >> import numpy as np, matplotlib.pyplot as plt >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> fig1, ax1 = plt.subplots() >> ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> fig1.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> t = np.arange(0.0, 2.0, 0.01) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> fig2.savefig("Global Plot") >> >> At least, I think that's what you're going for. Note I removed some extra calls to figure() and subplot() that I don't think were helping you. >> >> Ryan >> >> On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing > wrote: >> Below is a simplified version of a much more elaborate analysis code, but it will illustrate the problem I?m having. What I want to do is repetitively call an analysis function from my main code and plot the results of that analysis (a curve fit, although thats immaterial here) while in that function. Back in the main code, I want to plot the results of all the curve fits on a single plot. They share a common x axis, but appear at different points along it. What seems to be happening is that the gets set in the function, and doesn?t get set back in the main code. >> >> Note that there are two versions of the ?problem? function, problem and problem_alt. If you change the main code (move the #), you get the plot I want at the end of the main. >> >> There must be something I can call or set to recover the settings associated with figure(2), but I can?t seem to figure it out. Any help would be appreciated. >> >> Thanks, >> Bill Wing >> >> #! /usr/bin/env python >> # -*- coding: utf-8 -*- >> # >> # A simple skeleton of the program to work out the plotting problem >> # >> import numpy as np, matplotlib.pyplot as plt >> # >> # skeleton subroutines >> # >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> plt.figure(1) >> fig1, ax1 = plt.subplots() >> plt.subplot() >> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> plt.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> >> t = np.arange(0.0, 2.0, 0.01) >> plt.figure(2) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> plt.subplot() >> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> plt.savefig("Global Plot") >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> >> >> -- >> Ryan May >> > > > _______________________________________________ > 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 Wed Sep 27 12:23:58 2017 From: tcaswell at gmail.com (Thomas Caswell) Date: Wed, 27 Sep 2017 16:23:58 +0000 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: <05EBB0A8-DD7B-42A5-93CA-B3D4B5B5D53B@mac.com> References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> <05EBB0A8-DD7B-42A5-93CA-B3D4B5B5D53B@mac.com> Message-ID: Bill, Where on the matplotlib website would you have expected to find this information? Asking not to be passive aggressive, but so we can update the docs to put this information there so the next person can find it ;) Tom On Wed, Sep 27, 2017 at 8:23 AM William Ray Wing wrote: > On Sep 27, 2017, at 9:44 AM, Benjamin Root wrote: > > You might want to check out my Anatomy of Matplotlib tutorial: > https://github.com/matplotlib/AnatomyOfMatplotlib > > You can use the Jupyter notebooks and follow along with the recordings > available on YouTube: https://www.youtube.com/watch?v=rARMKS8jE9g (Scipy > 2017) and https://www.youtube.com/watch?v=MKucn8NtVeI (Scipy 2015 - > which covered more, but spent less time on each aspect). > > There is also a book, "Mastering Matplotlib", which goes into deep depths > with respect to the API and logic behind the library: > https://www.amazon.com/Mastering-matplotlib-Duncan-M-McGreggor/dp/1783987545 > > > Thanks, that book may be just what I?ve been searching for. I?ll check it > out. > Bill > > I hope that helps! > Ben Root > > > On Wed, Sep 27, 2017 at 8:37 AM, William Ray Wing wrote: > >> >> On Sep 26, 2017, at 6:20 PM, Ryan May wrote: >> >> William, >> >> Don't use plt to call all of the methods, but directly use them off of >> the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: >> >> >> Thanks, that did it. Very grateful. >> >> Parenthetically, I wish there were a matplotlib book that explained the >> underlying logic of mil plotting. Every one I?ve looked into so far is >> full of specific cookbook examples, but they don?t explain what the various >> calls really do, what order they need to be called in (and why), and how >> they affect each other. Cookbooks are fine for doing things by rote, but >> they don?t provide understanding. If anyone on this list knows of such a >> book, I?d really appreciate hearing. >> >> Thanks, >> Bill >> >> import numpy as np, matplotlib.pyplot as plt >> >> def problem(xdata, ydata, i): >> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >> fig1, ax1 = plt.subplots() >> ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >> fig1.savefig('Plot for run_num ' + str(i)) >> return >> >> def problem_alt(xdata, ydata, i): >> return >> >> t = np.arange(0.0, 2.0, 0.01) >> fig2, ax2 = plt.subplots() >> >> for i in range(0,4): >> i = i+1 >> problem(t, np.sin(i*np.pi*3*t), i) >> problem_alt(t, np.sin(i*np.pi*3*t), i) >> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >> ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >> >> fig2.savefig("Global Plot") >> >> At least, I think that's what you're going for. Note I removed some extra >> calls to figure() and subplot() that I don't think were helping you. >> >> Ryan >> >> On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing wrote: >> >>> Below is a simplified version of a much more elaborate analysis code, >>> but it will illustrate the problem I?m having. What I want to do is >>> repetitively call an analysis function from my main code and plot the >>> results of that analysis (a curve fit, although thats immaterial here) >>> while in that function. Back in the main code, I want to plot the results >>> of all the curve fits on a single plot. They share a common x axis, but >>> appear at different points along it. What seems to be happening is that >>> the gets set in the function, and doesn?t get set back in the main code. >>> >>> Note that there are two versions of the ?problem? function, problem and >>> problem_alt. If you change the main code (move the #), you get the plot I >>> want at the end of the main. >>> >>> There must be something I can call or set to recover the settings >>> associated with figure(2), but I can?t seem to figure it out. Any help >>> would be appreciated. >>> >>> Thanks, >>> Bill Wing >>> >>> #! /usr/bin/env python >>> # -*- coding: utf-8 -*- >>> # >>> # A simple skeleton of the program to work out the plotting problem >>> # >>> import numpy as np, matplotlib.pyplot as plt >>> # >>> # skeleton subroutines >>> # >>> >>> def problem(xdata, ydata, i): >>> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >>> plt.figure(1) >>> fig1, ax1 = plt.subplots() >>> plt.subplot() >>> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >>> plt.savefig('Plot for run_num ' + str(i)) >>> return >>> >>> def problem_alt(xdata, ydata, i): >>> return >>> >>> >>> t = np.arange(0.0, 2.0, 0.01) >>> plt.figure(2) >>> fig2, ax2 = plt.subplots() >>> >>> for i in range(0,4): >>> i = i+1 >>> problem(t, np.sin(i*np.pi*3*t), i) >>> problem_alt(t, np.sin(i*np.pi*3*t), i) >>> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >>> plt.subplot() >>> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >>> >>> plt.savefig("Global Plot") >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> >> >> -- >> Ryan May >> >> >> >> _______________________________________________ >> 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 wrw at mac.com Thu Sep 28 23:12:51 2017 From: wrw at mac.com (William Ray Wing) Date: Thu, 28 Sep 2017 23:12:51 -0400 Subject: [Matplotlib-users] Problem doing multiple independent plots In-Reply-To: References: <1DEF4045-61EC-43E2-813E-9A1DE38C6C77@mac.com> <90EBCE49-8650-42DB-AA0A-E62F8A36E941@mac.com> <05EBB0A8-DD7B-42A5-93CA-B3D4B5B5D53B@mac.com> Message-ID: <142A4D58-A0C6-48FB-89DF-D896084D4964@mac.com> > On Sep 27, 2017, at 12:23 PM, Thomas Caswell wrote: > > Bill, > > Where on the matplotlib website would you have expected to find this information? > Tom, I?m not ignoring your question. My frustration with solving the problem I was having leads me to think this is actually an issue worth some real thought. When I have something I think might be constructive, I will follow up. Thanks, Bill > Asking not to be passive aggressive, but so we can update the docs to put this information there so the next person can find it ;) > > Tom > > On Wed, Sep 27, 2017 at 8:23 AM William Ray Wing wrote: >>> On Sep 27, 2017, at 9:44 AM, Benjamin Root wrote: >>> >>> You might want to check out my Anatomy of Matplotlib tutorial: https://github.com/matplotlib/AnatomyOfMatplotlib >>> >>> You can use the Jupyter notebooks and follow along with the recordings available on YouTube: https://www.youtube.com/watch?v=rARMKS8jE9g (Scipy 2017) and https://www.youtube.com/watch?v=MKucn8NtVeI (Scipy 2015 - which covered more, but spent less time on each aspect). >>> >>> There is also a book, "Mastering Matplotlib", which goes into deep depths with respect to the API and logic behind the library: https://www.amazon.com/Mastering-matplotlib-Duncan-M-McGreggor/dp/1783987545 >>> >> >> Thanks, that book may be just what I?ve been searching for. I?ll check it out. >> Bill >> >>> I hope that helps! >>> Ben Root >>> >>> >>>> On Wed, Sep 27, 2017 at 8:37 AM, William Ray Wing wrote: >>>> >>>>> On Sep 26, 2017, at 6:20 PM, Ryan May wrote: >>>>> >>>>> William, >>>>> >>>>> Don't use plt to call all of the methods, but directly use them off of the Figure (e.g. fig1) and Axes (e.g. ax1) instances you create: >>>>> >>>> >>>> Thanks, that did it. Very grateful. >>>> >>>> Parenthetically, I wish there were a matplotlib book that explained the underlying logic of mil plotting. Every one I?ve looked into so far is full of specific cookbook examples, but they don?t explain what the various calls really do, what order they need to be called in (and why), and how they affect each other. Cookbooks are fine for doing things by rote, but they don?t provide understanding. If anyone on this list knows of such a book, I?d really appreciate hearing. >>>> >>>> Thanks, >>>> Bill >>>> >>>>> import numpy as np, matplotlib.pyplot as plt >>>>> >>>>> def problem(xdata, ydata, i): >>>>> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >>>>> fig1, ax1 = plt.subplots() >>>>> ax1.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >>>>> fig1.savefig('Plot for run_num ' + str(i)) >>>>> return >>>>> >>>>> def problem_alt(xdata, ydata, i): >>>>> return >>>>> >>>>> t = np.arange(0.0, 2.0, 0.01) >>>>> fig2, ax2 = plt.subplots() >>>>> >>>>> for i in range(0,4): >>>>> i = i+1 >>>>> problem(t, np.sin(i*np.pi*3*t), i) >>>>> problem_alt(t, np.sin(i*np.pi*3*t), i) >>>>> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >>>>> ax2.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >>>>> >>>>> fig2.savefig("Global Plot") >>>>> >>>>> At least, I think that's what you're going for. Note I removed some extra calls to figure() and subplot() that I don't think were helping you. >>>>> >>>>> Ryan >>>>> >>>>>> On Tue, Sep 26, 2017 at 3:04 PM, William Ray Wing wrote: >>>>>> Below is a simplified version of a much more elaborate analysis code, but it will illustrate the problem I?m having. What I want to do is repetitively call an analysis function from my main code and plot the results of that analysis (a curve fit, although thats immaterial here) while in that function. Back in the main code, I want to plot the results of all the curve fits on a single plot. They share a common x axis, but appear at different points along it. What seems to be happening is that the gets set in the function, and doesn?t get set back in the main code. >>>>>> >>>>>> Note that there are two versions of the ?problem? function, problem and problem_alt. If you change the main code (move the #), you get the plot I want at the end of the main. >>>>>> >>>>>> There must be something I can call or set to recover the settings associated with figure(2), but I can?t seem to figure it out. Any help would be appreciated. >>>>>> >>>>>> Thanks, >>>>>> Bill Wing >>>>>> >>>>>> #! /usr/bin/env python >>>>>> # -*- coding: utf-8 -*- >>>>>> # >>>>>> # A simple skeleton of the program to work out the plotting problem >>>>>> # >>>>>> import numpy as np, matplotlib.pyplot as plt >>>>>> # >>>>>> # skeleton subroutines >>>>>> # >>>>>> >>>>>> def problem(xdata, ydata, i): >>>>>> color_dic = {1: "red", 2: "green", 3: "blue", 4: "cyan"} >>>>>> plt.figure(1) >>>>>> fig1, ax1 = plt.subplots() >>>>>> plt.subplot() >>>>>> plt.plot(xdata, ydata, linestyle = '-', color = color_dic[i]) >>>>>> plt.savefig('Plot for run_num ' + str(i)) >>>>>> return >>>>>> >>>>>> def problem_alt(xdata, ydata, i): >>>>>> return >>>>>> >>>>>> >>>>>> t = np.arange(0.0, 2.0, 0.01) >>>>>> plt.figure(2) >>>>>> fig2, ax2 = plt.subplots() >>>>>> >>>>>> for i in range(0,4): >>>>>> i = i+1 >>>>>> problem(t, np.sin(i*np.pi*3*t), i) >>>>>> problem_alt(t, np.sin(i*np.pi*3*t), i) >>>>>> ax2.set_xlim(xmin = 0.0, xmax = 20.0) >>>>>> plt.subplot() >>>>>> plt.plot((t+i*3), np.sin(i*np.pi*3*(t+i*3))) >>>>>> >>>>>> plt.savefig("Global Plot") >>>>>> >>>>>> _______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Matplotlib-users at python.org >>>>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>>> >>>>> >>>>> >>>>> -- >>>>> Ryan May >>>>> >>>> >>>> >>>> _______________________________________________ >>>> 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: