Ask Your Question
0

How do I use sage to plot this?

asked 2014-09-08 11:19:36 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I want to visualize graph of y = k/x (k > 0). Assume k = 10, for this example. I referred to basic command, but it's not giving me the graph as I want.

I want same scale on both axes (i.e. same length for y and x axes for 1 unit). Generally the y axis is automatically scaled, so that x pixels represent different units on y and x axes. I don't want that. I also want to have grid lines of unit squares.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-09-08 14:16:00 +0100

kcrisman gravatar image

updated 2014-09-08 17:54:07 +0100

The documentation for showing graphics has lots of options. In your case, aspect_ratio=1 will give the same scale, and gridlines and similar options control grid lines.

Actually, because k/x has an asymptote, if you really want the same scale on both axes, you'll probably want to cut off the vertical axis fairly low down. Try this example:

k = 10
plot(k/x,x,0,10,gridlines=True,aspect_ratio=1, ymax=10)

For even more control of those grid lines, read the documentation for this (search for) [xlist,ylist]: and you can pass in whatever lines you want.

 k = 10
plot(k/x,x,0,10,aspect_ratio=1, ymax=10, gridlines=[range(10),range(10)])

Or you can make the ticks different as well.

edit flag offensive delete link more

Comments

Thanks, aspect ratio helps! But still the gridlines are at a distance of 2 units. I wanted at a distance of 1 unit. How do I to that?

taninamdar gravatar imagetaninamdar ( 2014-09-08 16:58:16 +0100 )edit

I've edited my answer. The documentation is actually pretty helpful, though I agree that finding the "show" command is not at all obvious.

kcrisman gravatar imagekcrisman ( 2014-09-08 17:54:47 +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: 2014-09-08 11:19:36 +0100

Seen: 505 times

Last updated: Sep 08 '14