Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sympy - altering the range of the y axis for a plot

Using Sympy how does one set the range for the y axis ?

plot((x**2 + 2))

I wanted to have this so that the y axis would be from 0 to 7

like image 919
baxx Avatar asked Nov 23 '15 22:11

baxx


People also ask

How do I change the Y axis range in Python?

MatPlotLib with Python To change the range of X and Y axes, we can use xlim() and ylim() methods.

How do I change the y axis values in MatPlotLib?

To specify the value of axes, create a list of characters. Use xticks and yticks method to specify the ticks on the axes with x and y ticks data points respectively. Plot the line using x and y, color=red, using plot() method. Make x and y margin 0.


1 Answers

When you plot you can use the kwargs xlim and ylim to set the axis limits.

For example:

>>> plot((x**2 + 2), xlim=[-3,3], ylim=[0,7])

enter image description here

like image 190
derricw Avatar answered Oct 07 '22 13:10

derricw