# Define range of y axis, instead of just x axis?

I was able to successfully define & display a graph of a linear equation, with the following statement:

plot(2*x+1, (-5,5))

The (-5, 5), successfully specifies an x axis range; but i haven't found any success in being able to explicitly define the range of the y axis.

edit retag close merge delete

Sort by » oldest newest most voted
plot(2*x+1, (x,-5,5),ymin=1,ymax=5)


is the preferred syntax.

more

plot(2*x+1, (-5,5),ymin=-4,ymax=4) This worked, thanks. What if the given the function: y^2 = x How would 1 plot it? I was able to do: plot(sqrt(x)) But as you know, one can't find the sqrts of negative number; so only the top half of the graph was displayed. The bottom half wasn't displayed :

( 2013-06-21 11:50:08 -0500 )edit
1

Your best option here is to use implicit_plot. Try implicit_plot(y^2==x,(x,-5,5),(y,-5,5)).

( 2013-06-21 16:15:41 -0500 )edit

y^2 =x is not a function; it fails the vertical line test. You could also try A=plot(sqrt(x),(x,0,1)) B=plot(-sqrt(x),(x,0,1)) show(A+B,xmin=-1,xmax=1)

( 2013-06-21 16:19:32 -0500 )edit

Or you could do var('y'); plot(y^2,(y,-5,5),axes_labels=['$y$','$x$']) if you wanted to be tricky - see [this link](http://sagecell.sagemath.org/?q=73417d65-fe8a-43f5-90a5-b9105813a02d).

( 2013-06-24 08:37:44 -0500 )edit
plot(2*x+1, (-5,5),ymin=-4,ymax=4)


Unfortunally

plot?


doesn't show the options ymin, ymax, but some examples do.

You can look for the options:

Evaluate:

P = plot(2*x+1)


Then type

P.


and hit the tab key

more

This is because ymin, ymax are actually an option to show(). The documentation in plot() links to the documentation of show() for this and many other options. It also mentions ymin/ymax explicitly in a special "Note" section.

( 2013-06-22 05:55:10 -0500 )edit