import matplotlib.pyplot as plt
import numpy as np
Matplotlib
np.random.randn()
-2.5106811179598463
= np.random.rand(10,1)
x = np.random.rand(10,1)
y '.')
plt.plot(x,y, plt.show()
def plot_means_and_stdevs(x1, y1, x2, y2):
= plt.subplots(1,3, figsize=(10,3))
fig, axs for i in range(3):
'.')
axs[i].plot(x1[:,i], y1[:,i], '.')
axs[i].plot(x2[:,i], y2[:,i], 'means')
axs[i].set_xlabel('stdev')
axs[i].set_ylabel(f'Channel #{i+1}')
axs[i].set_title('eval', 'train'])
axs[i].legend([ plt.show()
= np.random.rand(10,3)
x1 = np.random.rand(10,3)
y1 = np.random.rand(10,3)
x2 = np.random.rand(10,3)
y2 plot_means_and_stdevs(x1, y1, x2, y2)
A somewhat quicker method without using axes and figsize is to use plt.subplot
(note that index is 1-based):
for i in range(3):
1,3,i+1)
plt.subplot('.')
plt.plot(x1[:,i], y1[:,i], '.')
plt.plot(x2[:,i], y2[:,i], 'means')
plt.xlabel('stdev')
plt.ylabel(f'Channel #{i+1}')
plt.title('eval', 'train'])
plt.legend([ plt.show()
To remove axes use:
'off') plt.axis(
To save image:
"test.png", bbox_inches='tight') plt.savefig(
<Figure size 640x480 with 0 Axes>