Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to set the line end style or the line join style in ggplot?

Tags:

r

ggplot2

For a description of the line end and line join styles available in R, see http://students.washington.edu/mclarkso/documents/line%20styles%20Ver2.pdf

For ggplot, I already searched in plot_theme() and the github list of ggplot2 opts https://github.com/hadley/ggplot2/wiki/%2Bopts%28%29-List but found no leads, so I'm thinking it's not possible to change these in ggplot.

like image 991
Alex Holcombe Avatar asked Jan 05 '12 04:01

Alex Holcombe


1 Answers

A search with Baron's website (linked from RSiteSearch) brings up this method for setting the grid's lineend parameter. 'gglot2' functions uses the grid package so searching with grid-terms like lineend will be more productive for ferreting out obscure features:

http://finzi.psych.upenn.edu/R/library/ggplot2/html/geom_path.html

 xy <- data.frame(x = rep(c(1:3,3:9), times=3), y = rep(10:1, times=3), 
                 type = rep(LETTERS[1:2], each=5), type2 = rep(LETTERS[3:5], each=10))
 myplot <- ggplot(data = xy)+
                  geom_path(aes(x = x, y = y), size=4, lineend="butt", 
                             linejoin="mitre")+facet_grid(type ~ type2)
 myplot

(I was not convinced that all the linejoin parameter were being acted upon, but the lineend settings were being honored and the round joins were definitely different.)

like image 69
IRTFM Avatar answered Sep 26 '22 03:09

IRTFM