Guest User

Untitled

a guest
Apr 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #+NAME: R_plot
  2. #+BEGIN_SRC R :exports both :results output graphics :file r_comparison.png
  3. # graph in R
  4. library("ggplot2")
  5. performance <- read.csv("comparison.csv", header=FALSE)$V1
  6. df <- data.frame(resource = c("1node1core", "1node8core", "2node8core"), performance = performance)
  7. p <- ggplot(data = df, aes(x=resource, y=performance)) +
  8. geom_bar(stat="identity", fill="steelblue") +
  9. theme_minimal() +
  10. ggtitle("Computation time (min) vs. Resource (type)")
  11. p
  12. #+END_SRC
  13.  
  14. #+NAME: python_plot
  15. #+BEGIN_SRC python :exports both :results output graphics :file py_comparison.png
  16. import matplotlib.pyplot as plt; plt.rcdefaults()
  17. import matplotlib.pyplot as plt
  18. import csv
  19.  
  20. objects = ['1node1core', '1node8core', '2node8core']
  21. y_pos = list(range(0, len(objects)))
  22.  
  23. performance = []
  24. with open('comparison.csv', newline='') as csvfile:
  25. reader = csv.reader(csvfile)
  26. for row in reader:
  27. f_row = float(row[0])
  28. performance.append(f_row)
  29.  
  30. plt.bar(y_pos, performance, align='center', alpha=0.5)
  31. plt.xticks(y_pos, objects)
  32. plt.ylabel('Time')
  33. plt.title('Resource vs. Time')
  34.  
  35. plt.show()
  36. #+END_SRC
Add Comment
Please, Sign In to add comment