Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c09536b

Browse files
committed
Added example and whatsnew for issue 10267 yaxis tick label side.
1 parent c0712ca commit c09536b

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Properties in `.matplotlibrc` to place yaxis tick labels on LEFT or RIGHT
2+
-------------------------------------------------------------------------------
3+
4+
Introducing two new boolean properties in `.matplotlibrc` to place yaxis tick
5+
labels on the left or right hand side of a figure by default, namely,
6+
`ytick.labelright` and `ytick.labelleft`. These can also be changed in
7+
rcParams.
8+
9+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
============================================
3+
Set default y-axis tick labels on the right
4+
============================================
5+
6+
Example to show how to change two new properties in rcParams to put yaxis tick
7+
lables on either left or right by default.
8+
9+
These properties can also be set in .matplotlibrc:
10+
11+
ytick.labelright
12+
ytick.labelleft
13+
"""
14+
15+
16+
import matplotlib.pyplot as plt
17+
import numpy as np
18+
19+
20+
x = np.array([x for x in range(10)])
21+
22+
_, ax = plt.subplots(3, 1, sharex=True, figsize=(6, 6))
23+
24+
ax[0].plot(x)
25+
ax[0].yaxis.tick_right()
26+
27+
ax[1].plot(x)
28+
ax[1].yaxis.tick_left()
29+
30+
plt.rcParams['ytick.right'], plt.rcParams['ytick.labelright'] = True, True
31+
plt.rcParams['ytick.left'], plt.rcParams['ytick.labelleft'] = False, False
32+
33+
ax[2].plot(x)
34+
35+
plt.show()

0 commit comments

Comments
 (0)