# Plots shifted when using scanpy in R markdown

**URL:** <https://discourse.scverse.org/t/plots-shifted-when-using-scanpy-in-r-markdown/2044>\
**Category:** scanpy\
**Created:** [February 1, 2024, 2:12pm UTC](https://discourse.scverse.org/t/plots-shifted-when-using-scanpy-in-r-markdown/2044 "2024-02-01T14:12:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlebel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/mlebel/32/942_2.png) [@mlebel](https://discourse.scverse.org/u/mlebel)\
**Post date:** [February 1, 2024, 2:12pm UTC](https://discourse.scverse.org/t/plots-shifted-when-using-scanpy-in-r-markdown/2044/1 "2024-02-01T14:12:13Z")

</div>

Hello, I’m new to the scverse, and I’ve been doing my analysis primarily using R-based packages.

I’ve started branching out a bit to Python to be able to use scverse tools, and for ease of work, I wanted to group my analysis chunks in a R markdown. In conjugation with the {reticulate} package, I can have both R and python chunks in the same document, which is nice for interoperability.

To get started, I’ve been following the tutorial Scanpy in R ([Scanpy in R](https://theislab.github.io/scanpy-in-R/)). As in the tutorial, I saw that a lot of plots have the issue of being “shifted” to the right, which often cuts the legend. A similar issue is actually seen in the tutorial, but not addressed.

With these chunks

```auto
#R chunk
library("reticulate")
library("ggplot2")
library("SingleCellExperiment")
library("scater")
library("Seurat")

```

```auto
#Python chunk
import scanpy as sc

adata = sc.datasets.pbmc3k_processed()
adata

sc.pl.umap(adata, color='louvain')

```

(sorry, I cannot embed the image as a new user, but check out the tutorial at step 4.2 Using _ **scanpy** _ functions)

I also tried changing the knitr chunk options to expand plot, but it didn’t solve the issue

```auto
#Python chunk
#| fig.width: 10
#| fig.height: 5

sc.pl.umap(adata, color='louvain')

```

Do you have any idea how to solve this issue ? Any help would be greatly appreciated.
