Matplotlib Slow rotation of 3D scattering

I use matplotlib to scatter the graph of a 3D dot matrix. I am using the following code:

import pylab as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np my_data = np.random.rand(6500,3) # toy 3D points fig = plt.figure() ax = Axes3D(plt.gcf()) ax.scatter(my_data[:,0],my_data[:,1],my_data[:,2]) plt.show() 

It works, so it opens a window where I can see my glasses.

However, if I try to rotate the graph with the mouse (by clicking and dragging it), it rotates REALLY slow.

I think that 6500 points are not so much for such a slow and slow rotation, so I wonder if there is any preset to speed it up.

Note. I tried using Matlab, and I can rotate the way the larger scatter is without any lag, so this is not a computer limitation.

Can someone run this code and see if it experiences slow rotation?

EDIT . Using the system monitor, I see that when turning points, only one processor is used, so matplotlib does not parallelize the process.

My computer specifications:

  • Intel (R) Core (TM) i5-3550 CPU @ 3.30 GHz
  • Graphics Card: Xeon E3-1200 v2 / 3rd Gen Core Graphics Controller.
  • Memory: 10 GB RAM
  • HDD: Samsung SSD 500 GB

Ubuntu 16.10 works

+5
source share
1 answer

There is hardly a unique solution to your problem, so I offer suggestions that can improve productivity.

1) The first and easiest attempt to try: use a different backend, which can usually be set using ~ / .matplotlib / matplotlibrc. Some rear ends give a terrible view. I found on my machine that pyqt5 is one of the best, but still displays your sample code at a few frames / sec.

2) other print packages can give you much better performance, and there are many: GTK , mayavi based mayavi and plotly are a few to try. They may or may not be trivial to install. Before you do this, you can get a general idea of ​​what your equipment is capable of displaying with three.js examples in the past and found that performance is much better than matplotlib for building 3D scatter, although python bindings have some doubts moving forward, I think.

+2
source

Source: https://habr.com/ru/post/1266266/


All Articles