In [2]:
# import
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [60]:
# generating some data points
X = np.linspace(-np.pi, np.pi, 35, endpoint=True)
C, S= np.cos(X), np.sin(X)
In [64]:
fig = plt.figure()
f, axes = plt.subplots(1, 3) # 1 row and 3 columns
# Using subplot
axes[0].plot(X, C, '.')
axes[0].set_ylabel('Cos')
axes[1].plot(X, S, '-')
axes[1].set_ylabel('Sin')
axes[2].plot(X, S+0.1, 'o')
axes[2].set_ylabel('MSin')
Out[64]:
In [65]:
plt.clf() # clear the plot
In [77]:
fig = plt.figure()
ax=fig.add_subplot(131)
ax.plot(X, C, '.')
ax=fig.add_subplot(133)
ax.plot(X, S)
Out[77]:
In [78]:
plt.clf()
Chossing Plotting CoOrdinates
In [96]:
fig = plt.figure()
ax=fig.add_subplot(331) # plot coordinates - 1st of (3,3) plot grid
ax.plot(X, C, '.')
ax=fig.add_subplot(323) # plot coordinates - 3rd of (3,2) plot grid
ax.plot(X, S+0.2)
ax=fig.add_subplot(324) # plot coordinates - 4th of (3,2) plot grid
ax.plot(X, S)
ax=fig.add_subplot(338) # plot coordinates - 8th of (3,3) plot grid
ax.plot(X, S)
Out[96]:
Another Example
In [97]:
plt.clf()
fig = plt.figure()
ax=fig.add_subplot(431) # plot coordinates - 1st of (4,3) plot grid
ax.plot(X, C, '.')
ax=fig.add_subplot(423) # plot coordinates - 3rd of (4,2) plot grid
ax.plot(X, S+0.2)
ax=fig.add_subplot(424) # plot coordinates - 4th of (4,2) plot grid
ax.plot(X, S)
ax=fig.add_subplot(438) # plot coordinates - 8th of (4,3) plot grid
ax.plot(X, S)
ax=fig.add_subplot(234) # plot coordinates - 4th of (2,3) plot grid
ax.plot(X, C*0.4)
Out[97]:
Adding diffrent plots into one subplot
In [137]:
#plt.clf()
plt.plot(X, C)
plt.show()
In [138]:
plt.plot(X, S)
plt.show()
In [134]:
plt.plot(X, S*0.3)
Out[134]:
In [121]:
20.8 % 10
Out[121]:
In [130]:
a = [1,2,3,4]
b = [4,7,3,4]
list(zip(a,b))
Out[130]:
In [131]:
a == b
Out[131]:
In [ ]: