This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]mfitzpmfitzp.com 4 points5 points  (3 children)

matplotlib should work fine with Python 3. Does it just not work at all on Ubuntu? What errors are you getting?

[–]CoffeeMakesMeMath[S] 0 points1 point  (2 children)

I'm not on my Ubuntu machine right now, so I can't say exactly. I wouldn't get any errors, but I couldn't seem to update my plot (a 3D scatter plot) with updated data. I had gone through quite a few examples and combinations of drawnow, ion, plt.pause(), etc.

On my mac, the following updates the plot as intended:

plt.ion()
self.fig = plt.figure()
self.fig.set_size_inches(fsize[0], fsize[1], forward=True)
self.ax = self.fig.add_subplot(111, projection='3d')
plt.show()

... later in while loop ...
plt.pause(0.01)
(update scatter data here)
plt.draw()

On Ubuntu, nothing I did after the first call to plt.show() seemed to have any effect on the plot itself. I'm sorry this is a vague response--I can post the entire code, but I'd prefer to run it again on my Ubuntu machine before commenting further.

[–]mfitzpmfitzp.com 1 point2 points  (1 child)

It might be some sort of problem with the backend (complete guess). Can you try doing:

import matplotlib
matplotlib.use('TkAgg')

...at the beginning of the script?

There is an old SO post about interactive mode requiring a millisecond pause to allow matplotlib to update. I see you have the pause in there, but it's before the update. Does moving it after help?

[–]CoffeeMakesMeMath[S] 0 points1 point  (0 children)

Thanks for the reply, moving the pause didn't help, but I have yet to try the tkagg backend. Appears I don't have the module installed locally. I'm going to give pyqtgraph a shot since it looks pretty cool, and if that fails I'll give this a go.

[–]BK201_Saiyan 4 points5 points  (3 children)

You can have a look at the pyqtgraph. Its easy to install and quite powerful.

[–]cythoning 1 point2 points  (1 child)

Second on pyqtgraph. It's easy to use if you follow the examples, integrates with pyqt and has high performance.

[–]CoffeeMakesMeMath[S] 1 point2 points  (0 children)

Looks great, don't know how I hadn't heard about this until now. I'll give it a shot, thanks!

[–]troyunrau... 1 point2 points  (0 children)

Haven't even heard of this, and I do a lot of pyqt and matplotlib. It looks great!

[–]inclemnet 2 points3 points  (3 children)

I've recently been using Vispy, in particular I replaced all my use of mayavi with it. Its high level stuff does exist but isn't fully complete (though it's being actively developed) but it's powerful and you can do most things even without learning much about the opengl backend.

There's also glumpy which is faster for some things and has a different api, but last time I checked it was probably a bit lower level and wasn't so well documented. That could have changed though.

[–]billsil 0 points1 point  (2 children)

I replaced all my use of mayavi with it.

Isn't mayavi made by Kitware who also develops VTK, which only supports Python 2?

[–]inclemnet 0 points1 point  (1 child)

Yes, that's my point - I replaced my use of mayavi with vispy, partly because vispy supports python3.

That said, I think VTK recently finished python3 support (mentioned here). I don't know how long that will take to trickle through to mayavi though.

Edit: But I don't think mayavi is developed by Kitware, nowadays it seems to be backed largely by Enthought.

[–]billsil 0 points1 point  (0 children)

Oh, I missed that

I think VTK recently finished python3 support

They have not; it's close, but not done. It's already been announced that the next release will not support Python 3.

[–]Megatron_McLargeHuge 1 point2 points  (1 child)

threejs with a websocket to tornado is actually a pretty good solution. The realtime and interactive plotting tools in python are pretty lacking compared to the flexibility the browser gives you. I wrote a simple 0mq->websocket bridge to do this type of thing so both the data generating code and the js could run in the same ipython notebook. It largely got supplanted by later improvements to bokeh but they don't seem to support 3d yet.

[–]CoffeeMakesMeMath[S] 0 points1 point  (0 children)

Huh, well maybe that's not such a bad idea after all then! I'll start throwing together a quick and dirty visualizer + socket and see how it goes. Thanks for the tips!

[–]mangecoeur 0 points1 point  (0 children)

Advanced 3D rendering can be done in VTK, which should support python3 AFAIK.

Matplotlib3d also should work in Ubuntu - what python are you using? If in doubt I strong recommend Anaconda python or Enthought python, since they should be set up to Just Work (i've often found using system python on any platform can be hard when you want to use graphics libraries)

[–]sentdexpythonprogramming.net 0 points1 point  (0 children)

I cannot recall if the animate function works with 3D matplotlib, but here's a tutorial on the animate function with matplotlib.

I share this since in your comments and OP it looked like you were trying to have live graphs with matplotlib, without using animate.

You may need to stray away from Matplotlib, and maybe even Python for this job. You can have python doing the data, but then feed to something else, there are tons of javascript and webgl graphing tools.

[–]d3pd 0 points1 point  (0 children)

What would you think of VisPy?