Matplotlib: Difference between revisions

No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 11: Line 11:
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
</syntaxhighlight>
</syntaxhighlight>
===Set size===
<syntaxhighlight lang="python">
f, ax = plt.subplots(figsize=(5, 3))
# or
plt.figure(figsize=(5, 3))
plt.tight_layout()
</syntaxhighlight>
===Saving a plot===
===Saving a plot===
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Line 30: Line 39:
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
</syntaxhighlight>
===Multiple Figures===
<syntaxhighlight lang="python">
f, axarr = plt.subplots(3,1)
axarr[0].imshow(np.clip(x_val[0, 0, :, :, :].numpy(), 0, 1))
axarr[1].imshow(np.clip(val_image[0, :, :, :].numpy(), 0, 1))
axarr[2].imshow(np.clip(y_val[0, :, :, :].numpy(), 0, 1))
</syntaxhighlight>
</syntaxhighlight>


==Animations==
==Animations==
* [https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c Animations with Matplotlib]
* [https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c Animations with Matplotlib]