Pages

Showing posts with label matplotlib. Show all posts
Showing posts with label matplotlib. Show all posts

Matplotlib y-axis label not displayed when saved as .eps .pdf file

I encountered this error in matplotlib.pyplot.

When I tried to save the plotted graph in matplotlib, the y-axis label was not displayed in the saved file (.eps, .pdf, etc files).

Just add this line (as a previous line) before saving the graph as a file using savefig command.

plt.tight_layout()

The problem will be solved and the saved file will contain y-axis label.


Matpotlib error: Image size of 3831x7771797 pixels is too large. It must be less than 2^16 in each direction.

This is due to the large file size of the figs. you have plotted.
If you get this error, you may not visualize the figure(s) on the matplotlib.
However, you can save as a file (.pdf or .eps ir .png) and you can open and see the figures.

If you want to elimate the error message, the only solution is to decrease the file size (you may decrease the size of the figure or the pixel size)

Here is a related post in GitHub.
https://github.com/matplotlib/matplotlib/issues/16234


Another reason you may get this error may be due to the following reason.

If you have plt.text option as follow,

plt.text(6.0, 7.4, '(b)', ha='center', va='center', fontsize=14, rotation='horizontal', fontweight='bold')

then, this may be causing the problem (especially if you use alreadying existing script to plot figs.)
To solve this problem, just comment this plt.text() using # and try to save the file.
Now, if there is no error, you just adjust the location of the text values in the plt.text() to proper place.

This would solve this error.



Matplotlib common errors

Error: matplotlib.pyplot
not enough values to unpack (expected 3, got 2)

This is because, I defined as follows.

fig, ax, bx = plt.subplots()

Then, I did not use bx.

Once I removed bx,. i.e., by setting "fig, ax = plt.subplots()", the problem solved.




You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...