Only one edge facet_grid

I would like to use a facet grid to only display the right margin and not the bottom margin.

Sample code

library(ggplot2)
qplot(mpg, wt, data=mtcars) + facet_grid(cyl ~ vs, margins=TRUE) 

      

Current result enter image description here

Desired result enter image description here

+3


source to share


1 answer


qplot(mpg, wt, data=mtcars) + facet_grid(cyl ~ vs, margins="vs") 

      

enter image description here




When this answer was written, this behavior was not documented. It is now in the facet_grid documentation

fields are either a boolean value or a character character. Fields are additional faces that contain all data for each of the possible values โ€‹โ€‹of the cut variables. If FALSE

, additional faces are not included (default). If TRUE

, fields are included for all faceted variables. If specified as a character vector, these are the variable names for which you want to create fields.

(Thanks @Harry for that.)

+4


source







All Articles