sqjin / CellChat

R toolkit for inference, visualization and analysis of cell-cell communication from single-cell data
GNU General Public License v3.0
614 stars 140 forks source link

plotGeneExpression add legend #282

Open hahia opened 2 years ago

hahia commented 2 years ago

Does anyone know how to add legend on plotGeneExpression when I use the split.by parameter? thank you for your help.

sqjin commented 2 years ago

@hahia The order of the violin plot is based on the factor order in the 'split.by' variable. I will take a look to see how to add one.

csijcs commented 2 years ago

In the modify_vlnplot function the legend.position is set to "none". If you alter that you will get a legend for each separte violin plot. If you want one legend for the entire plot then add + plot_layout(guides = "collect") to the p <- patchwork::wrap_plots(plotlist = plot_list, ncol = 1) in the StackedVlnPlot function