I have recently started using scanpy as well as python and my query may be very basic one, but how can I control text on a plot made by correlation_matrix?
I want to rotate text on the top of the figure.
Hello @Shoma,
You have to create a matplotlib axes object, and provide it to sc.pl.correlation_matrix
thanks to the argument ax
.
Then you can interact with this Axes as usual, to for example change the rotation of your x_ticks labels as follow:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10,10))
sc.pl.correlation_matrix(adata, 'label', ax=ax, show=False)
ax.tick_params(axis="x", labelrotation=0)
The important thing here is to specify show=False
, otherwise axes dict won’t be returned by sc.pl.correlation_matrix
as detailed here: scanpy.pl.matrixplot — Scanpy 1.9.3 documentation
Best,
Paul
2 Likes