<p>Looking at the source code for Seurat's <code>DimPlot()</code> it's based on ggplot2 graphics (<a href="https://github.com/satijalab/seurat/blob/HEAD/R/visualization.R#L794" rel="nofollow noreferrer">https://github.com/satijalab/seurat/blob/HEAD/R/visualization.R#L794</a>), so you can manipulate the dimplot object and save it using ggplot2 commands. Using <code>ggsave()</code> you can specify the figure dimensions; if you increase the width of the final figure it should 'fix' your label overlap issue, i.e.</p>
<pre class="lang-r prettyprint-override"><code>#BiocManager::install(&quot;Seurat&quot;)
library(Seurat)
#&gt; Attaching SeuratObject
library(ggplot2) # for plotting
library(cowplot) # for the theme used by Seurat

# example data
data(&quot;pbmc_small&quot;)
p &lt;- DimPlot(object = pbmc_small, split.by = &quot;ident&quot;)

# example dimplot
p
</code></pre>
<p><img src="https://i.sstatic.net/P5FmK.png" alt="" /></p>
<pre class="lang-r prettyprint-override"><code># increase font size to make the labels overlap
p +
  theme_cowplot(font_size = 28) +
  theme(strip.background = element_blank())
</code></pre>
<p><img src="https://i.sstatic.net/R0m1g.png" alt="" /></p>
<pre class="lang-r prettyprint-override"><code># save the 'overlapping label' figure and specify a relatively large width to 'space out' the three facets
ggsave(&quot;dimplot_test.png&quot;, width = 40, height = 10, units = &quot;cm&quot;)
</code></pre>
<p><a href="https://i.sstatic.net/88ZWH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/88ZWH.png" alt="final.png" /></a></p>
<hr />
<p>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.</p>
<pre class="lang-r prettyprint-override"><code># reduce the size of the x axis text labels
p +
  theme_cowplot() +
  theme(strip.background = element_blank(),
        axis.text.x = element_text(size = 8))
</code></pre>
<p><img src="https://i.sstatic.net/ojFaU.png" alt="" /></p>
<pre class="lang-r prettyprint-override"><code># change the number of breaks
p +
  theme_cowplot() +
  theme(strip.background = element_blank()) +
  scale_x_continuous(breaks = scales::pretty_breaks(n = 2))
</code></pre>
<p><img src="https://i.sstatic.net/sEMYl.png" alt="" /></p>
<pre class="lang-r prettyprint-override"><code># Specify the breaks you want to use
p +
  theme_cowplot() +
  theme(strip.background = element_blank()) +
  scale_x_continuous(breaks = c(-20, 0, 20, 40))
</code></pre>
<p><img src="https://i.sstatic.net/Yfdwy.png" alt="" /></p>
<p><sup>Created on 2022-12-01 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>

CC BY-SA 4.0
2022-12-01T02:44:12.110Z
2022-12-01T02:44:12.110Z
jared_mamrot
<p>As a direct answer to your question, restrict the output to producing a single column:</p>
<pre><code>Dimplot(..., ncol=1)
</code></pre>
<p>But this doesn't seem like a useful answer. Please provide more context to your question if you want more help than this.</p>

CC BY-SA 4.0
2022-11-30T11:33:08.760Z
2022-11-30T11:33:08.760Z
gringer
<p>I have performed a Seurat PCA via <a href="https://satijalab.org/seurat/reference/dimplot" rel="nofollow noreferrer">Dimplot</a>.</p>
<p>How do I extend the x axis?</p>
<p>As you can see in my figure the double x axes overlap. <a href="https://i.sstatic.net/Jf7Ym.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Jf7Ym.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-11-30T11:34:12.103Z
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?
gringer
<seurat><single-cell>
How to extend the x axis in Dimplot Seurat
# How to extend the x axis in Dimplot Seurat

(Asked by: username_0 on 2022-11-28)

I have performed a Seurat PCA via [Dimplot](https://satijalab.org/seurat/reference/dimplot).

How do I extend the x axis?

As you can see in my figure the double x axes overlap. [![enter image description here](https://i.sstatic.net/Jf7Ym.png)](https://i.sstatic.net/Jf7Ym.png)

**Tags:** seurat, single-cell
> **Comments:**
> **username_1**: 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?  

---

## 2 answers

### Answer by username_2 on 2022-12-01. Score: 1 | Accepted answer

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.
#BiocManager::install("Seurat")
library(Seurat)
#> Attaching SeuratObject
library(ggplot2) # for plotting
library(cowplot) # for the theme used by Seurat

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

# example dimplot
p


# 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


---

### Answer by username_1 on 2022-11-30. Score: 0

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.


---

