-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscatterplot_ggplot2.r
More file actions
30 lines (16 loc) · 864 Bytes
/
scatterplot_ggplot2.r
File metadata and controls
30 lines (16 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ggplot(diamonds,aes(x=carat, y= price)) +geom_point()
#instead of having to rewrite the ggplot multiple times, we assign it as a variable.
g <- ggplot(diamonds,aes(x=carat, y= price)) # this is a variable.
g + geom_point()
g + geom_point(aes(color=color))
ggplot(diamonds,aes(x=carat, y= price)) +geom_point()
#instead of having to rewrite the ggplot multiple times, we assign it as a variable.
g <- ggplot(diamonds,aes(x=carat, y= price)) # this is a variable.
g + geom_point()
g + geom_point(aes(color=color))
g + geom_point(aes(color=color, shape=clarity))
# The shape palette can deal with a maximum of 6 discrete values
#because more than 6 becomes difficult to discriminate; you have
# 8. Consider specifying shapes manually if you must have them.
#too busy plot.
g + geom_point(aes(color=color, shape=cut))