Issue
I have a problem to see x-axis description for first subplot (I used Axes.set_xticks). See sample of code:
import matplotlib.axes
import matplotlib.pyplot as plt
y_lst=[100,200,150,500]
x_lst=[2,4,8,16]
plt.style.use("bmh") #"ggplot" "seaborn-v0_8-poster"
fig, ax = plt.subplots(2, 1, sharex="all", squeeze=False, figsize=(15, 6))
ax_cur: matplotlib.axes.Axes = ax[0][0]
plt.suptitle("Performance",weight='bold', fontsize=18, ha="center", va="top")
ax_cur.set_title("title", fontsize=14,ha="center", va="top")
ax_cur.plot(x_lst, y_lst, color='green', linestyle="-")
ax_cur.legend()
ax_cur.set_ylabel('RTF [calls/sec]')
ax_cur.set_xticks(x_lst)
plt.grid()
plt.show()
Did you solve the same problem?
Solution
Duplicate tick labels are turned off by default when you use sharex, but you can turn them back on with the tick_params
method.
import matplotlib.axes
import matplotlib.pyplot as plt
y_lst=[100,200,150,500]
x_lst=[2,4,8,16]
plt.style.use("bmh") #"ggplot" "seaborn-v0_8-poster"
fig, ax = plt.subplots(2, 1, sharex="all", squeeze=False, figsize=(15, 6))
ax_cur: matplotlib.axes.Axes = ax[0][0]
plt.suptitle("Performance",weight='bold', fontsize=18, ha="center", va="top")
ax_cur.set_title("title", fontsize=14,ha="center", va="top")
ax_cur.plot(x_lst, y_lst, color='green', linestyle="-")
ax_cur.legend()
ax_cur.set_ylabel('RTF [calls/sec]')
ax_cur.set_xticks(x_lst)
ax_cur.tick_params('x', labelbottom=True)
plt.grid()
plt.show()
Answered By - RuthC
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.