-1

How to set y axis label's on Matplotlib boxplot? I checked the docs and searched the google for it, but perhaps I am not using the right keywords. I want to set the y axis interval to 5000 instead of 20000 as it is shown in this graph. enter image description here

kron_ninja
  • 61
  • 8

1 Answers1

1

You can use MultipleLocator and set y axis:

Example:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)

# Sample
t = np.arange(0.0, 100.0, 0.1)
s = np.abs(100000 * np.sin(0.1 * np.pi * t) * np.exp(-t * 0.01))

# Plot function
fig, ax = plt.subplots()
ax.plot(t, s)

# Define the yaxis
ax.yaxis.set_major_locator(MultipleLocator(5000))

plt.show()

With MultipleLocator: with MultipleLocator

Without MultipleLocator: without MultipleLocator

Corralien
  • 109,409
  • 8
  • 28
  • 52