import os
import matplotlib.pyplot as plt
import numpy as np
os.chdir('/home/vg/Downloads/projects/ex13')
os.getcwd()
fig,axes = plt.subplots(2,2,figsize=(6,6),sharex=True,sharey=True,squeeze=False)
x1=np.random.randn(100)
x2=np.random.randn(100)
axes[0,0].set_title("Uncorrelated")
axes[0,0].scatter(x1,x2)
axes[0,1].set_title("Weakly positively correlated")
axes[0,1].scatter(x1,x1+x2)
axes[1,0].set_title("Weakly negatively correlated")
axes[1,0].scatter(x1,-x1+x2)
axes[1,1].set_title("Strongly correlated")
axes[1,1].scatter(x1,x1+0.15*x2)
axes[1,1].set_xlabel("x")
axes[1,0].set_xlabel("x")
axes[0,0].set_ylabel("y")
axes[1,0].set_ylabel("y")
plt.subplots_adjust(left=0.1,right=0.95,bottom=0.1,top=0.95,wspace=0.1,hspace=0.2)
plt.savefig("example13.png", dpi=100)
plt.show()
plt.close()
Like this:
Like Loading...
Related
Recent Comments