a normal version:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(np.random.randn(1000).cumsum())
# setting
ticks = ax.set_xticks([0, 250, 500, 750, 1000])
labels = ax.set_xticklabels(['one', 'two', 'three', 'four', 'five'],
rotation=30, fontsize='small')
ax.set_xlabel('Stages')
ax.set_title('My first matplotlib plot')
a batch version setting verison:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(np.random.randn(1000).cumsum())
props = {
'xticks': [0, 250, 500, 750, 1000],
'title': 'My first matplotlib plot',
'xlabel': 'Stages'
}
ax.set(**props)
but how can I add labels = ax.set_xticklabels(['one', 'two', 'three', 'four', 'five'],rotation=30, fontsize='small') into props?
It seems this function has some parameters and dict has just one value for the key, nested dict seems don't work.
'xticklabels': {'labels': ['one', 'two', 'three', 'four', 'five'], "rotation": 30, "fontsize": 'small'}?settwice, becausexticklabelsmust be set afterxticks