Mikhail  M
Mikhail M

Reputation: 960

How to set extent for matplotlib plt.show()?

I am making some prototype which displays diagrams like

import matplotlib.pyplot as plt
... 

plt.plot(xs, ys)
...
plt.show()

Getting window like

enter image description here

and now want to correct programmatically extent of the diagram to be open. To get something like

enter image description here

right after start. How to do this?

Upvotes: 1

Views: 977

Answers (1)

David Collins
David Collins

Reputation: 900

You need to set the upper and lower bounds for the x-axis and y-axis:

plt.xlim([0,45])

plt.ylim([0.00025,0.00200])

Use these after plt.plot() and before plt.show()

Upvotes: 2

Related Questions