satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.24k stars 902 forks source link

plot.margin in the theme() function can't work for FeaturePlot and AugmentPlot #5731

Closed Sophia409 closed 2 years ago

Sophia409 commented 2 years ago

Hi,

I want to change the plot margin for multiple FeaturePlots. But when I set combine = F, plot.margin in the theme() function can't work and returns NULL. Also, I try to change the plot margin for multiple AugmentPlots, it fails again.

Any comments will be greatly appreciated.

Sophia

# plot.margin in theme can not work for FeaturePlot
> baseplot <- FeaturePlot(object=SeuratObject,features=c('LHX8','LHX9'),raster = T,combine = F)+theme(plot.margin = margin(0.1, 0.1, 0.1, 0.1, "mm"))
Rasterizing points since number of points exceeds 100,000.
To disable this behavior set `raster=FALSE`
Rasterizing points since number of points exceeds 100,000.
To disable this behavior set `raster=FALSE`
> baseplot
NULL

# plot.margin in theme can not work for AugmentPlot
>baseplot <- FeaturePlot(object=SeuratObject,features=c('LHX8','LHX9'),raster = T,combine = F)
>baseplot
[[1]]

[[2]]

>baseplot <- lapply(X = baseplot, FUN = function(x) AugmentPlot(x))+theme(plot.margin = margin(0.1, 0.1, 0.1, 0.1, "mm"))
baseplot
NULL

# aspect.ratio in theme can work
> baseplot <- FeaturePlot(object=SeuratObject,features=c('LHX8','LHX9'),raster = T,combine = F)
Rasterizing points since number of points exceeds 100,000.
To disable this behavior set `raster=FALSE`
Rasterizing points since number of points exceeds 100,000.
To disable this behavior set `raster=FALSE`
> baseplot <- lapply(X = baseplot, FUN = function(x) AugmentPlot(x)+theme(aspect.ratio = 1))
> baseplot
[[1]]

[[2]]
yuhanH commented 2 years ago

Here is an example using pbmc_small:

plot.list <- FeaturePlot(pbmc_small, features = c('PPBP', 'GNLY'), combine = FALSE)
plot.list <- lapply(plot.list, function(x) x  + theme(plot.margin = margin(0.1, 0.1, 0.1, 0.1, "mm")))