Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import re
  5. import seaborn as sns
  6.  
  7. groupFig = plt.figure(num=None, figsize=(10,10), dpi=80, facecolor='w', edgecolor='k') # Set up the group figure, for all of the data
  8.  
  9. df = pd.read_csv('cdk.csv') # Get the data
  10.  
  11. l = 0 # some counters
  12. m = 0
  13.  
  14. for i in range(0,len(df.index)):
  15. rowKeys = df.iloc[i].keys()
  16.  
  17. singleFig = plt.figure(num=None, figsize=(10,10), dpi=80, facecolor='w', edgecolor='k') # Set up the single figure, for each individual row of data. I put it in the loop thinking it might recreate it every time, but to no avail.
  18. ax2 = singleFig.add_subplot(111) # I think I need this to have multiple series on one graph
  19.  
  20. x=[] # open array for x and y
  21. y=[]
  22.  
  23. for j in range(0,len(df.iloc[i])): # for all the values in the row
  24. if rowKeys[j].startswith("Venus_Activity at") and pd.isnull(df.iloc[i][j]) == False: # Scrape rows that contain y data, but only if the data isn't NaN
  25. y.append(df.iloc[i][j]) # add y values to the array
  26. x.extend(re.findall('d+.?d*', rowKeys[j])) # scrape only the number from the row, use it as x
  27. x = map(float,x) # but they have to be float in order to work later
  28.  
  29. ax1.plot(x, y) # for each compound, plot into my group figure
  30. ax2.plot(x, y) # for each compound, plot into the single figure
  31. groupFig.savefig(r'Plot/cdk/Plot' + str(i) + '.png') # save each single figure individually
  32. # ax2.cla() # I want to clear the figure here, but it doesn't work. It wants plt.cla() but that effects both figures...
  33.  
  34. groupFig.savefig(r'Plot/cdk/CDK plot.png') # Save the completed group figure
  35. plt.close() # clean up
  36.  
  37. import numpy as np
  38. import matplotlib.pyplot as plt
  39. import seaborn as sns
  40.  
  41. full_fig, full_ax = plt.subplots()
  42. x = np.arange(5)
  43.  
  44. for i, color in zip(range(1, 4), sns.color_palette()):
  45.  
  46. part_fig, part_ax = plt.subplots(subplot_kw=dict(ylim=(0, 12)))
  47. y = x * i
  48. full_ax.plot(x, y, c=color)
  49. part_ax.plot(x, y, c=color)
  50. part_ax.set_title("Part %d" % i)
  51. part_fig.savefig("part_%d.png" % i)
  52. full_ax.set_title("Full")
  53. full_fig.savefig("full_png")
  54.  
  55. import numpy as np
  56. import matplotlib.pyplot as plt
  57.  
  58. plt.figure(figsize=(4,3))
  59. plt.plot(list(x for x in range(1,50,5)), list(x*x for x in range(1,11)))
  60.  
  61. plt.figure(figsize=(8,6))
  62. plt.plot(list(x for x in range(1,100,5)), list(x*x for x in range(1,21)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement