This tag is for questions related to saving figures in matplotlib with .savefig
Questions tagged [savefig]
80 questions
0
votes
1 answer
Matplotlib savefig bbox_inches='tight' along a single direction only?
I have two plots, each with multiple subplots (panels), i.e. multiple rows and columns. Each row shows the same type of data as images with colorbars on the right side. The first plot has, say, 8 rows and 4 columns. The second one has, say, 3 rows…

bproxauf
- 1,076
- 12
- 23
0
votes
1 answer
Python Not Saving Polar Bar Chart
I've been trying to export a plot so that I can use it in a presentation and for whatever reason, python is only exporting a white square. I can save the plot using Spyder's built in Plot tab, but I'd like to use code later on to manipulate it…

ahluna
- 3
- 1
0
votes
1 answer
Saved image from google colab shows empty white space with noting on it
I tried saving the plot with following code
from google.colab import files
.....
plt.savefig('/content/drive/MyDrive/Project/firstone.jpeg' ,dpi=200,format='jpeg',bbox_inches='tight')
files.download('firstone.jpeg')
An image is saved but, it's with…

Lazybee
- 1
0
votes
1 answer
Matplotlib pdf backend can not save pdf with usetex
While running the following code:
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
plt.plot(range(10))
plt.savefig("plot.pdf")
I get the very long error, finally saying FileNotFoundError: [Errno 2] No such file or directory: ''.…

gasar8
- 306
- 4
- 12
0
votes
0 answers
How can I save multiple plots using matplotlib?
I am trying to save multiple plots I got after I run my code but when I save my fig it only save the last one, I have seen that the solution it is to save in a loop so it saves each figure individually but my lack of experience in python just dont…
0
votes
1 answer
The aspect ratio of the image when saving
When saving an image to matplotlib, the aspect ratio is always 4 by 3. Is it possible to change this in any way?
Commands like
plt.gca().set_aspect('equal')
change the aspect ratio only for the object being drawn, but not for the image.
Is it also…

Alexey Ismagilov
- 187
- 2
- 11
0
votes
0 answers
At big figsize at matplotlib crazzy image
I calculate with my own written "tree-framework" coordinates for tree-visulize/drawing (therefore I calculate coordinates for the nodes and the connections). I work under python 3.9 and I use for the drawing of the tree the matplotlib (version…

Fonso
- 31
- 3
0
votes
0 answers
Convert a styled dataframe to an image in Python
I have a number of styled dataframes (using df.style), how would I go about converting this to an image.
If I try and save these down using:
df_styled.savefig('/u1/username/df_styled.png')
I get the following error:
AttributeError: 'Styler' object…

flaws49
- 29
- 6
0
votes
0 answers
Segmentation Fault in matplotlib.pyplot.savefig
I am running a set of python scripts on my visual studio code on windows 10. It seems that there is a bug in matplotlib package of the anaconda3. Specifically, I notice that saving a figure as a .png utilizing matplotlib.pyplot.savefig function…

Ash
- 41
- 8
0
votes
0 answers
Why does matplotlib savefig not save axis labels and graph title against same white background as graph
I generate a graph with the following code:
# Initialize fig & axis objects
fig, ax1 = plt.subplots(1, 1, sharex=True)
# Add second y-axis
ax2=ax1.twinx()
# Create 4 legends
ln0 = ax2.plot([0,100], [80.5,…

user1245262
- 6,968
- 8
- 50
- 77
0
votes
1 answer
.savefig with geopandas results in empty figure
I want to produce a plot of the canton of Zürich by by importing a shapefile of Switzerland (https://www.swisstopo.admin.ch/de/geodata/landscape/boundaries3d.html) and zoom into the area of interest. In the last step I want to save the produced…

MCK1886
- 13
- 2
0
votes
1 answer
savefig('filename.png') saves a blank image in the folder
fig, ax = plt.xticks(datechange_index,datechange)
datacursor(display='single')
plt.ylabel('Temp in Kelvin')
plt.figure(figsize=(200,20))
plt.savefig('temp_plot.png')
plt.show()
The block of code above is what I tried to save a plot in matplotlib. …

Blackwidow
- 146
- 6
0
votes
1 answer
loops - How to save multiple plots in python
I'm trying to save the plots I got using "el in list". With "plot.show()" I only have the last plot. I tried with another one "plot.savefig.." but it didn't work so I left them as a comment. This is the code:
plot data gas flows
list = ['N2 flow',…

Nathali
- 3
- 1
0
votes
1 answer
Matplotlib GUI showing even though I never called plt.show()
I am using the following functions in order...
- plt.figure()
- plt.plot()
- plt.ylim
- plt.xticks()
- figure = plt.gcf()
- figure.set_size_inches()
- plt.savefig()
I just want to save the figure as png, which I've been doing…
0
votes
0 answers
Why does Python Matplotlib savefig behave differently when called a second time in the same script?
I have the following Python script using Matplotlib and the ternary library. It generates a ternary plot with some labels on the vertices and axes:
import matplotlib.pyplot as plt
import ternary
# Cleaning up
plt.close('all')
# Open figure
scale =…

Rob H.
- 81
- 1
- 7