Answers for "matplotlib plot two graphs side by side"

0

matplotlib plot two graphs side by side

import matplotlib.pyplot as plt
import numpy as np

# Simple data to display 
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

# the container holding the two Axes have already been unpacked
# useful if just few Axes have been created
f, (ax1, ax2) = plt.subplots(1, 2) 
ax1.plot(x, y)
ax1.set_title('Left plot')

ax2.scatter(x, y)
ax2.set_title('Right plot')

plt.tight_layout()
plt.show()
Posted by: Guest on May-19-2021

Code answers related to "matplotlib plot two graphs side by side"

Python Answers by Framework

Browse Popular Code Answers by Language