1

I am generating a matplotlib figure which consists of 2 subplots: A 3D plot with updated data each time (Poly3dcollection) and an image file that I plug in with plt.imshow().

I am able to save the this figure by plt.savefig, however, savefig is very slow for my application since I need to save ~4 million of these figures. I already tried saving in different file formats with various parameters, saving it into memory and than read it by PIL to save by PIL.save etc. None of the solutions that I could find made the saving of the figure in less than a second.

I`d very much appreciate if someone has a suggestion for this but I need a major increase in performance, minor changes will not matter a lot.

moldersmut
  • 11
  • 1
  • Would that include parallelizing onto multiple CPU cores? Or do you need to increase the single-thread performance? – MaxNoe Apr 15 '21 at 12:07
  • Also, have you profiled the code to see what is actually slow? – MaxNoe Apr 15 '21 at 12:08
  • Welcome to Stackoverflow. Try to create a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Molitoris Apr 16 '21 at 07:00
  • I profiled it, around 70% of the time is spent only for savefig. I haven`t tried multithreading but I believe that would only increase the time by the factor of number of cores my CPU has. Therefore I think I need to increase the single core performance. If matplotlib does not provide any method for that, I will need to look for another library that mobilizes the GPU for much faster saving/rendering. – moldersmut Apr 16 '21 at 13:53

0 Answers0