Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

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

asked 11 years ago

anonymous user

Anonymous

updated 10 years ago

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.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 11 years ago

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

is the preferred syntax.

Preview: (hide)
link

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 ( 11 years ago )
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 ( 11 years ago )

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 ( 11 years ago )

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 ( 11 years ago )

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

slelievre gravatar imageslelievre ( 3 years ago )
0

answered 11 years ago

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

Preview: (hide)
link

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 ( 11 years ago )

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: 11 years ago

Seen: 8,748 times

Last updated: Jun 21 '13