Ask Your Question
0

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

asked 2013-06-21 18:08:56 +0100

anonymous user

Anonymous

updated 2015-01-14 09:52:04 +0100

FrédéricC gravatar image

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 flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-06-21 18:32:04 +0100

kcrisman gravatar image
plot(2*x+1, (x,-5,5),ymin=1,ymax=5)

is the preferred syntax.

edit flag offensive delete link more

Comments

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 :

bxdin gravatar imagebxdin ( 2013-06-21 18:50:08 +0100 )edit
1

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

calc314 gravatar imagecalc314 ( 2013-06-21 23:15:41 +0100 )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)

dazedANDconfused gravatar imagedazedANDconfused ( 2013-06-21 23:19:32 +0100 )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).

kcrisman gravatar imagekcrisman ( 2013-06-24 15:37:44 +0100 )edit

@bxdin - even better than implicit_plot, you can use parametric_plot. See

slelievre gravatar imageslelievre ( 2021-04-29 22:03:18 +0100 )edit
0

answered 2013-06-21 18:37:07 +0100

ndomes gravatar image
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

edit flag offensive delete link more

Comments

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.

ppurka gravatar imageppurka ( 2013-06-22 12:55:10 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-06-21 18:08:56 +0100

Seen: 8,547 times

Last updated: Jun 21 '13