You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
1
(16) |
2
(8) |
3
(4) |
4
|
5
|
6
(3) |
7
(11) |
8
(16) |
9
(1) |
10
(2) |
11
(2) |
12
(6) |
13
(2) |
14
(4) |
15
(5) |
16
(10) |
17
(5) |
18
|
19
|
20
|
21
(3) |
22
|
23
(12) |
24
(7) |
25
(1) |
26
|
27
(3) |
28
(4) |
29
(5) |
30
(2) |
|
|
From: Courtenay G. \(Enthought\) <cgo...@en...> - 2015-04-30 18:25:05
|
**The <https://plus.google.com/s/%23SciPy2015> #SciPy2015 Conference (Scientific Computing with <https://plus.google.com/s/%23Python> #Python) Tutorial Schedule is up! It is 1st come, 1st served and already 30% sold out. Register today!** http://www.scipy2015.scipy.org/ehome/115969/289057/? <http://www.scipy2015.scipy.org/ehome/115969/289057/?&> &.This year you can choose from 16 different SciPy tutorials OR select the 2 day Software Carpentry course on scientific Python that assumes some programming experience but no Python knowledge. Please share! Tutorials include: *Introduction to NumPy (Beginner) *Machine Learning with Scikit-Learn (Intermediate) *Cython: Blend of the Best of Python and C/++ (Intermediate) *Image Analysis in Python with SciPy and Scikit-Image (Intermediate) *Analyzing and Manipulating Data with Pandas (Beginner) *Machine Learning with Scikit-Learn (Advanced) *Building Python Data Applications with Blaze and Bokeh (Intermediate) *Multibody Dynamics and Control with Python (Intermediate) *Anatomy of Matplotlib (Beginner) *Computational Statistics I (Intermediate) *Efficient Python for High-Performance Parallel Computing (Intermediate) *Geospatial Data with Open Source Tools in Python (Intermediate) *Decorating Drones: Using Drones to Delve Deeper into Intermediate Python (Intermediate) *Computational Statistics II (Intermediate) *Modern Optimization Methods in Python (Advanced) *Jupyter Advanced Topics Tutorial (Advanced) |
From: Christian A. <am...@ym...> - 2015-04-30 15:15:45
|
I just managed to read Thomas post on stackoverflow citation. Yes, it covers, exactly what I found. This would have help if I would have found earlier. @Ben:As I said, it's nice to see such implementation but it's offside the task and offside the suggested components to use. It doesn't cover the issues I had to deal with. I am not disregarding it! But if you have to use a gui built with Qt Designer to decouple gui design which might be given as task to someone else so you can focus on implementing the functional parts, and somewhat later, someone shall improve the design, this way of creating things has the advantage that proceeding the work, if one stops working for the project, is as easy as it should be.You can split the work to gain more development speed, which is an advantage, too. Keeping the functional part away from the gui itself, enables one to improve the design without touching the functional code and without changing it's revision number if version control systems are used. Code recycling is a third one. I don't see any drawback, yet, if you don't take into account that they may be something missing in the additional libraries and the gab might cause problems not solvable.But that's not the topic of this thread. Yes, Qt Designer just provides only the framework, which than can be filled with content, for example, coming from matplotlib. Having just a dummy widget to fill as interface pays respect to being most flexible. No, having to re-initiate the mouse because it is disabled from matplotlib due to an empty canvas is not wrong but a design decision. One could have easily decided to not disable it, but the ones who wrote that part might have thought, that if the canvas is empty,you don't need axes to rotate. They discovered that this thoughts lead to problems and build a workaround enabling to switch it on again, rather than change the default. That's ok for me, because it was there decision. I would have like to find any hint about that in books, tutorials or stuff like that, but that seems to be a not that often regarded problem. I took your objection about adding the axis before the canvas is build and changed the code so after creating the figure I'm adding it to the canvas so it won't be empty anymore. This is a better way and is avoiding the mouse issue.Yes, it's clear now, but that is what I asked for in the first place. I mentioned that there may be something out of correct order. Now we know what it was and I fixed it. I like this kind of discussion which clarify the understanding, because you can get them from books. So thank you very much for the talk. I think I'm going to review the part where all the figures are created and will put them into a method which builds them if needed. That would clean up the design and the code, too.But that's something for after the deadline, for which the code can be as ugly as it is. It just has to work to get my job contract renewed. cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" |
From: Benjamin R. <ben...@ou...> - 2015-04-29 19:37:15
|
Christian (again, keeping things on-list), The entire point of the example was to provide a proof of concept and to show the absolute minimum needed to get mplot3d embedded. Please do not disregard it because I did not use Qt Designer. If I understand Qt Designer correctly, it merely provides additional widgets to be included in the app, so the figure really doesn't care about that stuff and should be completely orthogonal to our problem. When you run the example I gave you, it works without any need to call mouse_init(). The fact that it works without any call to mouse_init() proves that something is going very wrong in your code. The only reason for it to be called by the user is if the user managed to disable the user interactions and needs to restore it. That should never happen unless the user explicitly makes that happen. What I see in your code is you creating the axes before creating the figure canvas. Look at my example closely. The order of the commands matter. If you are creating axes objects in a figure, and then adding a canvas, you are overwriting the auto-generated canvas that was implicitly created when you added axes objects. That is why you are losing interactivity, because all of the original callbacks were being attached to the original canvas that you overwrote. This was also noted in the SO link that Thomas gave you. I hope that clarifies things for you, Ben Root On Wed, Apr 29, 2015 at 3:12 PM, Christian Ambros <am...@ym...> wrote: > Nice, but not close to the task on hand, because no Qt Designer was used, > so no gui-elements from there, no embedding! And that was the point to all > this. > > But maybe I'v come up with a solution to my problem... > Your remember the lines: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *def main(argv): app = QtWidgets.QApplication(argv) mainwindow = > Main() mainwindow.show() fig1 = Figure() #ax1f1 = > fig1.add_subplot(111) fname='augtr_16MnCrS5.dat' arr = > np.genfromtxt(fname, delimiter=' ', usecols=(0,4,25), missing_values={0:' > '}, filling_values={0:0}, unpack=True) > #ax1f1.plot(np.random.rand(20)) #ax1f1.plot(arr(0,25)) #fig = > plt.figure() ax1f1 = fig1.add_subplot(111, projection='3d') Y, Z, X = > arr ax1f1.plot_wireframe(X, Y, Z, rstride=10, cstride=10) > #plt.show() fig2 = Figure() ax1f2 = fig2.add_subplot(211) > ax1f2.plot(Y, Z) #np.random.rand(10) ax2f2 = fig2.add_subplot(212) > ax2f2.plot(Y, X)#np.random.rand(10) fig3 = Figure() ax1f3 = > fig3.add_subplot(111) ax1f3.pcolormesh(np.random.rand(20,20)) > mainwindow.addmpl(fig1) mainwindow.addfig('figure 1', fig1) > mainwindow.addfig('figure 2', fig2) mainwindow.addfig('figure 3', > fig3) #input() #mainwindow.rmmpl() #mainwindow.addmpl(fig2) > #mainwindow.addfig('figure 2', fig2) sys.exit(app.exec_())* > > Let's take a look at the important part: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *def main(argv): app = QtWidgets.QApplication(argv) mainwindow = > Main() mainwindow.show() fig1 = Figure() #ax1f1 = > fig1.add_subplot(111) fname='augtr_16MnCrS5.dat' arr = > np.genfromtxt(fname, delimiter=' ', usecols=(0,4,25), missing_values={0:' > '}, filling_values={0:0}, unpack=True) > #ax1f1.plot(np.random.rand(20)) #ax1f1.plot(arr(0,25)) #fig = > plt.figure() ax1f1 = fig1.add_subplot(111, projection='3d') Y, Z, X = > arr ax1f1.plot_wireframe(X, Y, Z, rstride=10, cstride=10) > #plt.show() fig2 = Figure() ax1f2 = fig2.add_subplot(211) > ax1f2.plot(Y, Z) #np.random.rand(10) ax2f2 = fig2.add_subplot(212) > ax2f2.plot(Y, X)#np.random.rand(10) fig3 = Figure() ax1f3 = > fig3.add_subplot(111) ax1f3.pcolormesh(np.random.rand(20,20)) > mainwindow.addmpl(fig1) mainwindow.addfig('figure 1', fig1) > mainwindow.addfig('figure 2', fig2) mainwindow.addfig('figure 3', > fig3) #input() #mainwindow.rmmpl() #mainwindow.addmpl(fig2) > #mainwindow.addfig('figure 2', fig2) sys.exit(app.exec_())* > ... and skip the rest... > > if I just initialize the mouse upon the axis like this: > > fig1 = Figure() > fname='augtr_16MnCrS5.dat' > arr = np.genfromtxt(fname, delimiter=' ', usecols=(0,4,25), > missing_values={0:' '}, filling_values={0:0}, unpack=True) > ax1f1 = fig1.add_subplot(111, projection='3d') > Y, Z, X = arr > > mainwindow.addmpl(fig1) > ax1f1.mouse_init() > > ax1f1.plot_wireframe(X, Y, Z, rstride=10, cstride=10) > > than mouse rotation is back online, no warning, no error. > > As I asked at the beginning, it was just the right place where the > mouse_init() has to be put. > It bothered me so much that I dug into API again and searched for > mouse_init(). Taking the error message into account, "mouse rotation off" I > figured out that it's an axis problem. It's not the canvas which is > rotated, it's all about the axis, so I found the usage for the mouse_init(). > > Thank you very much for all your effort and the patience to go this way > with me. > > At last I have a good advice for you: Go and switch to using Qt Designer > and PyQt5, it really helps having good gui's for the uninitiated. > > cheers, > Christian > > Ps: I'll get back to you, when I'm done reading your book completely. > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Wednesday, April 29, 2015 1:46 PM, Benjamin Root <ben...@ou...> > wrote: > > > Here is a proof of concept (yes, it uses qt4... my work computer doesn't > have qt5, but that should be a straight-forward modification to make). Note > the complete lack of any call to mouse_init() and the complete lack of any > use of pyplot (in fact, I commented it out to make the point that you > shouldn't use pyplot *at all* when doing this sort of embedding). > > ``` > import numpy as np > #import matplotlib.pyplot as plt > import sys > from matplotlib.backends.qt4_compat import QtGui, QtCore > from matplotlib.figure import Figure > from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as > FigureCanvas > > from mpl_toolkits.mplot3d import Axes3D > > > if __name__ == '__main__': > # Must come before any Qt widgets are made > app = QtGui.QApplication(sys.argv) > win = QtGui.QMainWindow() > fig = Figure() > canvas = FigureCanvas(fig) > ax = fig.add_subplot(1, 1, 1, projection='3d') > > xs = np.random.rand(25) > ys = np.random.rand(25) > zs = np.random.rand(25) > ax.scatter(xs, ys, zs) > > win.resize(int(fig.bbox.width), int(fig.bbox.height)) > win.setWindowTitle("Embedding with Qt") > # Needed for keyboard events > canvas.setFocusPolicy(QtCore.Qt.StrongFocus) > canvas.setFocus() > win.setCentralWidget(canvas) > win.show() > sys.exit(app.exec_()) > ``` > > I hope this helps! > Ben Root > > > On Wed, Apr 29, 2015 at 5:38 AM, Christian Ambros <am...@ym...> > wrote: > > Ok, back from revision... > > The is no mix-up for the show command. The only explicit show() command is > commented out in line 41. It can be deleted. But I haven't done that, yet. > There are several bits of code which are remains of the design process > since this is work in progress. Code cleaning will be done when the main > functionality is in place. > > Back to addmpl where I embedded gui elements into the canvas. Taking out > the matplotlib taskbar doesn't change a thing as I wrote earlier, but to > make sure it doesn't bother the mainloop, it should be commented out. I may > not put it back in, because I don't see the point in needing it. It was > just to see if it's possible. > > >>But option 2 relinquishes that control to the developer's GUI app. You > *cannot* use pyplot for option 2, which is what you are doing. > > Is that so? In line 116 I create the canvas, which is derived from > matplotlib's backend's FigureCanvasQTAgg and given to the QWidget at line > 119. That's the only part where both interact with each other. the rest is > handle by matplotlib. > > The error message says that Axes3D.figure.canvas is 'None' and that's why > mouse rotation is disabled. > It's None because there is no content at that point, when it's passed to > the QWidget. It's filled with content in line 38. So if matplotlib disables > the mouse rotation by default, when the canvas is empty how do I prevent > this disabling by default? > If I can't, at what point do I have to pass the filled canvas to the > QWidget? How does that impact the GUI itself? > If I can't enable the mouse rotation by hand and I just can pass filled > canvas around, do I have to build a work around with initialize it with an > empty 2D canvas and replace it later with the filled 3D canvas? How's the > mouse rotation activated then? > > In general, I wouldn't have to enable the rotation if it wouldn't be > switch off for an empty canvas. > > I'm going to consult your book, now, for different ways of coping with > such things... > > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 8:28 PM, Benjamin Root <ben...@ou...> > wrote: > > > One thing I see off the bat is your addmpl() method: > > ``` > def addmpl(self, fig): > #FigureCanvas.__init__(self, fig) > self.canvas = FigureCanvas(fig) > > Axes3D.mouse_init(self, rotate_btn=1, zoom_btn=2) > self.mplvl.addWidget(self.canvas) > self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) > self.mplvl.addWidget(self.toolbar) > ``` > > You are calling Axes3D.mouse_init() on the Main object (that is `self`). > That is completely wrong. It can only be called for the 3d axes objects. > > Also, what I see happening here is some mixing up of how to do embedding. > There are two approaches to embedding. 1) you can embedded GUI elements > into your canvas widget, or 2) you can embed your canvas widget into your > GUI app. The important distinction between the two is who controls the > mainloop. In option 1 (and in matplotlib in general), pyplot will create > the GUI app for you automatically (it is completely transparent to you) and > kicks it off upon call to show(). But option 2 relinquishes that control to > the developer's GUI app. You *cannot* use pyplot for option 2, which is > what you are doing. Rip out all of the pyplot stuff, and instantiate the > Qt5 Figure object directly, and then obtain the axes objects from the > figure object via calls to add_subplot(). You shouldn't even need to do the > whole mouse_init() stuff. > > I now think this has nothing to do with Qt Designer. While I don't > specifically cover qt5 in my book, I do make all of these distinctions very > clear in chapter 5 of my book "Interactive Applications using Matplotlib". > > Cheers! > Ben Root > > > On Tue, Apr 28, 2015 at 4:03 PM, Christian Ambros <am...@ym...> > wrote: > > Hi Benjamin, > > I would do that if my task were my private stuff, but in this case it's > work-related and my boss wants me to use the designer and he already set a > deadline, which, I already knew, is set to tight. I told him before, that > it would be just a try but he sold it to his boss after some pressure. You > know how the bosses' bosses are, they don't get the idea that innovation > can't be dictated. They don't understand the concept that software is > written and doesn't come into existence out of nothing. > > Without PyQt5 it's working fine. I got the plots and they are gorgeous, > but that doesn't help when presenting to the bosses. If I just would know > how to activate the 3d-draw's mouse action again, by hand, than it has to > last just some moments for the presentation, afterwards I have the time to > examine and find a more robust solution. > > Thanks for the effort. > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> > wrote: > > > I think there is something wrong with the embedding code rather than there > being an actual bug. I have embedded mplot3d stuff before (admittedly, not > in qt5) with no problems. I haven't had the time yet to examine your code > to see what the potential issue is, though. I have also never used Qt > designer, so I have no clue if there is something that it is doing that > might be making things difficult. > > I already know that the code you originally posted has errors in it. I > would suggest first making a prototype without Qt Designer as a > proof-of-concept, perhaps starting with one of our examples in the gallery? > > Ben Root > > > On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> > wrote: > > Since there seems to be no progress with this issue, may I assume there > isn't any interest in it? > I took a further look around in the internet but couldn't any solution. > It leads to an other question: How many users of matplotlib are using > 3d-plots anyway? It we are just a few and there won't be anyone who wants > to embed it in PyQt5, than I can understand that this issue doesn't concern > no-one and I have to look somewhere else to find a 3d-plotting lib which is > embedable. > > cheers, > Christain > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> > wrote: > > > The addmpl() method isn't right. You created a canvas object, assigned it > to self.canvas, but then tried to call FigureCanvas.__init__(), passing it > whatever object "self" is. What class is addmpl() a part of? What does it > subclass? > > On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> > wrote: > > Hi, > > I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get > the following error: > > /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: > UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set > canvas then call Axes3D.mouse_init(). > warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation > disabled. Set canvas then call Axes3D.mouse_init().') > > From Stackoverflow, which host to question about this, I know that mouse > actions are disabled when the canvas is re-initialized by whatever. > > The only position I do such an operation is in here: > > > > > > > > *def addmpl(self, fig): self.canvas = FigureCanvas(fig) > #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) > self.mplvl.addWidget(self.canvas) self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) self.mplvl.addWidget(self.toolbar)* > > On of the Stackoverflow suggestion says, that re initializing FigureCanvas > should do the trick but I'll get: > > Traceback (most recent call last): > File "./ex_0.1.py", line 145, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 116, in addmpl > FigureCanvas.__init__(self, fig) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", > line 181, in __init__ > FigureCanvasQT.__init__(self, figure) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", > line 237, in __init__ > super(FigureCanvasQT, self).__init__(figure=figure) > TypeError: super(type, obj): obj must be an instance or subtype of type > > as follow-up error message. > > just using *Axes3D.mouse_init()* , as suggested by matplotlib itself, > leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init() > TypeError: mouse_init() missing 1 required positional argument: 'self' > > adding self leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init(self) > File > "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", > line 1002, in mouse_init > canv = self.figure.canvas > AttributeError: 'Main' object has no attribute 'figure' > ./ex_0.1.py & > > Maybe I'm adding those lines at the wrong place, but I could fined > anything useful in the matplotlib documantation, that would help me out, > either. > > Any thougts that might help? > > Cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > > |
From: Thomas C. <tca...@gm...> - 2015-04-29 13:47:44
|
I think that this SO answer may be relevant: https://stackoverflow.com/questions/18259350/embed-an-interactive-3d-plot-in-pyside/18278457#18278457 On Wed, Apr 29, 2015 at 5:43 AM Christian Ambros <am...@ym...> wrote: > Ok, back from revision... > > The is no mix-up for the show command. The only explicit show() command is > commented out in line 41. It can be deleted. But I haven't done that, yet. > There are several bits of code which are remains of the design process > since this is work in progress. Code cleaning will be done when the main > functionality is in place. > > Back to addmpl where I embedded gui elements into the canvas. Taking out > the matplotlib taskbar doesn't change a thing as I wrote earlier, but to > make sure it doesn't bother the mainloop, it should be commented out. I may > not put it back in, because I don't see the point in needing it. It was > just to see if it's possible. > > >>But option 2 relinquishes that control to the developer's GUI app. You > *cannot* use pyplot for option 2, which is what you are doing. > > Is that so? In line 116 I create the canvas, which is derived from > matplotlib's backend's FigureCanvasQTAgg and given to the QWidget at line > 119. That's the only part where both interact with each other. the rest is > handle by matplotlib. > > The error message says that Axes3D.figure.canvas is 'None' and that's why > mouse rotation is disabled. > It's None because there is no content at that point, when it's passed to > the QWidget. It's filled with content in line 38. So if matplotlib disables > the mouse rotation by default, when the canvas is empty how do I prevent > this disabling by default? > If I can't, at what point do I have to pass the filled canvas to the > QWidget? How does that impact the GUI itself? > If I can't enable the mouse rotation by hand and I just can pass filled > canvas around, do I have to build a work around with initialize it with an > empty 2D canvas and replace it later with the filled 3D canvas? How's the > mouse rotation activated then? > > In general, I wouldn't have to enable the rotation if it wouldn't be > switch off for an empty canvas. > > I'm going to consult your book, now, for different ways of coping with > such things... > > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 8:28 PM, Benjamin Root <ben...@ou...> > wrote: > > > One thing I see off the bat is your addmpl() method: > > ``` > def addmpl(self, fig): > #FigureCanvas.__init__(self, fig) > self.canvas = FigureCanvas(fig) > > Axes3D.mouse_init(self, rotate_btn=1, zoom_btn=2) > self.mplvl.addWidget(self.canvas) > self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) > self.mplvl.addWidget(self.toolbar) > ``` > > You are calling Axes3D.mouse_init() on the Main object (that is `self`). > That is completely wrong. It can only be called for the 3d axes objects. > > Also, what I see happening here is some mixing up of how to do embedding. > There are two approaches to embedding. 1) you can embedded GUI elements > into your canvas widget, or 2) you can embed your canvas widget into your > GUI app. The important distinction between the two is who controls the > mainloop. In option 1 (and in matplotlib in general), pyplot will create > the GUI app for you automatically (it is completely transparent to you) and > kicks it off upon call to show(). But option 2 relinquishes that control to > the developer's GUI app. You *cannot* use pyplot for option 2, which is > what you are doing. Rip out all of the pyplot stuff, and instantiate the > Qt5 Figure object directly, and then obtain the axes objects from the > figure object via calls to add_subplot(). You shouldn't even need to do the > whole mouse_init() stuff. > > I now think this has nothing to do with Qt Designer. While I don't > specifically cover qt5 in my book, I do make all of these distinctions very > clear in chapter 5 of my book "Interactive Applications using Matplotlib". > > Cheers! > Ben Root > > > On Tue, Apr 28, 2015 at 4:03 PM, Christian Ambros <am...@ym...> > wrote: > > Hi Benjamin, > > I would do that if my task were my private stuff, but in this case it's > work-related and my boss wants me to use the designer and he already set a > deadline, which, I already knew, is set to tight. I told him before, that > it would be just a try but he sold it to his boss after some pressure. You > know how the bosses' bosses are, they don't get the idea that innovation > can't be dictated. They don't understand the concept that software is > written and doesn't come into existence out of nothing. > > Without PyQt5 it's working fine. I got the plots and they are gorgeous, > but that doesn't help when presenting to the bosses. If I just would know > how to activate the 3d-draw's mouse action again, by hand, than it has to > last just some moments for the presentation, afterwards I have the time to > examine and find a more robust solution. > > Thanks for the effort. > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> > wrote: > > > I think there is something wrong with the embedding code rather than there > being an actual bug. I have embedded mplot3d stuff before (admittedly, not > in qt5) with no problems. I haven't had the time yet to examine your code > to see what the potential issue is, though. I have also never used Qt > designer, so I have no clue if there is something that it is doing that > might be making things difficult. > > I already know that the code you originally posted has errors in it. I > would suggest first making a prototype without Qt Designer as a > proof-of-concept, perhaps starting with one of our examples in the gallery? > > Ben Root > > > On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> > wrote: > > Since there seems to be no progress with this issue, may I assume there > isn't any interest in it? > I took a further look around in the internet but couldn't any solution. > It leads to an other question: How many users of matplotlib are using > 3d-plots anyway? It we are just a few and there won't be anyone who wants > to embed it in PyQt5, than I can understand that this issue doesn't concern > no-one and I have to look somewhere else to find a 3d-plotting lib which is > embedable. > > cheers, > Christain > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> > wrote: > > > The addmpl() method isn't right. You created a canvas object, assigned it > to self.canvas, but then tried to call FigureCanvas.__init__(), passing it > whatever object "self" is. What class is addmpl() a part of? What does it > subclass? > > On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> > wrote: > > Hi, > > I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get > the following error: > > /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: > UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set > canvas then call Axes3D.mouse_init(). > warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation > disabled. Set canvas then call Axes3D.mouse_init().') > > From Stackoverflow, which host to question about this, I know that mouse > actions are disabled when the canvas is re-initialized by whatever. > > The only position I do such an operation is in here: > > > > > > > > *def addmpl(self, fig): self.canvas = FigureCanvas(fig) > #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) > self.mplvl.addWidget(self.canvas) self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) self.mplvl.addWidget(self.toolbar)* > > On of the Stackoverflow suggestion says, that re initializing FigureCanvas > should do the trick but I'll get: > > Traceback (most recent call last): > File "./ex_0.1.py", line 145, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 116, in addmpl > FigureCanvas.__init__(self, fig) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", > line 181, in __init__ > FigureCanvasQT.__init__(self, figure) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", > line 237, in __init__ > super(FigureCanvasQT, self).__init__(figure=figure) > TypeError: super(type, obj): obj must be an instance or subtype of type > > as follow-up error message. > > just using *Axes3D.mouse_init()* , as suggested by matplotlib itself, > leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init() > TypeError: mouse_init() missing 1 required positional argument: 'self' > > adding self leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init(self) > File > "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", > line 1002, in mouse_init > canv = self.figure.canvas > AttributeError: 'Main' object has no attribute 'figure' > ./ex_0.1.py & > > Maybe I'm adding those lines at the wrong place, but I could fined > anything useful in the matplotlib documantation, that would help me out, > either. > > Any thougts that might help? > > Cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Benjamin R. <ben...@ou...> - 2015-04-29 13:46:48
|
Here is a proof of concept (yes, it uses qt4... my work computer doesn't have qt5, but that should be a straight-forward modification to make). Note the complete lack of any call to mouse_init() and the complete lack of any use of pyplot (in fact, I commented it out to make the point that you shouldn't use pyplot *at all* when doing this sort of embedding). ``` import numpy as np #import matplotlib.pyplot as plt import sys from matplotlib.backends.qt4_compat import QtGui, QtCore from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from mpl_toolkits.mplot3d import Axes3D if __name__ == '__main__': # Must come before any Qt widgets are made app = QtGui.QApplication(sys.argv) win = QtGui.QMainWindow() fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(1, 1, 1, projection='3d') xs = np.random.rand(25) ys = np.random.rand(25) zs = np.random.rand(25) ax.scatter(xs, ys, zs) win.resize(int(fig.bbox.width), int(fig.bbox.height)) win.setWindowTitle("Embedding with Qt") # Needed for keyboard events canvas.setFocusPolicy(QtCore.Qt.StrongFocus) canvas.setFocus() win.setCentralWidget(canvas) win.show() sys.exit(app.exec_()) ``` I hope this helps! Ben Root On Wed, Apr 29, 2015 at 5:38 AM, Christian Ambros <am...@ym...> wrote: > Ok, back from revision... > > The is no mix-up for the show command. The only explicit show() command is > commented out in line 41. It can be deleted. But I haven't done that, yet. > There are several bits of code which are remains of the design process > since this is work in progress. Code cleaning will be done when the main > functionality is in place. > > Back to addmpl where I embedded gui elements into the canvas. Taking out > the matplotlib taskbar doesn't change a thing as I wrote earlier, but to > make sure it doesn't bother the mainloop, it should be commented out. I may > not put it back in, because I don't see the point in needing it. It was > just to see if it's possible. > > >>But option 2 relinquishes that control to the developer's GUI app. You > *cannot* use pyplot for option 2, which is what you are doing. > > Is that so? In line 116 I create the canvas, which is derived from > matplotlib's backend's FigureCanvasQTAgg and given to the QWidget at line > 119. That's the only part where both interact with each other. the rest is > handle by matplotlib. > > The error message says that Axes3D.figure.canvas is 'None' and that's why > mouse rotation is disabled. > It's None because there is no content at that point, when it's passed to > the QWidget. It's filled with content in line 38. So if matplotlib disables > the mouse rotation by default, when the canvas is empty how do I prevent > this disabling by default? > If I can't, at what point do I have to pass the filled canvas to the > QWidget? How does that impact the GUI itself? > If I can't enable the mouse rotation by hand and I just can pass filled > canvas around, do I have to build a work around with initialize it with an > empty 2D canvas and replace it later with the filled 3D canvas? How's the > mouse rotation activated then? > > In general, I wouldn't have to enable the rotation if it wouldn't be > switch off for an empty canvas. > > I'm going to consult your book, now, for different ways of coping with > such things... > > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 8:28 PM, Benjamin Root <ben...@ou...> > wrote: > > > One thing I see off the bat is your addmpl() method: > > ``` > def addmpl(self, fig): > #FigureCanvas.__init__(self, fig) > self.canvas = FigureCanvas(fig) > > Axes3D.mouse_init(self, rotate_btn=1, zoom_btn=2) > self.mplvl.addWidget(self.canvas) > self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) > self.mplvl.addWidget(self.toolbar) > ``` > > You are calling Axes3D.mouse_init() on the Main object (that is `self`). > That is completely wrong. It can only be called for the 3d axes objects. > > Also, what I see happening here is some mixing up of how to do embedding. > There are two approaches to embedding. 1) you can embedded GUI elements > into your canvas widget, or 2) you can embed your canvas widget into your > GUI app. The important distinction between the two is who controls the > mainloop. In option 1 (and in matplotlib in general), pyplot will create > the GUI app for you automatically (it is completely transparent to you) and > kicks it off upon call to show(). But option 2 relinquishes that control to > the developer's GUI app. You *cannot* use pyplot for option 2, which is > what you are doing. Rip out all of the pyplot stuff, and instantiate the > Qt5 Figure object directly, and then obtain the axes objects from the > figure object via calls to add_subplot(). You shouldn't even need to do the > whole mouse_init() stuff. > > I now think this has nothing to do with Qt Designer. While I don't > specifically cover qt5 in my book, I do make all of these distinctions very > clear in chapter 5 of my book "Interactive Applications using Matplotlib". > > Cheers! > Ben Root > > > On Tue, Apr 28, 2015 at 4:03 PM, Christian Ambros <am...@ym...> > wrote: > > Hi Benjamin, > > I would do that if my task were my private stuff, but in this case it's > work-related and my boss wants me to use the designer and he already set a > deadline, which, I already knew, is set to tight. I told him before, that > it would be just a try but he sold it to his boss after some pressure. You > know how the bosses' bosses are, they don't get the idea that innovation > can't be dictated. They don't understand the concept that software is > written and doesn't come into existence out of nothing. > > Without PyQt5 it's working fine. I got the plots and they are gorgeous, > but that doesn't help when presenting to the bosses. If I just would know > how to activate the 3d-draw's mouse action again, by hand, than it has to > last just some moments for the presentation, afterwards I have the time to > examine and find a more robust solution. > > Thanks for the effort. > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> > wrote: > > > I think there is something wrong with the embedding code rather than there > being an actual bug. I have embedded mplot3d stuff before (admittedly, not > in qt5) with no problems. I haven't had the time yet to examine your code > to see what the potential issue is, though. I have also never used Qt > designer, so I have no clue if there is something that it is doing that > might be making things difficult. > > I already know that the code you originally posted has errors in it. I > would suggest first making a prototype without Qt Designer as a > proof-of-concept, perhaps starting with one of our examples in the gallery? > > Ben Root > > > On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> > wrote: > > Since there seems to be no progress with this issue, may I assume there > isn't any interest in it? > I took a further look around in the internet but couldn't any solution. > It leads to an other question: How many users of matplotlib are using > 3d-plots anyway? It we are just a few and there won't be anyone who wants > to embed it in PyQt5, than I can understand that this issue doesn't concern > no-one and I have to look somewhere else to find a 3d-plotting lib which is > embedable. > > cheers, > Christain > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> > wrote: > > > The addmpl() method isn't right. You created a canvas object, assigned it > to self.canvas, but then tried to call FigureCanvas.__init__(), passing it > whatever object "self" is. What class is addmpl() a part of? What does it > subclass? > > On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> > wrote: > > Hi, > > I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get > the following error: > > /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: > UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set > canvas then call Axes3D.mouse_init(). > warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation > disabled. Set canvas then call Axes3D.mouse_init().') > > From Stackoverflow, which host to question about this, I know that mouse > actions are disabled when the canvas is re-initialized by whatever. > > The only position I do such an operation is in here: > > > > > > > > *def addmpl(self, fig): self.canvas = FigureCanvas(fig) > #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) > self.mplvl.addWidget(self.canvas) self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) self.mplvl.addWidget(self.toolbar)* > > On of the Stackoverflow suggestion says, that re initializing FigureCanvas > should do the trick but I'll get: > > Traceback (most recent call last): > File "./ex_0.1.py", line 145, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 116, in addmpl > FigureCanvas.__init__(self, fig) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", > line 181, in __init__ > FigureCanvasQT.__init__(self, figure) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", > line 237, in __init__ > super(FigureCanvasQT, self).__init__(figure=figure) > TypeError: super(type, obj): obj must be an instance or subtype of type > > as follow-up error message. > > just using *Axes3D.mouse_init()* , as suggested by matplotlib itself, > leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init() > TypeError: mouse_init() missing 1 required positional argument: 'self' > > adding self leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init(self) > File > "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", > line 1002, in mouse_init > canv = self.figure.canvas > AttributeError: 'Main' object has no attribute 'figure' > ./ex_0.1.py & > > Maybe I'm adding those lines at the wrong place, but I could fined > anything useful in the matplotlib documantation, that would help me out, > either. > > Any thougts that might help? > > Cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > |
From: garyr <ga...@fi...> - 2015-04-29 10:18:04
|
From: Christian A. <am...@ym...> - 2015-04-29 09:41:58
|
Ok, back from revision... The is no mix-up for the show command. The only explicit show() command is commented out in line 41. It can be deleted. But I haven't done that, yet. There are several bits of code which are remains of the design process since this is work in progress. Code cleaning will be done when the main functionality is in place. Back to addmpl where I embedded gui elements into the canvas. Taking out the matplotlib taskbar doesn't change a thing as I wrote earlier, but to make sure it doesn't bother the mainloop, it should be commented out. I may not put it back in, because I don't see the point in needing it. It was just to see if it's possible. >>But option 2 relinquishes that control to the developer's GUI app. You *cannot* use pyplot for option 2, which is what you are doing. Is that so? In line 116 I create the canvas, which is derived from matplotlib's backend's FigureCanvasQTAgg and given to the QWidget at line 119. That's the only part where both interact with each other. the rest is handle by matplotlib. The error message says that Axes3D.figure.canvas is 'None' and that's why mouse rotation is disabled.It's None because there is no content at that point, when it's passed to the QWidget. It's filled with content in line 38. So if matplotlib disables the mouse rotation by default, when the canvas is empty how do I prevent this disabling by default? If I can't, at what point do I have to pass the filled canvas to the QWidget? How does that impact the GUI itself? If I can't enable the mouse rotation by hand and I just can pass filled canvas around, do I have to build a work around with initialize it with an empty 2D canvas and replace it later with the filled 3D canvas? How's the mouse rotation activated then? In general, I wouldn't have to enable the rotation if it wouldn't be switch off for an empty canvas. I'm going to consult your book, now, for different ways of coping with such things... cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 28, 2015 8:28 PM, Benjamin Root <ben...@ou...> wrote: One thing I see off the bat is your addmpl() method: ``` def addmpl(self, fig): #FigureCanvas.__init__(self, fig) self.canvas = FigureCanvas(fig) Axes3D.mouse_init(self, rotate_btn=1, zoom_btn=2) self.mplvl.addWidget(self.canvas) self.canvas.draw() self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True) self.mplvl.addWidget(self.toolbar) ``` You are calling Axes3D.mouse_init() on the Main object (that is `self`). That is completely wrong. It can only be called for the 3d axes objects. Also, what I see happening here is some mixing up of how to do embedding. There are two approaches to embedding. 1) you can embedded GUI elements into your canvas widget, or 2) you can embed your canvas widget into your GUI app. The important distinction between the two is who controls the mainloop. In option 1 (and in matplotlib in general), pyplot will create the GUI app for you automatically (it is completely transparent to you) and kicks it off upon call to show(). But option 2 relinquishes that control to the developer's GUI app. You *cannot* use pyplot for option 2, which is what you are doing. Rip out all of the pyplot stuff, and instantiate the Qt5 Figure object directly, and then obtain the axes objects from the figure object via calls to add_subplot(). You shouldn't even need to do the whole mouse_init() stuff. I now think this has nothing to do with Qt Designer. While I don't specifically cover qt5 in my book, I do make all of these distinctions very clear in chapter 5 of my book "Interactive Applications using Matplotlib". Cheers! Ben Root On Tue, Apr 28, 2015 at 4:03 PM, Christian Ambros <am...@ym...> wrote: Hi Benjamin, I would do that if my task were my private stuff, but in this case it's work-related and my boss wants me to use the designer and he already set a deadline, which, I already knew, is set to tight. I told him before, that it would be just a try but he sold it to his boss after some pressure. You know how the bosses' bosses are, they don't get the idea that innovation can't be dictated. They don't understand the concept that software is written and doesn't come into existence out of nothing. Without PyQt5 it's working fine. I got the plots and they are gorgeous, but that doesn't help when presenting to the bosses. If I just would know how to activate the 3d-draw's mouse action again, by hand, than it has to last just some moments for the presentation, afterwards I have the time to examine and find a more robust solution. Thanks for the effort.cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> wrote: I think there is something wrong with the embedding code rather than there being an actual bug. I have embedded mplot3d stuff before (admittedly, not in qt5) with no problems. I haven't had the time yet to examine your code to see what the potential issue is, though. I have also never used Qt designer, so I have no clue if there is something that it is doing that might be making things difficult. I already know that the code you originally posted has errors in it. I would suggest first making a prototype without Qt Designer as a proof-of-concept, perhaps starting with one of our examples in the gallery? Ben Root On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> wrote: Since there seems to be no progress with this issue, may I assume there isn't any interest in it?I took a further look around in the internet but couldn't any solution.It leads to an other question: How many users of matplotlib are using 3d-plots anyway? It we are just a few and there won't be anyone who wants to embed it in PyQt5, than I can understand that this issue doesn't concern no-one and I have to look somewhere else to find a 3d-plotting lib which is embedable. cheers,Christain -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> wrote: The addmpl() method isn't right. You created a canvas object, assigned it to self.canvas, but then tried to call FigureCanvas.__init__(), passing it whatever object "self" is. What class is addmpl() a part of? What does it subclass? On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> wrote: Hi, I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get the following error: /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set canvas then call Axes3D.mouse_init(). warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation disabled. Set canvas then call Axes3D.mouse_init().') >From Stackoverflow, which host to question about this, I know that mouse actions are disabled when the canvas is re-initialized by whatever. The only position I do such an operation is in here: def addmpl(self, fig): self.canvas = FigureCanvas(fig) #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) self.mplvl.addWidget(self.canvas) self.canvas.draw() self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True) self.mplvl.addWidget(self.toolbar) On of the Stackoverflow suggestion says, that re initializing FigureCanvas should do the trick but I'll get: Traceback (most recent call last): File "./ex_0.1.py", line 145, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 116, in addmpl FigureCanvas.__init__(self, fig) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", line 181, in __init__ FigureCanvasQT.__init__(self, figure) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", line 237, in __init__ super(FigureCanvasQT, self).__init__(figure=figure) TypeError: super(type, obj): obj must be an instance or subtype of type as follow-up error message. just using Axes3D.mouse_init() , as suggested by matplotlib itself, leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init() TypeError: mouse_init() missing 1 required positional argument: 'self' adding self leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init(self) File "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 1002, in mouse_init canv = self.figure.canvas AttributeError: 'Main' object has no attribute 'figure' ./ex_0.1.py & Maybe I'm adding those lines at the wrong place, but I could fined anything useful in the matplotlib documantation, that would help me out, either. Any thougts that might help? Cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Benjamin R. <ben...@ou...> - 2015-04-28 20:28:37
|
One thing I see off the bat is your addmpl() method: ``` def addmpl(self, fig): #FigureCanvas.__init__(self, fig) self.canvas = FigureCanvas(fig) Axes3D.mouse_init(self, rotate_btn=1, zoom_btn=2) self.mplvl.addWidget(self.canvas) self.canvas.draw() self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True) self.mplvl.addWidget(self.toolbar) ``` You are calling Axes3D.mouse_init() on the Main object (that is `self`). That is completely wrong. It can only be called for the 3d axes objects. Also, what I see happening here is some mixing up of how to do embedding. There are two approaches to embedding. 1) you can embedded GUI elements into your canvas widget, or 2) you can embed your canvas widget into your GUI app. The important distinction between the two is who controls the mainloop. In option 1 (and in matplotlib in general), pyplot will create the GUI app for you automatically (it is completely transparent to you) and kicks it off upon call to show(). But option 2 relinquishes that control to the developer's GUI app. You *cannot* use pyplot for option 2, which is what you are doing. Rip out all of the pyplot stuff, and instantiate the Qt5 Figure object directly, and then obtain the axes objects from the figure object via calls to add_subplot(). You shouldn't even need to do the whole mouse_init() stuff. I now think this has nothing to do with Qt Designer. While I don't specifically cover qt5 in my book, I do make all of these distinctions very clear in chapter 5 of my book "Interactive Applications using Matplotlib". Cheers! Ben Root On Tue, Apr 28, 2015 at 4:03 PM, Christian Ambros <am...@ym...> wrote: > Hi Benjamin, > > I would do that if my task were my private stuff, but in this case it's > work-related and my boss wants me to use the designer and he already set a > deadline, which, I already knew, is set to tight. I told him before, that > it would be just a try but he sold it to his boss after some pressure. You > know how the bosses' bosses are, they don't get the idea that innovation > can't be dictated. They don't understand the concept that software is > written and doesn't come into existence out of nothing. > > Without PyQt5 it's working fine. I got the plots and they are gorgeous, > but that doesn't help when presenting to the bosses. If I just would know > how to activate the 3d-draw's mouse action again, by hand, than it has to > last just some moments for the presentation, afterwards I have the time to > examine and find a more robust solution. > > Thanks for the effort. > cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> > wrote: > > > I think there is something wrong with the embedding code rather than there > being an actual bug. I have embedded mplot3d stuff before (admittedly, not > in qt5) with no problems. I haven't had the time yet to examine your code > to see what the potential issue is, though. I have also never used Qt > designer, so I have no clue if there is something that it is doing that > might be making things difficult. > > I already know that the code you originally posted has errors in it. I > would suggest first making a prototype without Qt Designer as a > proof-of-concept, perhaps starting with one of our examples in the gallery? > > Ben Root > > > On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> > wrote: > > Since there seems to be no progress with this issue, may I assume there > isn't any interest in it? > I took a further look around in the internet but couldn't any solution. > It leads to an other question: How many users of matplotlib are using > 3d-plots anyway? It we are just a few and there won't be anyone who wants > to embed it in PyQt5, than I can understand that this issue doesn't concern > no-one and I have to look somewhere else to find a 3d-plotting lib which is > embedable. > > cheers, > Christain > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> > wrote: > > > The addmpl() method isn't right. You created a canvas object, assigned it > to self.canvas, but then tried to call FigureCanvas.__init__(), passing it > whatever object "self" is. What class is addmpl() a part of? What does it > subclass? > > On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> > wrote: > > Hi, > > I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get > the following error: > > /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: > UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set > canvas then call Axes3D.mouse_init(). > warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation > disabled. Set canvas then call Axes3D.mouse_init().') > > From Stackoverflow, which host to question about this, I know that mouse > actions are disabled when the canvas is re-initialized by whatever. > > The only position I do such an operation is in here: > > > > > > > > *def addmpl(self, fig): self.canvas = FigureCanvas(fig) > #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) > self.mplvl.addWidget(self.canvas) self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) self.mplvl.addWidget(self.toolbar)* > > On of the Stackoverflow suggestion says, that re initializing FigureCanvas > should do the trick but I'll get: > > Traceback (most recent call last): > File "./ex_0.1.py", line 145, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 116, in addmpl > FigureCanvas.__init__(self, fig) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", > line 181, in __init__ > FigureCanvasQT.__init__(self, figure) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", > line 237, in __init__ > super(FigureCanvasQT, self).__init__(figure=figure) > TypeError: super(type, obj): obj must be an instance or subtype of type > > as follow-up error message. > > just using *Axes3D.mouse_init()* , as suggested by matplotlib itself, > leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init() > TypeError: mouse_init() missing 1 required positional argument: 'self' > > adding self leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init(self) > File > "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", > line 1002, in mouse_init > canv = self.figure.canvas > AttributeError: 'Main' object has no attribute 'figure' > ./ex_0.1.py & > > Maybe I'm adding those lines at the wrong place, but I could fined > anything useful in the matplotlib documantation, that would help me out, > either. > > Any thougts that might help? > > Cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > |
From: Christian A. <am...@ym...> - 2015-04-28 20:03:36
|
Hi Benjamin, I would do that if my task were my private stuff, but in this case it's work-related and my boss wants me to use the designer and he already set a deadline, which, I already knew, is set to tight. I told him before, that it would be just a try but he sold it to his boss after some pressure. You know how the bosses' bosses are, they don't get the idea that innovation can't be dictated. They don't understand the concept that software is written and doesn't come into existence out of nothing. Without PyQt5 it's working fine. I got the plots and they are gorgeous, but that doesn't help when presenting to the bosses. If I just would know how to activate the 3d-draw's mouse action again, by hand, than it has to last just some moments for the presentation, afterwards I have the time to examine and find a more robust solution. Thanks for the effort.cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 28, 2015 7:30 PM, Benjamin Root <ben...@ou...> wrote: I think there is something wrong with the embedding code rather than there being an actual bug. I have embedded mplot3d stuff before (admittedly, not in qt5) with no problems. I haven't had the time yet to examine your code to see what the potential issue is, though. I have also never used Qt designer, so I have no clue if there is something that it is doing that might be making things difficult. I already know that the code you originally posted has errors in it. I would suggest first making a prototype without Qt Designer as a proof-of-concept, perhaps starting with one of our examples in the gallery? Ben Root On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> wrote: Since there seems to be no progress with this issue, may I assume there isn't any interest in it?I took a further look around in the internet but couldn't any solution.It leads to an other question: How many users of matplotlib are using 3d-plots anyway? It we are just a few and there won't be anyone who wants to embed it in PyQt5, than I can understand that this issue doesn't concern no-one and I have to look somewhere else to find a 3d-plotting lib which is embedable. cheers,Christain -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> wrote: The addmpl() method isn't right. You created a canvas object, assigned it to self.canvas, but then tried to call FigureCanvas.__init__(), passing it whatever object "self" is. What class is addmpl() a part of? What does it subclass? On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> wrote: Hi, I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get the following error: /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set canvas then call Axes3D.mouse_init(). warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation disabled. Set canvas then call Axes3D.mouse_init().') >From Stackoverflow, which host to question about this, I know that mouse actions are disabled when the canvas is re-initialized by whatever. The only position I do such an operation is in here: def addmpl(self, fig): self.canvas = FigureCanvas(fig) #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) self.mplvl.addWidget(self.canvas) self.canvas.draw() self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True) self.mplvl.addWidget(self.toolbar) On of the Stackoverflow suggestion says, that re initializing FigureCanvas should do the trick but I'll get: Traceback (most recent call last): File "./ex_0.1.py", line 145, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 116, in addmpl FigureCanvas.__init__(self, fig) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", line 181, in __init__ FigureCanvasQT.__init__(self, figure) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", line 237, in __init__ super(FigureCanvasQT, self).__init__(figure=figure) TypeError: super(type, obj): obj must be an instance or subtype of type as follow-up error message. just using Axes3D.mouse_init() , as suggested by matplotlib itself, leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init() TypeError: mouse_init() missing 1 required positional argument: 'self' adding self leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init(self) File "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 1002, in mouse_init canv = self.figure.canvas AttributeError: 'Main' object has no attribute 'figure' ./ex_0.1.py & Maybe I'm adding those lines at the wrong place, but I could fined anything useful in the matplotlib documantation, that would help me out, either. Any thougts that might help? Cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Benjamin R. <ben...@ou...> - 2015-04-28 19:22:24
|
I think there is something wrong with the embedding code rather than there being an actual bug. I have embedded mplot3d stuff before (admittedly, not in qt5) with no problems. I haven't had the time yet to examine your code to see what the potential issue is, though. I have also never used Qt designer, so I have no clue if there is something that it is doing that might be making things difficult. I already know that the code you originally posted has errors in it. I would suggest first making a prototype without Qt Designer as a proof-of-concept, perhaps starting with one of our examples in the gallery? Ben Root On Tue, Apr 28, 2015 at 2:12 PM, Christian Ambros <am...@ym...> wrote: > Since there seems to be no progress with this issue, may I assume there > isn't any interest in it? > I took a further look around in the internet but couldn't any solution. > It leads to an other question: How many users of matplotlib are using > 3d-plots anyway? It we are just a few and there won't be anyone who wants > to embed it in PyQt5, than I can understand that this issue doesn't concern > no-one and I have to look somewhere else to find a 3d-plotting lib which is > embedable. > > cheers, > Christain > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > > On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> > wrote: > > > The addmpl() method isn't right. You created a canvas object, assigned it > to self.canvas, but then tried to call FigureCanvas.__init__(), passing it > whatever object "self" is. What class is addmpl() a part of? What does it > subclass? > > On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> > wrote: > > Hi, > > I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get > the following error: > > /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: > UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set > canvas then call Axes3D.mouse_init(). > warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation > disabled. Set canvas then call Axes3D.mouse_init().') > > From Stackoverflow, which host to question about this, I know that mouse > actions are disabled when the canvas is re-initialized by whatever. > > The only position I do such an operation is in here: > > > > > > > > *def addmpl(self, fig): self.canvas = FigureCanvas(fig) > #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) > self.mplvl.addWidget(self.canvas) self.canvas.draw() > self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, > coordinates=True) self.mplvl.addWidget(self.toolbar)* > > On of the Stackoverflow suggestion says, that re initializing FigureCanvas > should do the trick but I'll get: > > Traceback (most recent call last): > File "./ex_0.1.py", line 145, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 116, in addmpl > FigureCanvas.__init__(self, fig) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", > line 181, in __init__ > FigureCanvasQT.__init__(self, figure) > File > "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", > line 237, in __init__ > super(FigureCanvasQT, self).__init__(figure=figure) > TypeError: super(type, obj): obj must be an instance or subtype of type > > as follow-up error message. > > just using *Axes3D.mouse_init()* , as suggested by matplotlib itself, > leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init() > TypeError: mouse_init() missing 1 required positional argument: 'self' > > adding self leads to: > > Traceback (most recent call last): > File "./ex_0.1.py", line 146, in <module> > main(sys.argv) > File "./ex_0.1.py", line 53, in main > mainwindow.addmpl(fig1) > File "./ex_0.1.py", line 118, in addmpl > Axes3D.mouse_init(self) > File > "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", > line 1002, in mouse_init > canv = self.figure.canvas > AttributeError: 'Main' object has no attribute 'figure' > ./ex_0.1.py & > > Maybe I'm adding those lines at the wrong place, but I could fined > anything useful in the matplotlib documantation, that would help me out, > either. > > Any thougts that might help? > > Cheers, > Christian > > -- > "A little learning never caused anyone's head to explode!" > > > "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
From: Christian A. <am...@ym...> - 2015-04-28 18:15:28
|
Since there seems to be no progress with this issue, may I assume there isn't any interest in it?I took a further look around in the internet but couldn't any solution.It leads to an other question: How many users of matplotlib are using 3d-plots anyway? It we are just a few and there won't be anyone who wants to embed it in PyQt5, than I can understand that this issue doesn't concern no-one and I have to look somewhere else to find a 3d-plotting lib which is embedable. cheers,Christain -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" On Tuesday, April 21, 2015 1:44 PM, Benjamin Root <ben...@ou...> wrote: The addmpl() method isn't right. You created a canvas object, assigned it to self.canvas, but then tried to call FigureCanvas.__init__(), passing it whatever object "self" is. What class is addmpl() a part of? What does it subclass? On Tue, Apr 21, 2015 at 7:24 AM, Christian Ambros <am...@ym...> wrote: Hi, I embedded Ryan's examble for PyQt5-matplotlib use into my App but I get the following error: /usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py:1009: UserWarning: Axes3D.figure.canvas is 'None', mouse rotation disabled. Set canvas then call Axes3D.mouse_init(). warnings.warn('Axes3D.figure.canvas is \'None\', mouse rotation disabled. Set canvas then call Axes3D.mouse_init().') >From Stackoverflow, which host to question about this, I know that mouse actions are disabled when the canvas is re-initialized by whatever. The only position I do such an operation is in here: def addmpl(self, fig): self.canvas = FigureCanvas(fig) #FigureCanvas.__init__(self, fig) #Axes3D.mouse_init(self) self.mplvl.addWidget(self.canvas) self.canvas.draw() self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True) self.mplvl.addWidget(self.toolbar) On of the Stackoverflow suggestion says, that re initializing FigureCanvas should do the trick but I'll get: Traceback (most recent call last): File "./ex_0.1.py", line 145, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 116, in addmpl FigureCanvas.__init__(self, fig) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5agg.py", line 181, in __init__ FigureCanvasQT.__init__(self, figure) File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt5.py", line 237, in __init__ super(FigureCanvasQT, self).__init__(figure=figure) TypeError: super(type, obj): obj must be an instance or subtype of type as follow-up error message. just using Axes3D.mouse_init() , as suggested by matplotlib itself, leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init() TypeError: mouse_init() missing 1 required positional argument: 'self' adding self leads to: Traceback (most recent call last): File "./ex_0.1.py", line 146, in <module> main(sys.argv) File "./ex_0.1.py", line 53, in main mainwindow.addmpl(fig1) File "./ex_0.1.py", line 118, in addmpl Axes3D.mouse_init(self) File "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 1002, in mouse_init canv = self.figure.canvas AttributeError: 'Main' object has no attribute 'figure' ./ex_0.1.py & Maybe I'm adding those lines at the wrong place, but I could fined anything useful in the matplotlib documantation, that would help me out, either. Any thougts that might help? Cheers,Christian -- "A little learning never caused anyone's head to explode!" "Ein wenig Lernen hat noch niemandens Kopf zum Explodieren gebracht!" ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Thomas C. <tca...@gm...> - 2015-04-27 22:02:29
|
Those look like they are coming up out of numpy. I am not familiar with gentoo, but it looks like numpy is not in the dependencies list. Tom On Mon, Apr 27, 2015, 16:59 Martin MOKREJŠ <mmo...@gm...> wrote: > Hi, > I use dev-python/matplotlib-1.4.3 and I suspect this is a recent > regression in it. Can anybody reproduce this? > > $ pychecker test.py > Processing module test (test.py)... > warning: couldn't find real module for class <class 'fftpack.error'> > (module name: fftpack) > warning: couldn't find real module for class <class > 'lapack_lite.LapackError'> (module name: lapack_lite) > warning: couldn't find real module for class <type 'mtrand.RandomState'> > (module name: mtrand) > warning: couldn't find real module for class <type 'mtrand.RandomState'> > (module name: mtrand) > ImportError: No module named _winreg > warning: couldn't find real module for class <type 'cntr.Cntr'> (module > name: cntr) > > Warnings... > > test.py:3: Imported module (pylab) not used > $ cat test.py > #! /usr/bin/python > > import pylab > $ > > > > > > > It was installed with these flags on Gentoo Linux: > > # emerge -pv matplotlib > > These are the packages that would be merged, in order: > > Calculating dependencies... done! > [ebuild R ] dev-python/matplotlib-1.4.3::gentoo USE="cairo examples > fltk gtk tk wxwidgets -doc -excel -gtk3 -latex -pyside -qt4 -qt5 {-test}" > PYTHON_TARGETS="python2_7 -python3_3 -python3_4" 0 KiB > > > > I use dev-python/pychecker-0.8.19-r1 for the code sanity checks. > http://pychecker.sourceforge.net/ http://pypi.python.org/pypi/PyChecker > > > Thank you for clues, > Martin > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Martin M. <mmo...@gm...> - 2015-04-27 20:56:55
|
Hi, I use dev-python/matplotlib-1.4.3 and I suspect this is a recent regression in it. Can anybody reproduce this? $ pychecker test.py Processing module test (test.py)... warning: couldn't find real module for class <class 'fftpack.error'> (module name: fftpack) warning: couldn't find real module for class <class 'lapack_lite.LapackError'> (module name: lapack_lite) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) warning: couldn't find real module for class <type 'mtrand.RandomState'> (module name: mtrand) ImportError: No module named _winreg warning: couldn't find real module for class <type 'cntr.Cntr'> (module name: cntr) Warnings... test.py:3: Imported module (pylab) not used $ cat test.py #! /usr/bin/python import pylab $ It was installed with these flags on Gentoo Linux: # emerge -pv matplotlib These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] dev-python/matplotlib-1.4.3::gentoo USE="cairo examples fltk gtk tk wxwidgets -doc -excel -gtk3 -latex -pyside -qt4 -qt5 {-test}" PYTHON_TARGETS="python2_7 -python3_3 -python3_4" 0 KiB I use dev-python/pychecker-0.8.19-r1 for the code sanity checks. http://pychecker.sourceforge.net/ http://pypi.python.org/pypi/PyChecker Thank you for clues, Martin |
From: Jesper L. <jes...@gm...> - 2015-04-27 07:55:55
|
Hi Tom, Thanks for the reply. I will open it as an issue on github. Best regards, Jesper 2015-04-25 22:20 GMT+02:00 Thomas Caswell <tca...@gm...>: > Jesper, > > Can you open an issue on this on github. If you are feeling ambitious a > pull request fixing the bug (as you seem to have a good idea of where the > problem is) would also be great! > > Tom > > On Fri, Apr 24, 2015 at 8:38 AM Jesper Larsen <jes...@gm...> > wrote: > >> Hi Matplotlib Users, >> >> When I make wind barbs with rounding enabled and custom barb increments I >> noticed that there were no wind barbs with half barbs above 2 full barbs. >> The reason seems to be a bug in the _find_tails method. The bug is >> illustrated by this small script (_find_tails is a copy of the one in >> matplotlib): >> >> import numpy as np >> >> def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): >> ''' >> Find how many of each of the tail pieces is necessary. Flag >> specifies the increment for a flag, barb for a full barb, and half for >> half a barb. Mag should be the magnitude of a vector (ie. >= 0). >> >> This returns a tuple of: >> >> (*number of flags*, *number of barbs*, *half_flag*, *empty_flag*) >> >> *half_flag* is a boolean whether half of a barb is needed, >> since there should only ever be one half on a given >> barb. *empty_flag* flag is an array of flags to easily tell if >> a barb is empty (too low to plot any barbs/flags. >> ''' >> >> #If rounding, round to the nearest multiple of half, the smallest >> #increment >> if rounding: >> mag = half * (mag / half + 0.5).astype(np.int) >> >> num_flags = np.floor(mag / flag).astype(np.int) >> mag = np.mod(mag, flag) >> >> num_barb = np.floor(mag / full).astype(np.int) >> mag = np.mod(mag, full) >> >> half_flag = mag >= half >> empty_flag = ~(half_flag | (num_flags > 0) | (num_barb > 0)) >> >> return num_flags, num_barb, half_flag, empty_flag >> >> def main(): >> mag = np.arange(0,21,1) >> barb_incs = {'half': 2.57222, >> 'full': 5.14444, >> 'flag': 25.7222} >> print 'With rounding' >> num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, >> rounding=True, **barb_incs) >> for i in range(len(mag)): >> print mag[i], num_flags[i], num_barb[i], half_flag[i], >> empty_flag[i] >> print 'Without rounding' >> num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, >> rounding=False, **barb_incs) >> for i in range(len(mag)): >> print mag[i], num_flags[i], num_barb[i], half_flag[i], >> empty_flag[i] >> >> if __name__ == '__main__': >> exit(main()) >> >> It seems like the error is not present when the barb increments are not >> set. I believe the reason for the bug is the float comparison (half_flag = >> mag >= half) where the value is rounded to a value very close to/identical >> to the 'half' increment. And it seems like python does the right thing when >> the "half" increment is a whole number but not always when it is not. >> >> But in any case the code should probably not depend two floats being >> equal. >> >> Best regards, >> Jesper >> >> ------------------------------------------------------------------------------ >> One dashboard for servers and applications across Physical-Virtual-Cloud >> Widest out-of-the-box monitoring support with 50+ applications >> Performance metrics, stats and reports that give you Actionable Insights >> Deep dive visibility with transaction tracing using APM Insight. >> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > |
From: Thomas C. <tca...@gm...> - 2015-04-25 20:20:44
|
Jesper, Can you open an issue on this on github. If you are feeling ambitious a pull request fixing the bug (as you seem to have a good idea of where the problem is) would also be great! Tom On Fri, Apr 24, 2015 at 8:38 AM Jesper Larsen <jes...@gm...> wrote: > Hi Matplotlib Users, > > When I make wind barbs with rounding enabled and custom barb increments I > noticed that there were no wind barbs with half barbs above 2 full barbs. > The reason seems to be a bug in the _find_tails method. The bug is > illustrated by this small script (_find_tails is a copy of the one in > matplotlib): > > import numpy as np > > def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): > ''' > Find how many of each of the tail pieces is necessary. Flag > specifies the increment for a flag, barb for a full barb, and half for > half a barb. Mag should be the magnitude of a vector (ie. >= 0). > > This returns a tuple of: > > (*number of flags*, *number of barbs*, *half_flag*, *empty_flag*) > > *half_flag* is a boolean whether half of a barb is needed, > since there should only ever be one half on a given > barb. *empty_flag* flag is an array of flags to easily tell if > a barb is empty (too low to plot any barbs/flags. > ''' > > #If rounding, round to the nearest multiple of half, the smallest > #increment > if rounding: > mag = half * (mag / half + 0.5).astype(np.int) > > num_flags = np.floor(mag / flag).astype(np.int) > mag = np.mod(mag, flag) > > num_barb = np.floor(mag / full).astype(np.int) > mag = np.mod(mag, full) > > half_flag = mag >= half > empty_flag = ~(half_flag | (num_flags > 0) | (num_barb > 0)) > > return num_flags, num_barb, half_flag, empty_flag > > def main(): > mag = np.arange(0,21,1) > barb_incs = {'half': 2.57222, > 'full': 5.14444, > 'flag': 25.7222} > print 'With rounding' > num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, > rounding=True, **barb_incs) > for i in range(len(mag)): > print mag[i], num_flags[i], num_barb[i], half_flag[i], > empty_flag[i] > print 'Without rounding' > num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, > rounding=False, **barb_incs) > for i in range(len(mag)): > print mag[i], num_flags[i], num_barb[i], half_flag[i], > empty_flag[i] > > if __name__ == '__main__': > exit(main()) > > It seems like the error is not present when the barb increments are not > set. I believe the reason for the bug is the float comparison (half_flag = > mag >= half) where the value is rounded to a value very close to/identical > to the 'half' increment. And it seems like python does the right thing when > the "half" increment is a whole number but not always when it is not. > > But in any case the code should probably not depend two floats being equal. > > Best regards, > Jesper > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Antonino I. <tri...@gm...> - 2015-04-24 18:04:52
|
Hi, I think there is a good reason to add the functionality to plot pre-computed histograms to hist() or to a new function with similar API. Sometimes histograms are heavy or we don't want to recompute them to perform a series of plots. In this case, I miss the ability to easily set the plot style. hist() allows to chose between bar, step and stepfilled. To change the style with pre-computed histograms, I need to write 3 different "plots" using bar(), plot() and fill_between() respectively. This is quite inconvenient and error prone, considering that these function have different API for the input data. Maybe the plotting part of hist() should be splitted in a standalone function (plotbins() ?) In this way, hist() can call this function to generate the plot, but also the user can call it when the histogram is pre-computed. The bonus is that we retain the same API for plot style. My 2cents, Antonio On Fri, Apr 24, 2015 at 4:31 AM, Jerzy Karczmarczuk < jer...@un...> wrote: > > Le 24/04/2015 12:58, Christian Alis responds to the problem posed by > Virgil Stokes > > I had the same problem some time ago and what I did is to use bar() to > > plot the histogram, which can be done in one line: > > > > hst, bin_edges = np.histogram(data) > > plt.bar(bin_edges[:-1], hst) > > > > Perhaps this trick can be added in the documentation? > > > > I am willing to code Virgil's request if many will find this useful. > Separating the computation of the histogram, and plotting it is > obviously useful. > (I needed this in a linguistical simulation context, where plotting had > no sense). > > Actually hist is more or less this, > see _axes.py, line 5678, the Axes method hist just calls > numpy.histogram. And then plots bars (or uses some other style). > > So, although completing the documentation might be of general interest, > I would NOT recommend adding some new version of hist. > This would be misleading. Hist is hist is hist(ogram). It computes the > histogram (and eventually plots it). If it is already computed elsewhere, > naming the procedure which JUST plots some bars a "histogram" is > methodologically very dubious. > > Jerzy Karczmarczuk > > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Jesper L. <jes...@gm...> - 2015-04-24 12:38:15
|
Hi Matplotlib Users, When I make wind barbs with rounding enabled and custom barb increments I noticed that there were no wind barbs with half barbs above 2 full barbs. The reason seems to be a bug in the _find_tails method. The bug is illustrated by this small script (_find_tails is a copy of the one in matplotlib): import numpy as np def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): ''' Find how many of each of the tail pieces is necessary. Flag specifies the increment for a flag, barb for a full barb, and half for half a barb. Mag should be the magnitude of a vector (ie. >= 0). This returns a tuple of: (*number of flags*, *number of barbs*, *half_flag*, *empty_flag*) *half_flag* is a boolean whether half of a barb is needed, since there should only ever be one half on a given barb. *empty_flag* flag is an array of flags to easily tell if a barb is empty (too low to plot any barbs/flags. ''' #If rounding, round to the nearest multiple of half, the smallest #increment if rounding: mag = half * (mag / half + 0.5).astype(np.int) num_flags = np.floor(mag / flag).astype(np.int) mag = np.mod(mag, flag) num_barb = np.floor(mag / full).astype(np.int) mag = np.mod(mag, full) half_flag = mag >= half empty_flag = ~(half_flag | (num_flags > 0) | (num_barb > 0)) return num_flags, num_barb, half_flag, empty_flag def main(): mag = np.arange(0,21,1) barb_incs = {'half': 2.57222, 'full': 5.14444, 'flag': 25.7222} print 'With rounding' num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, rounding=True, **barb_incs) for i in range(len(mag)): print mag[i], num_flags[i], num_barb[i], half_flag[i], empty_flag[i] print 'Without rounding' num_flags, num_barb, half_flag, empty_flag = _find_tails(None, mag, rounding=False, **barb_incs) for i in range(len(mag)): print mag[i], num_flags[i], num_barb[i], half_flag[i], empty_flag[i] if __name__ == '__main__': exit(main()) It seems like the error is not present when the barb increments are not set. I believe the reason for the bug is the float comparison (half_flag = mag >= half) where the value is rounded to a value very close to/identical to the 'half' increment. And it seems like python does the right thing when the "half" increment is a whole number but not always when it is not. But in any case the code should probably not depend two floats being equal. Best regards, Jesper |
From: Jerzy K. <jer...@un...> - 2015-04-24 11:31:19
|
Le 24/04/2015 12:58, Christian Alis responds to the problem posed by Virgil Stokes > I had the same problem some time ago and what I did is to use bar() to > plot the histogram, which can be done in one line: > > hst, bin_edges = np.histogram(data) > plt.bar(bin_edges[:-1], hst) > > Perhaps this trick can be added in the documentation? > > I am willing to code Virgil's request if many will find this useful. Separating the computation of the histogram, and plotting it is obviously useful. (I needed this in a linguistical simulation context, where plotting had no sense). Actually hist is more or less this, see _axes.py, line 5678, the Axes method hist just calls numpy.histogram. And then plots bars (or uses some other style). So, although completing the documentation might be of general interest, I would NOT recommend adding some new version of hist. This would be misleading. Hist is hist is hist(ogram). It computes the histogram (and eventually plots it). If it is already computed elsewhere, naming the procedure which JUST plots some bars a "histogram" is methodologically very dubious. Jerzy Karczmarczuk |
From: Virgil S. <vs...@it...> - 2015-04-24 11:28:41
|
On 24-Apr-2015 12:58, Christian Alis wrote: > I had the same problem some time ago and what I did is to use bar() to > plot the histogram, which can be done in one line: > > hist, bin_edges = np.histogram(data) > plt.bar(bin_edges[:-1], hist) Very elegant Christian :-) > > Perhaps this trick can be added in the documentation? Well, I vote to add it. However, I did find the following nice example (after reading your email) that shows how the bar function might be used (http://matplotlib.org/examples/api/barchart_demo.html) for my problem. Had I seen this before, I probably would not have posted this request.:-[ > > I am willing to code Virgil's request if many will find this useful. > > > On Fri, Apr 24, 2015 at 11:33 AM, Virgil Stokes <vs...@it...> wrote: >> I have some Python (2.7.9) code that processes some rather large data sets >> to determine the curvatures along 2D curves. One feature of these data that >> I like to look at is the distribution of the curvatures. I use NumPy to to >> determine histograms for each set, and save the histogram parameters >> returned from numpy.histogram in a file. >> >> I would like to use Matplotlib to plot histograms from the parameters >> returned in NumPy and stored in a file --- why? Because the size of my data >> sets does not allow for the use of the histogram plot function in Matplotlib >> (1.4.3); i.e., it needs the data sets to calculate the histogram, before >> doing the plot. I would like to have a histogram plot function in Matplotlib >> that could bypass the actual calculation of the bin counts and edges from >> the data, and use values of these found a priori. Of course, an obvious >> question is -- Why not write code to plot the rectangles yourself? Yes, I >> could do this; but, why not extend the Matplotlib histogram class to allow >> for this option? If I better understood Matplotlib, I would try this myself. >> Maybe it is possible to get this into the next planned release (1.5). :-) >> >> If this request is inappropriate for this list, then please accept my >> apology and direct me to where I should send this request. >> >> Best regards. >> >> ------------------------------------------------------------------------------ >> One dashboard for servers and applications across Physical-Virtual-Cloud >> Widest out-of-the-box monitoring support with 50+ applications >> Performance metrics, stats and reports that give you Actionable Insights >> Deep dive visibility with transaction tracing using APM Insight. >> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> Keep up the good work on Matplotlib and I look forward to vers. 1.5 :-) |
From: Christian A. <ia...@gm...> - 2015-04-24 10:59:05
|
I had the same problem some time ago and what I did is to use bar() to plot the histogram, which can be done in one line: hist, bin_edges = np.histogram(data) plt.bar(bin_edges[:-1], hist) Perhaps this trick can be added in the documentation? I am willing to code Virgil's request if many will find this useful. On Fri, Apr 24, 2015 at 11:33 AM, Virgil Stokes <vs...@it...> wrote: > I have some Python (2.7.9) code that processes some rather large data sets > to determine the curvatures along 2D curves. One feature of these data that > I like to look at is the distribution of the curvatures. I use NumPy to to > determine histograms for each set, and save the histogram parameters > returned from numpy.histogram in a file. > > I would like to use Matplotlib to plot histograms from the parameters > returned in NumPy and stored in a file --- why? Because the size of my data > sets does not allow for the use of the histogram plot function in Matplotlib > (1.4.3); i.e., it needs the data sets to calculate the histogram, before > doing the plot. I would like to have a histogram plot function in Matplotlib > that could bypass the actual calculation of the bin counts and edges from > the data, and use values of these found a priori. Of course, an obvious > question is -- Why not write code to plot the rectangles yourself? Yes, I > could do this; but, why not extend the Matplotlib histogram class to allow > for this option? If I better understood Matplotlib, I would try this myself. > Maybe it is possible to get this into the next planned release (1.5). :-) > > If this request is inappropriate for this list, then please accept my > apology and direct me to where I should send this request. > > Best regards. > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Virgil S. <vs...@it...> - 2015-04-24 10:36:36
|
I have some Python (2.7.9) code that processes some rather large data sets to determine the curvatures along 2D curves. One feature of these data that I like to look at is the distribution of the curvatures. I use NumPy to to determine histograms for each set, and save the histogram parameters returned from numpy.histogram in a file. I would like to use Matplotlib to plot histograms *from the parameters returned in NumPy* and stored in a file --- why? Because the size of my data sets does not allow for the use of the histogram plot function in Matplotlib (1.4.3); i.e., it needs the data sets to calculate the histogram, before doing the plot. I would like to have a histogram plot function in Matplotlib that could bypass the actual calculation of the bin counts and edges from the data, and use values of these found /a priori/. Of course, an obvious question is -- Why not write code to plot the rectangles yourself? Yes, I could do this; but, why not extend the Matplotlib histogram class to allow for this option? If I better understood Matplotlib, I would try this myself. Maybe it is possible to get this into the next planned release (1.5).:-) If this request is inappropriate for this list, then please accept my apology and direct me to where I should send this request. Best regards. |
From: Virgil S. <vs...@it...> - 2015-04-24 09:05:12
|
On 23-Apr-2015 20:09, Jerzy Karczmarczuk wrote: > Animation problem of Virgil Stokes. > > Since I began the answer sequence, here's a little more. If this overlaps > other answers, I apologize. > > About the third parameter >>> "/frames/ can be a generator, an iterable, or a number of frames." >> This makes very little sense to me --- what does "or a number of frames" mean? >>> The name "data_gen" could suggest its meaning (after having read the doc). >> I am not sure what you are referencing as "the doc"; but I did read the >> documentation several times and English is my native language. > I am not trying to accuse you of anything, I simply underline that if the > documentation - as cited - mentions the word *generator*, and the program > contains the argument *data_gen*, which is OBVIOUSLY a generator which > *yields* some data, then this might have give you some clues concerning its > meaning. Ok Jerzy --- I apologize for my reaction and you are correct, I should have taken "generator" more seriously. > >>> Note please that the keyword parameters are specified extra. >> I am aware of this. Perhaps, I am a Python dummy --- when I see something >> like value = None in a Python API argument, I interpret this as a keyword >> argument and not a generator. > > 1. Generators might be or not function arguments, keyword or not; this is not > an issue here. Generators are entities which produce iterators. Here you > have: *def data_gen(): while True: yield np.random.rand(10)* , and this is all. Yes, again Jerzy. > > 2. When you see "frames=None", etc., this doesn't absolutely mean that it is a > kw parameter, just a positional parameter with a default value. > Brendan Barnwell commented this already. > If you look at the definition of the FuncAnimation class, which is readable, > in the file ... matplotlib/animation.py, you will see > *def __init__(self, fig, func, frames=None, init_func=None, fargs=None, > save_count=None, **kwargs):** > ** ...* > which explicitly confirms this. > > I think that you got the answers you demanded. The FuncAnimation callback > *requires* one argument, even if you don't use it. It may be the frame number > (or index if you wish), or explicit, specific data, such as in your first > example. > If, as in your second example, the parameter passed is the frame index, and > you want to see how you can use it, test this: > > *x=np.linspace(0,20,300)*** > > * def update(i):* > > ** > > ** > > * data=(np.sin(x+i/3)+1)/2* > > ** > > * line.set_ydata(data)* > > ** > > * > * > > *ani = animation.FuncAnimation(fig, update, interval=40)* > > > You should see a moving sinusoid. Yes, I have written something like this myself in an attempt to better understand Matplotlib animation. IMHO, the documentation for FuncAnimation should explicitly state that one argument is required for the animation function. The documentation does state: "Makes an animation by repeatedly calling a function /func/, passing in (optional) arguments in /fargs/." But of course this is my opinion. > >>> >>> Please, in such cases test your programs by adding some simple tracing >>> contraptions, say, print(data) inside update. >> I did this and more before posting my email. I would not have posted this >> unless I thought it was necessary. And I thought one purpose of this user >> group was to help people --- even if they ask a question which may be >> annoying or "stupid" in some subscribers opinion. I try to remember what a >> very wise teacher once said --- "there is no such thing as a stupid question". > > I don't understand your reaction. I teach computer science for many years, > and several times per week I suggest to my students to do this, to trace their > programs. I trace mine. I have also taught programming and I often make the same suggestion and of course this is a suggestion that I follow myself. And I did this before posting. One thing that led me astray was the error message that was generated when I removed the argument to the animate function. I even went into the source of Matplotlib in an attempt to answer this; but, I still could not resolve this issue. > Nobody feels offended. You said: data is undefined. But it WAS DEFINED, you > agree? So, printing its value was the most natural suggestion. You would > immediately see that it had been generated by data_gen. Yes, I did see this and this was one thing that confused me. > > Also, I recommend that you look upon the sources of Matplotlib from time to > time. I do it regularly, it is nicely commented, and complements very well the > documentation. I have done this several times; but, I find this package very complex and difficult to unravel. I use Matplotlib a lot and it is a fantastic package --- great work by the developer team. The fact that I do not always need to know what is "under the cover" of Matplotlib, is IMHO a positive thing, and a good indicator that the documentation (including the examples and gallery) is rather well done. > > Jerzy Karczmarczuk > > PS. Some blizzard around positional/keyword parameters in Python is quite > persistent. "Dive into Python" of Mark Pilgrim covers this, and offers some > useful references. I recently obtained this book; but, have not "dived" into it yet It now seems clear that I should take the plunge soon :-) Best regards, and thanks for your follow-up Jerzy, --V |
From: Jerzy K. <jer...@un...> - 2015-04-23 18:09:52
|
Animation problem of Virgil Stokes. Since I began the answer sequence, here's a little more. If this overlaps other answers, I apologize. About the third parameter >> "/frames/ can be a generator, an iterable, or a number of frames." > This makes very little sense to me --- what does "or a number of > frames" mean? >> The name "data_gen" could suggest its meaning (after having read the >> doc). > I am not sure what you are referencing as "the doc"; but I did read > the documentation several times and English is my native language. I am not trying to accuse you of anything, I simply underline that if the documentation - as cited - mentions the word *generator*, and the program contains the argument *data_gen*, which is OBVIOUSLY a generator which *yields* some data, then this might have give you some clues concerning its meaning. >> Note please that the keyword parameters are specified extra. > I am aware of this. Perhaps, I am a Python dummy --- when I see > something like value = None in a Python API argument, I interpret this > as a keyword argument and not a generator. 1. Generators might be or not function arguments, keyword or not; this is not an issue here. Generators are entities which produce iterators. Here you have: *def data_gen(): while True: yield np.random.rand(10)* , and this is all. 2. When you see "frames=None", etc., this doesn't absolutely mean that it is a kw parameter, just a positional parameter with a default value. Brendan Barnwell commented this already. If you look at the definition of the FuncAnimation class, which is readable, in the file ... matplotlib/animation.py, you will see *def __init__(self, fig, func, frames=None, init_func=None, fargs=None, save_count=None, **kwargs):** ** ...* which explicitly confirms this. I think that you got the answers you demanded. The FuncAnimation callback *requires* one argument, even if you don't use it. It may be the frame number (or index if you wish), or explicit, specific data, such as in your first example. If, as in your second example, the parameter passed is the frame index, and you want to see how you can use it, test this: *x=np.linspace(0,20,300)*** * def update(i):* ** ** * data=(np.sin(x+i/3)+1)/2* ** * line.set_ydata(data)* ** *** *** *ani = animation.FuncAnimation(fig, update, interval=40)* You should see a moving sinusoid. >> >> Please, in such cases test your programs by adding some simple >> tracing contraptions, say, print(data) inside update. > I did this and more before posting my email. I would not have posted > this unless I thought it was necessary. And I thought one purpose of > this user group was to help people --- even if they ask a question > which may be annoying or "stupid" in some subscribers opinion. I try > to remember what a very wise teacher once said --- "there is no such > thing as a stupid question". I don't understand your reaction. I teach computer science for many years, and several times per week I suggest to my students to do this, to trace their programs. I trace mine. Nobody feels offended. You said: data is undefined. But it WAS DEFINED, you agree? So, printing its value was the most natural suggestion. You would immediately see that it had been generated by data_gen. Also, I recommend that you look upon the sources of Matplotlib from time to time. I do it regularly, it is nicely commented, and complements very well the documentation. Jerzy Karczmarczuk PS. Some blizzard around positional/keyword parameters in Python is quite persistent. "Dive into Python" of Mark Pilgrim covers this, and offers some useful references. See also this : https://www.python.org/dev/peps/pep-3102/ |
From: Benjamin R. <ben...@ou...> - 2015-04-23 17:50:48
|
"Thanks for this also Ben --- I will quite likely get this book. However, considering the complexity of Matplotlib --- only 174 pages bothers me a little. :-)" I am just that good! No, really though, the book focuses only on a subset of features in Matplotlib, and it does assume that you are somewhat comfortable with the language (or at least, understand the basics of Object Oriented Programming and terminology). There will be another book that will come out in a few months that is intended to be a complete refresh of Sandro Toshi's 2009 book that might be more up your alley, but I don't know how much it will cover of Animations. Sandro's book was released before the animation module was even a twinkle in Ryan May's eye... Cheers! Ben Root On Thu, Apr 23, 2015 at 1:40 PM, Virgil Stokes <vs...@it...> wrote: > On 23-Apr-2015 18:48, Benjamin Root wrote: > > ... keeping conversation on-list ... > > The reason why you get that error is because you took out the argument > from the call signature. But, FuncAnimation assumes that it can send in at > least one argument. That argument is not optional, even if you aren't using > it. So, animate() was called with an argument by FuncAnimation internally, > but since animate() as defined by you did not have that argument, it fails. > > Ok --- thanks again for the clarification. Who knows, with a little help > from this list, I might someday be able to create some useful animations > with Matplotlib ;-) > > > Cheers! > Ben Root > > > On Thu, Apr 23, 2015 at 12:32 PM, Virgil Stokes <vs...@it...> wrote: > >> On 23-Apr-2015 18:25, Benjamin Root wrote: >> >> The documentation should say "the number", not "a number". This >> particular argument expects either a generator, an iterable, or an integer. >> If none is given, it will try and figure out something for itself. The >> integer is used to create a number generator, and so you effectively have >> an iterable that supplies the first argument to the animation function. >> >> Ok Benjamin :-) --- thanks for the clarification. >> >> >> Often times, the first argument to this function is just a frame index. >> It is quite possible that you don't need it at all, but it is a part of the >> defined API that the FuncAnimation assumes to be able to call the >> user-supplied function. >> >> Does that help? >> >> Yes, this does indeed help. But I am still puzzled by the error message >> given when I remove the argument to the animate function. >> >> >> Ben Root >> >> <shameless_plug> >> P.S. - My new book "Interactive Applications using Matplotlib" has an >> entire chapter devoted to animations >> </shameless_plug> >> >> Thanks for this also Ben --- I will quite likely get this book. > However, considering the complexity of Matplotlib --- only 174 pages > bothers me a little. :-) > > >> >> On Thu, Apr 23, 2015 at 12:05 PM, Virgil Stokes <vs...@it...> wrote: >> >>> Thanks for your reply to my post, Jerzy. >>> >>> On 23-Apr-2015 13:18, Jerzy Karczmarczuk wrote: >>> >>> >>> >>> Le 23/04/2015 12:22, Virgil Stokes a écrit : >>> >>> The following interesting example (random_data.py) is posted at: >>> >>> http://matplotlib.org/1.4.2/examples/animation/random_data.html >>> >>> >>> import matplotlib.pyplot as plt >>> import matplotlib.animation as animation >>> >>> import numpy as np >>> >>> Yes, I forgot to include this >>> >>> >>> fig, ax = plt.subplots() >>> line, = ax.plot(np.random.rand(10)) >>> ax.set_ylim(0, 1) >>> >>> def update(data): >>> line.set_ydata(data) >>> return line, >>> >>> def data_gen(): >>> while True: yield np.random.rand(10) >>> >>> ani = animation.FuncAnimation(fig, update, data_gen, interval=100) >>> plt.show() >>> >>> This codes works; but, I am very confused by it. For example: >>> >>> 1. There are 3 positional arguments given for animation.FuncAnimation; >>> but, in the >>> API documentation for this class ( >>> <http://matplotlib.org/api/animation_api.html> >>> http://matplotlib.org/api/animation_api.html), only >>> two positional arguments are shown. >>> >>> The third one is the third one, >>> "*frames* can be a generator, an iterable, or a number of frames." >>> >>> This makes very little sense to me --- what does "or a number of >>> frames" mean? >>> >>> The name "data_gen" could suggest its meaning (after having read the >>> doc). >>> >>> I am not sure what you are referencing as "the doc"; but I did read the >>> documentation several times and English is my native language. >>> >>> Note please that the keyword parameters are specified extra. >>> >>> I am aware of this. Perhaps, I am a Python dummy --- when I see >>> something like value = None in a Python API argument, I interpret this as a >>> keyword argument and not a generator. >>> >>> >>> 2. data, the argument to the update function seems to be undefined. >>> >>> FuncAnimation usually passes the frame number: 0, 1, 2, ... as the first >>> parameter of the update function, when "frames" is None, or the number of >>> frames. If - as here - the third parameter is a generator, it passes the >>> yielded data to update. >>> It may be used or not. >>> >>> Ok, I understand that better now. But, you say "or *the number* of >>> frames" but the documentation reads "or *a number* of frames" --- what >>> does this mean? >>> >>> And I still do not understand how to use the first argument of the >>> function to be called for the animation. In another animation example ( >>> histogram.py), the animation function is defined by: >>> >>> def animate(i): >>> # simulate new data coming in >>> data = np.random.randn(1000 >>> n, bins = np.histogram(data, 100) >>> top = bottom + n >>> verts[1::5,1] = top >>> verts[2::5,1] = top >>> >>> This works of course; but, why is the "i" required? There is no other >>> reference to it in the entire script. If I remove it; i.e. use def >>> animate(): I get the following error: >>> >>> TypeError: animate() takes no arguments (1 given) >>> >>> I do not understand how this explains the fact that the function no >>> longer has any arguments. Please explain the meaning of this error message? >>> >>> >>> Please, in such cases test your programs by adding some simple tracing >>> contraptions, say, print(data) inside update. >>> >>> I did this and more before posting my email. I would not have posted >>> this unless I thought it was necessary. And I thought one purpose of this >>> user group was to help people --- even if they ask a question which may be >>> annoying or "stupid" in some subscribers opinion. I try to remember what a >>> very wise teacher once said --- "there is no such thing as a stupid >>> question". >>> >>> >>> ------------------------------------------------------------------------------ >>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>> Develop your own process in accordance with the BPMN 2 standard >>> Learn Process modeling best practices with Bonita BPM through live >>> exercises >>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>> event?utm_ >>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> > > |
From: Virgil S. <vs...@it...> - 2015-04-23 17:47:06
|
On 23-Apr-2015 18:28, Thomas Caswell wrote: > Can everyone please bring the level of snark/hostility down? Programming is > frustrating, but antagonizing the mailing list does not help anyone. > > It is not well documented, but the signature for `func` is assumed to be `def > function(required, *optional_positional)` see > https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py#L1107 > This was very useful! > for the line where it actually gets called. The logic behind this is that the > function needs to have some input to know what to draw (so the state about > where in the sequence you are lives in the animation code, not in the supplied > user code). > > For passing in the frame data you have several options. The first is to pass > in an iterable of the data you want to be passed to the function (ex > np.arange(5), image_stack, image_generator), basically anything where `it = > iter(input); data = next(it)` 'does the right thing'. The second is to pass > in a callable where repeated calls to `data = my_callable()` 'does the right > thing' This would be useful if you want to reach out and hit some external > hardware for you data each time the animation updates. The last is to pass in > a number of frames, which gets converted into xrange(frames). In all cases, > the Animation turns what ever your input is into an iterable which gets hit > once pre frame (see > https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py#L1047 > And also very useful! > for the code version of this paragraph). > > Tom > > PS was finishing this up as Ben's email came in > > On Thu, Apr 23, 2015 at 12:06 PM Virgil Stokes <vs...@it... > <mailto:vs...@it...>> wrote: > > Thanks for your reply to my post, Jerzy. > > > On 23-Apr-2015 13:18, Jerzy Karczmarczuk wrote: >> >> >> Le 23/04/2015 12:22, Virgil Stokes a écrit : >>> The following interesting example (random_data.py) is posted at: >>> >>> http://matplotlib.org/1.4.2/examples/animation/random_data.html >>> >>> >>> import matplotlib.pyplot as plt >>> import matplotlib.animation as animation >> import numpy as np > Yes, I forgot to include this > >>> >>> fig, ax = plt.subplots() >>> line, = ax.plot(np.random.rand(10)) >>> ax.set_ylim(0, 1) >>> >>> def update(data): >>> line.set_ydata(data) >>> return line, >>> >>> def data_gen(): >>> while True: yield np.random.rand(10) >>> >>> ani = animation.FuncAnimation(fig, update, data_gen, interval=100) >>> plt.show() >>> >>> This codes works; but, I am very confused by it. For example: >>> >>> 1. There are 3 positional arguments given for animation.FuncAnimation; >>> but, in the >>> API documentation for this class >>> (http://matplotlib.org/api/animation_api.html), only >>> two positional arguments are shown. >> The third one is the third one, >> "/frames/ can be a generator, an iterable, or a number of frames." > This makes very little sense to me --- what does "or a number of frames" mean? > >> The name "data_gen" could suggest its meaning (after having read the doc). > I am not sure what you are referencing as "the doc"; but I did read the > documentation several times and English is my native language. > >> Note please that the keyword parameters are specified extra. > I am aware of this. Perhaps, I am a Python dummy --- when I see something > like value = None in a Python API argument, I interpret this as a keyword > argument and not a generator. >> >>> 2. data, the argument to the update function seems to be undefined. >> FuncAnimation usually passes the frame number: 0, 1, 2, ... as the first >> parameter of the update function, when "frames" is None, or the number of >> frames. If - as here - the third parameter is a generator, it passes the >> yielded data to update. >> It may be used or not. > Ok, I understand that better now. But, you say "or *the number* of frames" > but the documentation reads "or *a number* of frames" --- what does this mean? > > And I still do not understand how to use the first argument of the > function to be called for the animation. In another animation example > (histogram.py), the animation function is defined by: > > def animate(i): > # simulate new data coming in > data = np.random.randn(1000 > n, bins = np.histogram(data, 100) > top = bottom + n > verts[1::5,1] = top > verts[2::5,1] = top > > This works of course; but, why is the "i" required? There is no other > reference to it in the entire script. If I remove it; i.e. use def > animate(): I get the following error: > > TypeError: animate() takes no arguments (1 given) > > I do not understand how this explains the fact that the function no longer > has any arguments. Please explain the meaning of this error message? >> >> Please, in such cases test your programs by adding some simple tracing >> contraptions, say, print(data) inside update. > I did this and more before posting my email. I would not have posted this > unless I thought it was necessary. And I thought one purpose of this user > group was to help people --- even if they ask a question which may be > annoying or "stupid" in some subscribers opinion. I try to remember what a > very wise teacher once said --- "there is no such thing as a stupid question". > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF_______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |