Created
October 13, 2015 11:55
-
-
Save Rekyt/3e28e33ee8754310c52f to your computer and use it in GitHub Desktop.
How to use the 'stroke' option of geom_point in ggplot2 R package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For the moment, ggplot2 stable version cannot support the option 'geom_point(stroke = 2)' to change border size of points | |
# To use it we need to install ggplot2 development version | |
# To do that we first want to install 'devtools' package which makes packages installation from GitHub easier | |
install.packages("devtools") | |
# 'ggplot2' last version is at 'http://github.com/hadley/ggplot2/' | |
# thus using devtools' function 'install_github()' (install from GitHub) the syntax is simple: | |
devtools::install_github("hadley/ggplot2") # Note the use of '::' not to load the entire package | |
# Plots | |
ggplot(mtcars, aes(x = mpg, y = disp, colour = as.factor(vs), fill = as.factor(cyl)) + | |
geom_point(size = 4, stroke = 5) | |
# Does not work, why? Because the default circle shape for points does not have both 'fill' and 'colour' attributes | |
# Only shapes with 'pch' between 21 and 25 do | |
# Working plot | |
ggplot(mtcars, aes(x = mpg, y = disp, colour = as.factor(vs), fill = as.factor(cyl)) + | |
geom_point(size = 4, stroke = 5, pch = 21) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See I don't understand this