Home > Enterprise >  How do I zoom in graph with matplotlib?
How do I zoom in graph with matplotlib?

Time:02-12

Hi I'm working with matplotlab library and want to zoom in graph I made too see it more clearly. Any ideas?

pic of code

pic of graph i want to zoom in

CodePudding user response:

In matplotlib you can zoom in the plot by specifying the x and y limits. For the case you have provided an example can be:

plt.xlim(-2.5, 1)
plt.ylim(0, 50)

If you only want to zoom in in the x axis use only the first line. Analogously you can zoom in only in the y axis by using the second line.

CodePudding user response:

If you want to keep the xlim and ylim unchanged then you can export the figure as a png using

plt.savefig()

you may also increase the dpi value.

  • Related