Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
54 views

How to save a matplotlib figure with automatic height to pdf

I have the following problem: I want to save a figure with a specific width, but auto-determine its height. Let's look at an example: import matplotlib.pyplot as plt import numpy as np fig,ax=plt....
Simon Schey's user avatar
0 votes
1 answer
30 views

How to save matplotlib violinplots with axes? Tried using fig.tight_layout() but the saved plots are without axes or labels or titles

My codes are as follows: import matplotlib.pyplot as plt import numpy as np data_to_plot = [avg[0]['Cell Perimeter (unit pixel side)'], avg[1]['Cell Perimeter (unit pixel side)'], avg[2]['Cell ...
eu tube's user avatar
2 votes
1 answer
288 views

rasterio rasterize shapely ploygons and save plot to file

Ultimately I will create a bunch of rasters from a bunch of building polygons in a geopandas dataframe. But this is preliminary testing. >>> import shapely >>> import shapely....
Don Mclachlan's user avatar
0 votes
0 answers
35 views

Save Matplotlib plots to PDF with PdfPages changes my plots

I'm generating multiple figures in a for loop and then I want to save these figures in 1 pdf file. Therefore I use this code: from matplotlib.backends.backend_pdf import PdfPages save_image(...
Charlotte Crauwels's user avatar
2 votes
0 answers
202 views

Corrupted image when saving imshow as PDF with matplotlib

I have been trying to save an imshow figure as a PDF, but when I try to open it up in my PDF reader (Acrobat Reader DC) it says "Insufficient data for an image" and refuses to display the ...
Gustaf's user avatar
  • 21
0 votes
3 answers
105 views

How to reference a previously created file name in savefig [duplicate]

I am fairly inexperienced with python but I have quite a lot of data (csv) that I need to process and plot in figures. My question is when using plt.savefig how would I reference the figure file name ...
Gabriel Kalman's user avatar
0 votes
0 answers
253 views

Does someone got stuck with "savefig" in Julia?

I have a problem with savefig (inside PlotlyJS) that I can't know where it comes from. The code is simple, there are some scatters and a figure that show correctly: using PlotlyJS n_points = 250 ...
Franco Riottini's user avatar
0 votes
0 answers
95 views

ERROR: Unexpected character with savefig in Julia

I'm just trying to save a plot with savefig but I've encountered a strange ERROR. julia> PlotlyJS.savefig(p) ERROR: Unexpected character Line: 0 Around: ...�Desea terminar el tra... ^ ...
Franco Riottini's user avatar
0 votes
0 answers
24 views

plt.savefig behaviour in eps mode for nan type using imshow [duplicate]

I am trying to save an image using plt.imshow and plt.savefig by inputting a certain 2D array that happens to contain NaNs. When I call plt.show() the NaNs map to white but when saved to an eps file ...
maxxpinse's user avatar
0 votes
2 answers
102 views

How can I correctly save plots with a tkinter app plot function?

I am saving my plot using matplotlib.pyplot.savefig, but the resulting figure sometimes has bugs in it. These bugs are different in each image and can be the image with a transparent background, a ...
Rauf's user avatar
  • 19
1 vote
0 answers
68 views

unable to change pie chart size in pie() in matplotllnb [duplicate]

import pandas as pd import numpy as np df = pd.read_csv("Medals.csv") import matplotlib.pyplot as plt fig=plt.figure() plt.suptitle("Medals data") x = sum(df.Gold) y = sum(df....
Vineet Pashine's user avatar
-2 votes
1 answer
73 views

Saving figures in a loop in matplotlib [duplicate]

I am trying to save multiple histograms while iterating through a loop but it just ends up saving as a blank image. I tried the exact same code outside the loop and it seems to work, so I'm not sure ...
Alison Andrade's user avatar
0 votes
0 answers
90 views

matplotlib's function savefig() is not saving the hover event annotations used with mpl_connect()

Issue: The mouse hover annotation display effect of bars is not working in saved image "foo.png" by plt.savefig('foo.png'). The savefig() function saving the plot as a static image without ...
user3603533's user avatar
0 votes
1 answer
287 views

Wrong image size when using Matplotlib savefig

I use savefig from Matplotlib to get an Image from a figure, and this image is modified with PIL after that. I also want to remove every padding. My problem is that the final size of the image is ...
Nicolas's user avatar
  • 1,870
0 votes
2 answers
68 views

plots to folder python

I am having issue saving plots to a folder. I want to store all of the plots created in a for loop to a folder that I previously created. I tried using imsave() function as follows: for p in samples: ...
barista's user avatar
  • 35
0 votes
2 answers
86 views

Matplot SavFig Returns Blank Image

I am trying to download some plots as images and these are being downloaded as blank images. The direct download works but the download through the drive shows blank images. ANY HELP WOULD BE HIGHLY ...
Sehr Malik's user avatar
0 votes
0 answers
111 views

How do I get rid of background whitespace when saving a matplotlib table?

I have searched stack overflow extensively for a solution to my problem and have had no luck finding an answer. I am trying to save a matplotlib table as a png image with no whitespace background in ...
Matt's user avatar
  • 1
0 votes
1 answer
228 views

How to save figure in matplotlib ajusted to the object size?

Hello everyone I am trying to save the figures from matplotlib. It saves with blank spaces around the figure, I mean It adds space, It is no saved with ajusted object size. It is very easy to edit ...
Miguel 's user avatar
  • 155
0 votes
0 answers
72 views

why python saves graph partially in high dpi?

I need to save a graph with high resolution by: plt.savefig('trace', format='jpeg', bbox_inches='tight', dpi=3000) The main graph is: But it saves partially, like this: How can I solve this problem?...
Nasrin Asgari's user avatar
0 votes
2 answers
363 views

Matplotlib save very long plot in single image Python

I'm trying to save a very long EEG line plot (>100 hours with a datapoint every 5min) as a single image with a resolution ~10x10000px so that it would be readable by human eye when zoomed in. I ...
Fabio Magarelli's user avatar
-2 votes
1 answer
217 views

How can I save several plots in a for loop? [duplicate]

I am trying to save several plots in a for loop but I got this error: 'FileNotFoundError: [Errno 2] No such file or directory: '8/2020/graph.png' Here is my code: for i in names.columns: fig, ax = ...
Yaman's user avatar
  • 1
4 votes
3 answers
3k views

x axis label cropped on saved image

So I'm trying to do a bar plot on a data where x is the username (string ) and each x is long enough to overlap each other, so I have to rotate the x label. No problem there. However, when exporting ...
Yusuf Syam's user avatar
0 votes
1 answer
2k views

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 ...
silence_of_the_lambdas's user avatar
0 votes
1 answer
48 views

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 ...
ahluna's user avatar
  • 3
1 vote
1 answer
467 views

Python - Insert 2 figures objects in one PDF page

I want to take 2 figures objects and save them together on one pdf page. This is my code that currently saves them on 2 separate pages: if (output_pdf_name is not None): pdf = matplotlib.backends....
Yuval Froman's user avatar
2 votes
1 answer
131 views

Matplotlib not saving axes on savfig

This code only saves this image. As you can see it's rather empty :| Where are my axes plots? start = 100 sim_rets = gbm( mu=m.mu, n_scenarios=m.scenarios, n_years=m.years, prices=True,...
Michael Paccione's user avatar
0 votes
1 answer
1k views

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('...
Lazybee's user avatar
1 vote
1 answer
315 views

julia savefig() saves wrong marker shape

The code is to using PyPlot to scatter and save in julia. using PyPlot;pygui(true) fig = figure() for i = 1:400 scatter([i,i+1], [i+1, i+2], color = "blue", s = 0.1) end PyPlot.savefig(...
BenXylona's user avatar
2 votes
1 answer
3k views

How can I save multiple figures after they have been created in a loop?

I'm relatively new to using Python and have been re-writing some of my MatLab scripts. I have a script that creates 7 figures within a loop. After they have been made I want to save each one.I am ...
Alex Cushley's user avatar
0 votes
1 answer
194 views

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 ...
gasar8's user avatar
  • 314
1 vote
0 answers
1k views

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 ...
Osnaya Ivn's user avatar
-1 votes
2 answers
7k views

Unexpected keyword argument in python

I am trying to run python script for computing lipid interactions. The python script is downloaded from: https://pylipid.readthedocs.io/en/master/demo.html When I run the script, the following error ...
Abhinav Srivastava's user avatar
6 votes
1 answer
2k views

Save sklearn pipeline diagram

I want to save a pipeline displayed with the set_config(display="diagram") command, see below: Is there a better way to do it than by taking a screenshot?
Joris Limonier's user avatar
0 votes
1 answer
872 views

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 ...
Alexey Ismagilov's user avatar
0 votes
0 answers
69 views

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 ...
Fonso's user avatar
  • 29
1 vote
1 answer
1k views

Saving Colorbar Plot as Image File

I am trying to save a matplotlib.colorbar plot as an image file, jpg or png. I have tried the two ways written in the code below. Using clb.savefig results in the error: AttributeError: 'Colorbar' ...
XyloSedai's user avatar
0 votes
0 answers
926 views

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 ...
Ash's user avatar
  • 41
0 votes
0 answers
99 views

Why does matplotlib savefig not save axis labels and graph title against same white background as graph [duplicate]

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,...
user1245262's user avatar
  • 7,495
2 votes
3 answers
747 views

Plot n graphs and save them in n different files

First and foremost, I'd like to precise that I am no expert in Python and still learning how to use pandas. I dig through older posts but I don't find a suitable answer. I've been trying to code a ...
Aurore's user avatar
  • 31
2 votes
1 answer
2k views

Save multiple plots on a single pdf-page using python

I want to save multiple (6) plots on one page of a pdf file using python. Currently, I'm saving every plot on a new page. pdf = matplotlib.backends.backend_pdf.PdfPages("output.pdf") for fig ...
luisa's user avatar
  • 82
0 votes
1 answer
3k views

.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. ...
MCK1886's user avatar
  • 13
-1 votes
1 answer
49 views

Set real dimensione of a Chart in Matplotlib

I need to set the dimension of a chart exactly. I tried this, but the result is not what I expected (both if I set px and cm). In addiction, I would like to know how to export correctly the image. ...
Nicola Talamonti's user avatar
1 vote
1 answer
457 views

Savefig not saving axes for png file

I'm having a trouble when trying to save plot to png file. When I tried with .jpg, everything was alright. So, the problem is that graph is not saved with axes and axes' titles, there is only the ...
user16096708's user avatar
1 vote
1 answer
92 views

Could not save whole figure of barplot with long yticklabel

I want to save a barplot, but found it was clipped when save it to a file. import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset("tips") sns.set_theme(font_scale=1.6)...
Jack Chen's user avatar
0 votes
1 answer
206 views

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 ...
Blackwidow's user avatar
0 votes
1 answer
43 views

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 ...
Nathali's user avatar
1 vote
0 answers
630 views

Matplotlib performance problem: savefig too slow, any alternative?

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 ...
moldersmut's user avatar
1 vote
0 answers
1k views

Why `plt.savefig` is so slow ? Could I somehow speed it up?

Creation of 100 charts in less then second, but writing them on disk on converting to base64 representation without writing them on disk takes 10 second, so the overhead is in creation of png/jpg ...
Qbik's user avatar
  • 6,107
0 votes
1 answer
373 views

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 ...
Jonah Dafilou's user avatar
0 votes
0 answers
311 views

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 # ...
Rob H.'s user avatar
  • 111