#!/usr/bin/env python # coding: utf-8 # In[4]: import matplotlib.pyplot as plt import numpy as np get_ipython().run_line_magic('matplotlib', 'inline') # ### Other type of plots # # #### Regular Plots # In[9]: n = 256 X = np.linspace(-np.pi, np.pi, n, endpoint=True) Y = np.sin(2 * X) # plot 1 plt.plot(X, Y + 1, color='blue', alpha=1.00) # plot 2 plt.plot(X, Y - 1, color='blue', alpha=1.00) # In[6]: n = 256 X = np.linspace(-np.pi, np.pi, n, endpoint=True) Y = np.sin(2 * X) # plot 1 plt.plot(X, Y + 1, color='blue', alpha=1.00) plt.fill_between(X, 1, Y + 1, color='blue', alpha=.25) # plot 2 plt.plot(X, Y - 1, color='blue', alpha=1.00) plt.fill_between(X, -1, Y - 1, (Y - 1) > -1, color='blue', alpha=.25) plt.fill_between(X, -1, Y - 1, (Y - 1) < -1, color='red', alpha=.25) # #### Scatter Plots # In[7]: n = 1024 X = np.random.normal(0,1,n) Y = np.random.normal(0,1,n) plt.scatter(X,Y) # In[8]: n = 1024 X = np.random.normal(0, 1, n) Y = np.random.normal(0, 1, n) T = np.arctan2(Y, X) plt.axes([0.025, 0.025, 0.95, 0.95]) plt.scatter(X, Y, s=75, c=T, alpha=.5) plt.xlim(-1.5, 1.5) plt.xticks(()) plt.ylim(-1.5, 1.5) plt.yticks(()) plt.show() # #### Bar Plots # In[10]: n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) plt.bar(X, +Y1, facecolor='#9999ff', edgecolor='white') plt.bar(X, -Y2, facecolor='#ff9999', edgecolor='white') for x, y in zip(X, Y1): plt.text(x + 0.4, y + 0.05, '%.2f' % y, ha='center', va='bottom') plt.ylim(-1.25, +1.25) # In[11]: n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) plt.axes([0.025, 0.025, 0.95, 0.95]) plt.bar(X, +Y1, facecolor='#9999ff', edgecolor='white') plt.bar(X, -Y2, facecolor='#ff9999', edgecolor='white') for x, y in zip(X, Y1): plt.text(x + 0.4, y + 0.05, '%.2f' % y, ha='center', va= 'bottom') for x, y in zip(X, Y2): plt.text(x + 0.4, -y - 0.05, '%.2f' % y, ha='center', va= 'top') plt.xlim(-.5, n) plt.xticks(()) plt.ylim(-1.25, 1.25) plt.yticks(()) # In[ ]: