How do you limit the y-axis height in matplotlib?

Viewed 12010

How do you limit the height of the y-axis in matplotlib figure? I am trying to both display the x axis, and reduce the height of the figure for this 1D plot.

I have tried setting ticks, figure sizes, tight_layout, margin, etc. with no luck.

Also, changing the ylimits just spans the full figure height no matter what limits I choose.

import numpy as np
import matplotlib.pyplot as plot
from matplotlib import rcParams

x = np.array([3500])
y = np.array([0])

rcParams['toolbar'] = 'None'

plot.figure(num=None, figsize=(4, 1), dpi=80, facecolor='w')
plot.axes(frameon=False)
plot.yticks([0])
plot.xlim(0, 6000)
plot.ylim(-0.1, 0.1)
plot.plot(x, y, 'x', markersize=10)

plot.show()

Current figure:

Current figure

Desired figure:

Desired figure

3 Answers
Related