Answers.Body: <p>DimPlot returns a ggplot object, so ggplot functions can be applied to it. You can change the legend position like this:</p>
  <pre><code>DimPlot(data) + theme(legend.position = &quot;top&quot;)
  # or
  DimPlot(data) + theme(legend.position = c(.1, .9))
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-06T17:15:17.163Z
Answers.Text: Thank you so much, problem solved. I was trying to solve it from DimPlot() method.
Answers.UserDisplayName: cst
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-06T10:55:17.423Z
Answers.LastActivityDate: 2023-01-06T10:55:17.423Z
Answers.UserDisplayName: Cloudberry
Body: <p>I have a Seurat object and plotted the Dimplot for UMAP visualization for 2 variables, as shown in the image below.</p>
  <p><a href="https://i.sstatic.net/2gj8q.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2gj8q.png" alt="enter image description here" /></a></p>
  <p>Now, the problem is that I want the group by variables such as <code>Non-responder and Responder</code> and <code>anti-CLTA4, anti-CLTA4+PD1, anti-PD1</code> on the top of the UMAP plot and not on the right side. My desired output would look like the following.</p>
  <p><a href="https://i.sstatic.net/imshU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/imshU.png" alt="enter image description here" /></a></p>
  <p>The timely help is highly appreciated, many thanks.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-05T15:48:17.587Z
Comments.Text: If you plan to export the graph anyway, the easiest way could be to edit it with a vector graphics program. The other option is to save the `ggplot` object returned by `Dimplot()` and modify it to suit your needs.
Comments.UserDisplayName: Cloudberry
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-06T04:09:42.280Z
Comments.Text: Could you please provide an example of Seurat `DimPlot()` to `ggplot` ? @Cloudberry
Comments.UserDisplayName: cst
Tags: <scrnaseq><seurat><ggplot2>
Title: How to change the position of groups colors in DimPlot of Seurat
ThreadText: # How to change the position of groups colors in DimPlot of Seurat
  
  (Asked by: username_0 on 2023-01-05)
  
  I have a Seurat object and plotted the Dimplot for UMAP visualization for 2 variables, as shown in the image below.
  
  [![enter image description here](https://i.sstatic.net/2gj8q.png)](https://i.sstatic.net/2gj8q.png)
  
  Now, the problem is that I want the group by variables such as `Non-responder and Responder` and `anti-CLTA4, anti-CLTA4+PD1, anti-PD1` on the top of the UMAP plot and not on the right side. My desired output would look like the following.
  
  [![enter image description here](https://i.sstatic.net/imshU.png)](https://i.sstatic.net/imshU.png)
  
  The timely help is highly appreciated, many thanks.
  
  **Tags:** scrnaseq, seurat, ggplot2
  
  > **Comments:**
  > **username_1**: If you plan to export the graph anyway, the easiest way could be to edit it with a vector graphics program. The other option is to save the `ggplot` object returned by `Dimplot()` and modify it to suit your needs.  
  > **username_0**: Could you please provide an example of Seurat `DimPlot()` to `ggplot` ? @username_1  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-06. Score: 3 | Accepted answer
  
  DimPlot returns a ggplot object, so ggplot functions can be applied to it. You can change the legend position like this:
  
  ```
  DimPlot(data) + theme(legend.position = "top")
  # or
  DimPlot(data) + theme(legend.position = c(.1, .9))
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you so much, problem solved. I was trying to solve it from DimPlot() method.  
  
  ---
  
  