Good morning, now i use scanpy module and get results. but when i use [name.add_totals()] function, i don’t know how to save it pdf or image files.
sample1: → it’s working
sc.pl.stacked_violin(data, markers, groupby=‘sample’, save=‘file.pdf’)
sample2: → i don’t know how to save it. can someone help me?
vp= sc.pl.stacked_violin(data, markers, groupby=‘sample’, return_fig=True)
vp.add_totals().style(ylim=(0,5)).show()
axes_dict=vp.get_axes()
Have a good day!
Hey there! did you ever figure out how to save these “add_total()” figs? They’re really cool but for the life of me I haven’t been able to crack this!
I tried using matplotlib’s:
fig, (ax1) = plt.subplots(1)
vp = sc.pl.stacked_violin( adata, marker_genes_dict, groupby=“seurat_clusters”, ax=ax1, show=True, dendrogram = True, cmap=“inferno”, return_fig = True, save = “_violin_plot.svg”
)
vp.add_totals(sort = ‘ascending’, color= adata.uns[‘seurat_clusters_colors’]).style(ylim=(0,5)).show().savefig(“plot.svg”)
plt.savefig(“test.svg”, format=“svg”)
And this also didnt work 
For anyone else that came here! I finally got matplotlib working (from this stack link: https://stackoverflow.com/questions/78463183/problem-exporting-images-with-matplot-lib
fig, ax1 = plt.subplots(1)
vp = sc.pl.stacked_violin(
adata, marker_genes_dict, groupby="seurat_clusters", ax=ax1, show=True,
cmap="inferno", return_fig = True)
vp.add_totals(sort = 'ascending', color= adata.uns['seurat_clusters_colors']).style(ylim=(0,5)).show()
fig.savefig("test.svg", format="svg")
fig.show()