Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove whitespace around figure matplotlib

plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, 
            hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.savefig("filename.pdf", bbox_inches = 'tight',
    pad_inches = 0)

# contributor was unsure about how it works, but nonetheless, it works!
Comment

PREVIOUS NEXT
Code Example
Python :: datetime not defined python 
Python :: exception get line number python 
Python :: how to split a string between letters and digits python 
Python :: read file line by line into list 
Python :: python datetime now only hour and minute 
Python :: python iterate dictionary in reverse order 
Python :: matplotlib grid 
Python :: pandas columns starting with 
Python :: python randomise between 0 or 1 
Python :: how to receive password using tkinter entry 
Python :: pandas.core.indexes.base.index to list 
Python :: how to install flask module in vscode 
Python :: opencv get area of contour 
Python :: jupyter notebook pass python variable to shell 
Python :: initialize pandas dataframe with column names 
Python :: python clone object 
Python :: pandas dataframe from dict 
Python :: time it in jupyter notebook 
Python :: make length string in pandas 
Python :: python read url 
Python :: pandas capitalize column 
Python :: update anaconda 
Python :: save matplotlib figure with base64 
Python :: RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() 
Python :: count how many duplicates python pandas 
Python :: reload all extensions discord.py 
Python :: python calculate age from date of birth 
Python :: plotly plot size 
Python :: pydrive list folders 
Python :: web3py to wei 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =