# How to change the axis limits in scanpy for violin plots

**URL:** <https://discourse.scverse.org/t/how-to-change-the-axis-limits-in-scanpy-for-violin-plots/627>\
**Category:** scanpy\
**Created:** [July 18, 2022, 8:06pm UTC](https://discourse.scverse.org/t/how-to-change-the-axis-limits-in-scanpy-for-violin-plots/627 "2022-07-18T20:06:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptellier](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@ptellier](https://discourse.scverse.org/u/ptellier)\
**Post date:** [July 18, 2022, 8:06pm UTC](https://discourse.scverse.org/t/how-to-change-the-axis-limits-in-scanpy-for-violin-plots/627/1 "2022-07-18T20:06:28Z")

</div>

How do you change the axis limits in ScanPy for violin plots? Is this possible?

specifically for this type of plot

```auto
sc.pl.violin(adata, keys='total_counts', groupby='leiden', xlabel="leiden cluster number", save="_leiden_clusters_total_counts")

```

---

<div class="post-metadata">

**Author:** ![jeskowagner](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jeskowagner/32/218_2.png) [@jeskowagner](https://discourse.scverse.org/u/jeskowagner)\
**Post date:** [July 22, 2022, 9:29am UTC](https://discourse.scverse.org/t/how-to-change-the-axis-limits-in-scanpy-for-violin-plots/627/2 "2022-07-22T09:29:38Z")

</div>

Hi! You can get back the Axes object and manipulate e.g. the y-axis limits like so:

```auto
ax = sc.pl.violin(adata, keys='total_counts', groupby='leiden', xlabel="leiden cluster number", show=False)
ax.set_ylim(bottom=0,top=100)

```

Of course don’t forget to save the plot afterwards, as now this will not happen automatically.
