Issue
I use the following plot function to create a line chart of a Pandas dataframe
row = df.iloc[0].astype(int)
plt.subplot(1, 2, 1)
row.plot(marker='o', fontsize=20, ylabel=yax_label)
plt.show()
Problem is that, the y steps are shown in float (0.5 steps). Is there any way to control that? For example, 3,4,5,6,7 as integers.
Solution
You can use .set_yticks()
:
(I can't run your code, send an example)
import matplotlib.pyplot as plt
fig, axe = plt.subplots(1, 3, constrained_layout=True)
axe[0].plot(range(10))
axe[0].set_yticks(np.arange(0,10,0.5))
axe[1].plot(range(10))
axe[1].set_yticks(np.arange(0,10))
axe[2].plot(range(10))
axe[2].set_yticks(np.arange(0,10,2))
plt.show()
Output:
Answered By - user1740577
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.