Skip to content

Instantly share code, notes, and snippets.

@Rekyt
Created October 13, 2015 11:55
Show Gist options
  • Save Rekyt/3e28e33ee8754310c52f to your computer and use it in GitHub Desktop.
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
# 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)
@Shri333
Copy link

Shri333 commented Jun 13, 2020

See I don't understand this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment