You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: matplotlib pyplot creates a broken plot when long #28137
This is a fundamental limitation of agg (the renderer for the most commonly used backends)
Assuming you have the default dpi (100), your long dimension is 450*100 = 45,000 pixels.
This is actually under the limit that (at one point) we thought was relevant (2**16=65,536) though there is some thought that the limit may actually be in RGB(A) subpixels, rather than full pixels, which would lower the limit by at least a factor of 3. (45k is also greater than the 2**15=33k which I have also seen stated as the limit... I did not go digging into the code to figure out which one is the actual limit here)
It's probably possible to rewrite agg to allow larger images, but someone would have to put in the work
As for work arounds, it would be helpful to specify why you need a figure that is 12 m (42 feet) long. The reason this never gets fixed is because such a huge figure is usually not desired.
To give a little more context on the problem, I am plotting events on a timeline. It is somewhat similar to the problem they had in this other issue with the audio spectrogram.
The idea is to create an image with a good resolution to be able to zoom in on the screen and analyze the events that occurred at different timestamps.
This problem could be solved with other tools, but I'd like to do it with pyplot because it allows you to export the plot to an image that is portable and that anyone can analyze the results using an image viewer.
I don't see how the user is to find the timestamps to zoom into. The fonts in the displayed image will be unreadable. People could zoom and pan around but it's not going to be efficient.
If I were doing this I'd use Matplotlib directly and allow the zoom tool to reveal detail (while updating the axes limits) or make a GUI that uses the prebuilt images. But if you do the latter, you can easily paste together multiple images in your GUI.
@jklymak here I provide an extract of a real plot.
x axis represents the time, y axis represents speed in km/h of a vehicle.
Note that the displayed fonts are perfectly readable, that represents hour minutes and seconds, measured in local time.
Sure, I could create a software approach by drawing the results by tiles, this will require to create a website or to bundle the results with a software to be installed (what I can't / wouldn't want to do). I usually send the zipped image by email, so anyone can analyze it using a standard image viewer.
What format do you send the images in? I tried saving a png from the example in the OP. It seemed to save OK but my image viewer (Eye of Gnome on Ubuntu) threw an error saying it could not display images that large.
@rcomer I save the images in .png.
I'd have to test it on linux. Currently I'm using Mac, with the default image preview application.
I have no problem visualizing with that, but I'd guess that other open source applications for image manipulation shouldn't have any problem to handle these kind of images.
The fonts are readable because you have zoomed in. If you look at the whole image at once it will not be readable.
Again this is a limitation of Matplotlib Agg renderer. I don't think we would object to someone doing the work to relax this constraint. However it is not currently a high priority because it is usually not desired.
Activity
ksunden commentedon Apr 25, 2024
This is a fundamental limitation of agg (the renderer for the most commonly used backends)
Assuming you have the default dpi (100), your long dimension is 450*100 = 45,000 pixels.
This is actually under the limit that (at one point) we thought was relevant (
2**16=65,536) though there is some thought that the limit may actually be in RGB(A) subpixels, rather than full pixels, which would lower the limit by at least a factor of 3. (45k is also greater than the2**15=33kwhich I have also seen stated as the limit... I did not go digging into the code to figure out which one is the actual limit here)See also:
(Probably among others, those are just the ones I found most readily.)
estebanuri commentedon Apr 26, 2024
Thanks @ksunden for your reply.
So are you referring to this module of the library?
Do you know where exactly is this limitation defined?
Can you figure out if there is any workaround to plot these kind of large plots?
Thank you in advance
jklymak commentedon Apr 26, 2024
It's probably possible to rewrite agg to allow larger images, but someone would have to put in the work
As for work arounds, it would be helpful to specify why you need a figure that is 12 m (42 feet) long. The reason this never gets fixed is because such a huge figure is usually not desired.
estebanuri commentedon Apr 26, 2024
To give a little more context on the problem, I am plotting events on a timeline. It is somewhat similar to the problem they had in this other issue with the audio spectrogram.
The idea is to create an image with a good resolution to be able to zoom in on the screen and analyze the events that occurred at different timestamps.
This problem could be solved with other tools, but I'd like to do it with pyplot because it allows you to export the plot to an image that is portable and that anyone can analyze the results using an image viewer.
jklymak commentedon Apr 26, 2024
I don't see how the user is to find the timestamps to zoom into. The fonts in the displayed image will be unreadable. People could zoom and pan around but it's not going to be efficient.
If I were doing this I'd use Matplotlib directly and allow the zoom tool to reveal detail (while updating the axes limits) or make a GUI that uses the prebuilt images. But if you do the latter, you can easily paste together multiple images in your GUI.
estebanuri commentedon Apr 29, 2024
@jklymak here I provide an extract of a real plot.

x axis represents the time, y axis represents speed in km/h of a vehicle.
Note that the displayed fonts are perfectly readable, that represents hour minutes and seconds, measured in local time.
Sure, I could create a software approach by drawing the results by tiles, this will require to create a website or to bundle the results with a software to be installed (what I can't / wouldn't want to do). I usually send the zipped image by email, so anyone can analyze it using a standard image viewer.
rcomer commentedon Apr 29, 2024
What format do you send the images in? I tried saving a png from the example in the OP. It seemed to save OK but my image viewer (Eye of Gnome on Ubuntu) threw an error saying it could not display images that large.
estebanuri commentedon Apr 29, 2024
@rcomer I save the images in .png.
I'd have to test it on linux. Currently I'm using Mac, with the default image preview application.
I have no problem visualizing with that, but I'd guess that other open source applications for image manipulation shouldn't have any problem to handle these kind of images.
jklymak commentedon Apr 29, 2024
The fonts are readable because you have zoomed in. If you look at the whole image at once it will not be readable.
Again this is a limitation of Matplotlib Agg renderer. I don't think we would object to someone doing the work to relax this constraint. However it is not currently a high priority because it is usually not desired.
scottshambaugh commentedon Apr 29, 2024
Closing as a duplicate as #26368, which has some more discussion in it.