0

My Y-aixs tick labels are showing strange behaviour. By default Y-axis has maximum limit as read from file but I could not increase the label size. So I have inserted

ax2.tick_params(axis="y", labelsize=28)

After inserting this line the Y-axis goes to 15 and the minor tick label are at the interval of 2.5 and appears as flots (example, 1 is appearing as 1.0)

I have tried with below to make the Y-axis labels integer but could not.

ax1.set_yticklabels(tick_labels.astype(int))

I want to keep my Y-axis labels defaults but want to increase the label size.

I am getting below error

    ax1.set_yticklabels(tick_labels.astype(int))
NameError: name 'tick_labels' is not defined
astha
  • 593
  • 5
  • 15

1 Answers1

1

You can try the following solution as per this answer

import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator

fig, ax = plt.subplots()

# your code here

# For minor ticks
ax.yaxis.set_minor_locator(MaxNLocator(integer=True))

# For major ticks
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
Sheldore
  • 37,862
  • 7
  • 57
  • 71