Is there a possibility to scale the plot size of matplotlib plots in jupyter notebooks? You could increase the plot size by changing the default values of figure.figsize
, but this does not affect parameters like fontsize, linewidth, markersize etc. What I need is a plot where all the parameters are scaled accordingly.
P.S.: To display plots in jupyter notebooks I use %matplotlib inline
, see screenshot below.
For completeness, here is a code snippet doing exactly what I needed:
def scale_plot_size(factor=1.5):
import matplotlib as mpl
default_dpi = mpl.rcParamsDefault['figure.dpi']
mpl.rcParams['figure.dpi'] = default_dpi*factor
Next, to increase the size of the plot in the jupyter notebook use plt. rcParams[“figure. figsize”] method and set width and height of the plot.
You don't want to change the figure size. You want to change the dpi (dots per inch).
Also see Relationship between dpi and figure size.
import matplotlib.pyplot as plt
%matplotlib inline
def plot(dpi):
fig, ax=plt.subplots(dpi=dpi)
ax.plot([2,4,1,5], label="Label")
ax.legend()
for i in range(1,4):
plot(i*72)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With