I have performed a Seurat PCA via Dimplot.

How do I extend the x axis?

As you can see in my figure the double x axes overlap. enter image description here

  • $\begingroup$ Could you please add some context around your question, so we can understand why you want to do this? What are your trying to produce? How did you generate this plot? $\endgroup$
    – gringer
    Nov 30, 2022 at 11:34

2 Answers 2


Looking at the source code for Seurat's DimPlot() it's based on ggplot2 graphics (https://github.com/satijalab/seurat/blob/HEAD/R/visualization.R#L794), so you can manipulate the dimplot object and save it using ggplot2 commands. Using ggsave() you can specify the figure dimensions; if you increase the width of the final figure it should 'fix' your label overlap issue, i.e.

#> Attaching SeuratObject
library(ggplot2) # for plotting
library(cowplot) # for the theme used by Seurat

# example data
p <- DimPlot(object = pbmc_small, split.by = "ident")

# example dimplot

# increase font size to make the labels overlap
p +
  theme_cowplot(font_size = 28) +
  theme(strip.background = element_blank())

# save the 'overlapping label' figure and specify a relatively large width to 'space out' the three facets
ggsave("dimplot_test.png", width = 40, height = 10, units = "cm")


You could also decrease the font size and keep the original dimensions to fix the problem, or alter the breaks on the x axis, e.g.

# reduce the size of the x axis text labels
p +
  theme_cowplot() +
  theme(strip.background = element_blank(),
        axis.text.x = element_text(size = 8))

# change the number of breaks
p +
  theme_cowplot() +
  theme(strip.background = element_blank()) +
  scale_x_continuous(breaks = scales::pretty_breaks(n = 2))

# Specify the breaks you want to use
p +
  theme_cowplot() +
  theme(strip.background = element_blank()) +
  scale_x_continuous(breaks = c(-20, 0, 20, 40))

Created on 2022-12-01 with reprex v2.0.2


As a direct answer to your question, restrict the output to producing a single column:

Dimplot(..., ncol=1)

But this doesn't seem like a useful answer. Please provide more context to your question if you want more help than this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.