Guest User

Untitled

a guest
Oct 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. library(tidyverse)
  2.  
  3. set.seed(1)
  4. mydata = data.frame(x = runif(20),
  5. y = runif(20))
  6. mydata = mydata %>%
  7. mutate(x = round(x, 2)) %>%
  8. mutate(y = round(y, 2)) %>%
  9. mutate(color = round(x - y,2)) %>%
  10. mutate(shape = gl(3,20/3))
  11. #write_csv(mydata, 'color-and-shape.csv')
  12.  
  13. ggplot(mydata, aes(x = x, y = y, color = color, shape = shape)) +
  14. geom_point(size = 5)
  15. ggsave('color-and-shape.png', width = 7, height = 5)
  16.  
  17. documentclass[margin=2pt]{standalone}
  18.  
  19. usepackage{filecontents}
  20. begin{filecontents*}{color-and-shape.csv}
  21. x,y,color,shape
  22. 0.27,0.93,-0.66,1
  23. 0.37,0.21,0.16,1
  24. 0.57,0.65,-0.08,1
  25. 0.91,0.13,0.78,1
  26. 0.2,0.27,-0.07,1
  27. 0.9,0.39,0.51,1
  28. 0.94,0.01,0.93,2
  29. 0.66,0.38,0.28,2
  30. 0.63,0.87,-0.24,2
  31. 0.06,0.34,-0.28,2
  32. 0.21,0.48,-0.27,2
  33. 0.18,0.6,-0.42,2
  34. 0.69,0.49,0.2,3
  35. 0.38,0.19,0.19,3
  36. 0.77,0.83,-0.06,3
  37. 0.5,0.67,-0.17,3
  38. 0.72,0.79,-0.07,3
  39. 0.99,0.11,0.88,3
  40. 0.38,0.72,-0.34,1
  41. 0.78,0.41,0.37,1
  42. end{filecontents*}
  43.  
  44. usepackage{pgfplots}
  45. pgfplotsset{width=7cm,compat=newest}
  46.  
  47. begin{document}
  48. begin{tikzpicture}
  49. begin{axis}[colorbar horizontal]
  50. addplot[scatter,only marks,point meta=explicit] table
  51. [x=x,y=y,meta=color,col sep=comma] {color-and-shape.csv};
  52. end{axis}
  53. end{tikzpicture}
  54. end{document}
Add Comment
Please, Sign In to add comment