1

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?

Mikhail M
  • 929
  • 2
  • 10
  • 23
  • you mean [`xlim`](https://matplotlib.org/3.1.3/api/_as_gen/matplotlib.pyplot.xlim.html) and [`ylim`](https://matplotlib.org/3.1.3/api/_as_gen/matplotlib.pyplot.ylim.html)? see also [here](https://stackoverflow.com/questions/2849286/python-matplotlib-subplot-how-to-set-the-axis-range). – hiro protagonist Feb 22 '20 at 07:23

1 Answers1

2

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()

David Collins
  • 848
  • 3
  • 10
  • 28