Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- set.seed(1)
- mydata = data.frame(x = runif(20),
- y = runif(20))
- mydata = mydata %>%
- mutate(x = round(x, 2)) %>%
- mutate(y = round(y, 2)) %>%
- mutate(color = round(x - y,2)) %>%
- mutate(shape = gl(3,20/3))
- #write_csv(mydata, 'color-and-shape.csv')
- ggplot(mydata, aes(x = x, y = y, color = color, shape = shape)) +
- geom_point(size = 5)
- ggsave('color-and-shape.png', width = 7, height = 5)
- documentclass[margin=2pt]{standalone}
- usepackage{filecontents}
- begin{filecontents*}{color-and-shape.csv}
- x,y,color,shape
- 0.27,0.93,-0.66,1
- 0.37,0.21,0.16,1
- 0.57,0.65,-0.08,1
- 0.91,0.13,0.78,1
- 0.2,0.27,-0.07,1
- 0.9,0.39,0.51,1
- 0.94,0.01,0.93,2
- 0.66,0.38,0.28,2
- 0.63,0.87,-0.24,2
- 0.06,0.34,-0.28,2
- 0.21,0.48,-0.27,2
- 0.18,0.6,-0.42,2
- 0.69,0.49,0.2,3
- 0.38,0.19,0.19,3
- 0.77,0.83,-0.06,3
- 0.5,0.67,-0.17,3
- 0.72,0.79,-0.07,3
- 0.99,0.11,0.88,3
- 0.38,0.72,-0.34,1
- 0.78,0.41,0.37,1
- end{filecontents*}
- usepackage{pgfplots}
- pgfplotsset{width=7cm,compat=newest}
- begin{document}
- begin{tikzpicture}
- begin{axis}[colorbar horizontal]
- addplot[scatter,only marks,point meta=explicit] table
- [x=x,y=y,meta=color,col sep=comma] {color-and-shape.csv};
- end{axis}
- end{tikzpicture}
- end{document}
Add Comment
Please, Sign In to add comment