scanpy
scanpy copied to clipboard
Rasterisation/vector_friendly not always working
- [x] I have checked that this issue has not already been reported.
- [ ] I have confirmed this bug exists on the latest version of scanpy.
- [ ] (optional) I have confirmed this bug exists on the master branch of scanpy.
I tried setting sc._settings.settings._vector_friendly=True
This rasterises some of my figures, but not as expected.
UMAPs: Rasterized when saved, but if I save figures they are no longer rasterized in the notebook when shown (leading to large notebook). If I do not save the figure then the notebook stays small. Scatterplots: Not saved rasterized. Not sure about the notebook.
Maybe someone should also check other plots, such as violinplots with stripplots.
I also found out that vector_friendly works for sc.pl.umap but not for sc.pl.scatterplot
Here is a small piece of code to demonstrate it:
sc.set_figure_params(vector_friendly=True, dpi_save=300) # Makes PDFs of scatter plots much smaller in size but still high-quality
clusters = data.obs[leiden_col].cat.categories
for clust in range(0, len(clusters)):
clust_name = clusters[clust]
sc.pl.scatter(data, color=leiden_col, basis="umap", palette=["red"], groups=str(clust_name), size=7, show=False, ax=ax[clust], legend_loc="none", title=leiden_col) # won't be vector friendly
sc.pl.umap(data, color=leiden_col,palette=["red"], groups=str(clust_name), size=7, show=False,ax=ax[clust], legend_loc="none") # will be vector friendly
plt.show()
I found the same problem using scanpy.pl.violin. And did you guys find the solution?
I found the same problem using scanpy.pl.violin.
It looks like the problem is in sns.violinplot
, which ignores kwargs, so it's impossible to make it rasterized.