Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove top and right border from ggplot2 [duplicate]

Tags:

r

ggplot2

Is it possible to to remove the top and right border from ggplot2 graphs?

I.e, I'd like to keep the x and y-axis but remove the rest of the black frame that surrounds the graph.

//M

like image 667
Misha Avatar asked Oct 11 '22 10:10

Misha


2 Answers

see this thread, it deals specifically with the problem here

http://groups.google.com/group/ggplot2/browse_thread/thread/f998d113638bf251

and gives a solution that appears to work.

like image 139
Nelso Avatar answered Oct 17 '22 15:10

Nelso


You can add this to your plot

+ opts(panel.grid.minor = theme_blank()) 
+ opts(panel.grid.major = theme_blank()) 
+ opts(axis.line = theme_segment())

Since version 0.9.2, opts has been replaced by theme:

+ theme(panel.grid.minor = element_blank()) 
+ theme(panel.grid.major = element_blank()) 
+ theme(axis.line = element_segment())
like image 34
Sarah West Avatar answered Oct 17 '22 14:10

Sarah West