Change Y axis font size wit Scanpy
I would like to increase the font size of only the y axis ticks:
sc.pl.dotplot(data, ["gene"], 'CellType',figsize=(4,10), dendrogram=False)
Using plt.rcParams.update({'ytick.labelsize': 50}) doesn’t work. Updating rcParams using:
matplotlib.rcParams.update({'font.size': 5})
changes fonts for the entire plot, but I am interested in just the Y axis.
Does anyone know how to do this?
• 3,659 views
•
link
1 answer
You can modify the ylabel and yticks size with matplotlib.pyplot for a specific plot, without the global options of matplotlib.
import matplotlib.pyplot as plt
plt.xlabel('This is my x text label', size = 30)
plt.ylabel('This is my y text label', size = 20)
plt.xticks(size = 20)
plt.yticks(size = 20)
I used this example from the Matplotlin documentation: https://matplotlib.org/3.3.1/gallery/shapes_and_collections/scatter.html
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1986)
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = (30 * np.random.rand(N))**2
plt.scatter(x, y, s=area, c=colors, alpha=0.5);
plt.xlabel('This is my X text label', size = 30);
plt.ylabel('This is my Y text label', size = 20);
plt.xticks(size = 20);
plt.yticks(size = 20);
# plt.show() # This is not necessary for Jupyter.
• 0 views
•
link
Log in to answer this question.
The same has been answered in this SO thread: https://stackoverflow.com/questions/63925267/how-to-change-font-size-in-scanpy