Created
November 30, 2019 16:05
-
-
Save tkshnkmr/e47d9904d26d681008baab35e1be58b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# Input x, output y | |
x = np.linspace(0, 2*np.pi, 400) | |
y = np.sin(x**2) | |
# Creates figure first | |
my_dpi = 40 | |
fig = plt.figure(figsize=(20, 10), dpi=my_dpi) | |
print(fig) | |
fig.suptitle('Subplot example3-1: Add subplot later', fontsize=20) | |
# Add plots | |
ax1 = fig.add_subplot(1, 3, 1) | |
ax1.plot(x, y) | |
ax1.set_xlabel('X label, plot1') | |
ax1.set_ylabel('Y label, plot1') | |
ax1.set_xticklabels('') | |
ax1.set_yticklabels('') | |
ax2 = fig.add_subplot(1, 3, 2) | |
ax2.plot(x, y) | |
ax2.set_xlabel('X label, plot2') | |
ax2.set_ylabel('Y label, plot2') | |
ax3 = fig.add_subplot(1, 3, 3) | |
ax3.set_xlabel('X label, plot3') | |
ax3.set_ylabel('Y label, plot3') | |
fig.savefig('Subplot_ex3.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment