joo hwan kwon
joo hwan kwon

Reputation: 119

Matplotlib shift plot graph to left

I'm wondering if it is possible to shift the graph only to the left for the following plot graph.

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

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

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
   title='About as simple as it gets, folks')
ax.grid()

fig.savefig("test.png")
plt.show()

Pyh

I want to leave the x ticks the same but want to shift the graph so that the starting point of the graph is on y-axis. Any suggestions?

Thank you in advance.

Upvotes: 1

Views: 4141

Answers (1)

S95
S95

Reputation: 21

You can make the starting point of the line lie on the y-axis by changing the limits on the x-axis with

ax.set_xlim(xmin=0)

Upvotes: 1

Related Questions