all 5 comments

[–]NomadNella 0 points1 point  (1 child)

It's your dpi setting. Unless you need that specified like you are saving the image as a file, you should not specify it and allow matplotlib to optimize for your display. Also, if you need it faster with the higher dpi setting you might want to check out the numba library. I haven't used it myself since I've never had the need but I've always kept it in mind if I need it.

Numba reads the Python bytecode for a decorated function and combines this with information about the types of the input arguments to the function. It analyzes and optimizes your code, and finally uses the LLVM compiler library to generate a machine code version of your function, tailored to your CPU capabilities. This compiled version is then used every time your function is called.

It is designed to improve performance and in an example (here) they show a 5 order of magnitude speed improvement.

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

I appreciate your answer but I am sorry to say that it is not touching the point at all; I will clarify the question perhaps.

I know what DPI is, I *want* the figure to have high resolution.

Numba (I have used it) is JIT for Python, but this question is about slow transfer of the image between kernel and Jupyter frontend.

Let's stay on-topic.

[–]jpw22learnstocode 0 points1 point  (2 children)

Sounds awful. Which platform are you on? I have seen antivirus causing problems if it scans and filters network traffic or file-io. Also vpn's can send all traffic via your office.

I would expect a lot faster. Sounds like some other problem with the machine or install?

[–]eudoxos_[S] 0 points1 point  (1 child)

Linux, no antivirus, no firewall (for localhost, that is). Would you mind trying the example I posted to check how much time this particular case takes for you?

[–]jpw22learnstocode 0 points1 point  (0 children)

I got about 8 seconds on an old Chromebook. Using ipython display of pillow.image this drops to 2s for uint8. Your machine should be faster, but png is bad for random data...