Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. fig,ax = plt.subplots(figsize = (20,16))
  2.  
  3. b=ax.contourf(dfE,4,cmap='Greens', alpha=0.5, linewidths=(3,))
  4. cbax2 = fig.add_axes([0.91, 0.41, 0.02, 0.2])
  5. cb2 = plt.colorbar(b, cax=cbax2)
  6.  
  7. d = ax.contourf(dfH,4,cmap='Reds', linewidths=(3,), alpha=0.5)
  8. cbax4 = fig.add_axes([0.91, 0.19, 0.02, 0.2])
  9. cb4 = plt.colorbar(d, cax=cbax4)
  10.  
  11. f = ax.contourf(dfS,3,cmap='Wistia', linewidths=(3,), alpha=0.5)
  12. cbax6 = fig.add_axes([0.97, 0.41, 0.02, 0.2])
  13. cb6 = plt.colorbar(f, cax=cbax6)
  14.  
  15. g = ax.contourf(dfT,4,cmap='Purples', linewidths=(2,), alpha=0.5)
  16. cbax7 = fig.add_axes([0.97, 0.63, 0.02, 0.2])
  17. cb7 = plt.colorbar(g, cax=cbax7)
  18.  
  19. h = ax.contourf(dfC,4,cmap='Blues', linewidths=(3,), alpha=0.5)
  20. cbax8 = fig.add_axes([0.91, 0.63, 0.02, 0.2])
  21. cb8 = plt.colorbar(h, cax=cbax8)
  22.  
  23. ax.set_ylim([0, 16])
  24. ax.set_xlim([0, 16])
  25.  
  26. ax.set_xlabel('Principal Component 1', size = 25)
  27. ax.set_ylabel('Principal Component 2', size = 25)
  28.  
  29. cb4.set_label('Helix (H)',size = 15)
  30. cb2.set_label('Sheet (E)',size = 15)
  31. cb8.set_label('Other (C)',size = 15)
  32. cb7.set_label('H-Bonded Turn (T)',size = 15)
  33. cb6.set_label('Bend (S)',size = 15)
  34.  
  35. ax.set_title('8-State PCA Analysis: 108 Dimensions', size = 30)
  36. plt.show()
  37.  
  38. import numpy as np
  39. from matplotlib import pyplot as plt
  40.  
  41. #Create the grid
  42. x = np.arange(-20,21,1)
  43. y=x
  44. X,Y = np.meshgrid(x,y)
  45.  
  46. #Create the functions to plot
  47. Z1 = 1000-np.abs(X**2+(Y+4)**3)
  48. Z2 = 1000-np.abs((X+4)**3+Y**3)
  49. Z3 = 1000-np.abs((Y+2)**3+(X-3)**3)
  50. Z4 = 1000-np.abs(X**2+Y**3-1)
  51.  
  52.  
  53.  
  54. fig = plt.figure(figsize=(8,8))
  55.  
  56. ax = plt.subplot(111)
  57.  
  58. #Plot using contourf making sure you set your contour levels and don't show the lowest levels
  59. b=ax.contourf(X,Y,Z1/np.nanmax(Z1),[.25,.5,.75],alpha=.5,cmap='Greens',linewidths=3,extend='max')
  60. d=ax.contourf(X,Y,Z2/np.nanmax(Z2),[.25,.5,.75],alpha=.5,cmap='Reds',linewidths=3,extend='max')
  61. f=ax.contourf(X,Y,Z3/np.nanmax(Z3),[.25,.5,.75],alpha=.5,cmap='Blues',linewidths=3,extend='max')
  62. g=ax.contourf(X,Y,Z4/np.nanmax(Z4),[.25,.5,.75],alpha=.5,cmap='Purples',linewidths=3,extend='max')
  63.  
  64. plt.show()
  65.  
  66. import numpy as np
  67. from matplotlib import pyplot as plt
  68.  
  69. #Create the grid
  70. x = np.arange(-20,21,1)
  71. y=x
  72. X,Y = np.meshgrid(x,y)
  73.  
  74. #Create the functions to plot
  75. Z1 = 1000-np.abs(X**2+(Y+4)**3)
  76. Z2 = 1000-np.abs((X+4)**3+Y**3)
  77. Z3 = 1000-np.abs((Y+2)**3+(X-3)**3)
  78. Z4 = 1000-np.abs(X**2+Y**3-1)
  79.  
  80.  
  81.  
  82. fig = plt.figure(figsize=(8,8))
  83.  
  84. ax = plt.subplot(111)
  85.  
  86. #Plot using contour instead of contourf and change the colors
  87. b=ax.contour(X,Y,Z1/np.nanmax(Z1),[.25,.5,.75],alpha=.8,colors='Green',linewidths=3)
  88. d=ax.contour(X,Y,Z2/np.nanmax(Z2),[.25,.5,.75],alpha=.8,colors='Red',linewidths=3)
  89. f=ax.contour(X,Y,Z3/np.nanmax(Z3),[.25,.5,.75],alpha=.8,colors='Blue',linewidths=3)
  90. g=ax.contour(X,Y,Z4/np.nanmax(Z4),[.25,.5,.75],alpha=.8,colors='Purple',linewidths=3,linestyles='dashed')
  91.  
  92. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement