Ask Your Question
0

How can I determine or control a plot's display scale?

asked 2013-11-10 19:19:13 +0100

Gro-Tsen gravatar image

Suppose I do something like

p = plot(sin(x), (x,0,2*pi))
p.save("/tmp/plot.png")

Is there some way of knowing (or even better, controlling) exactly the scale of the saved image in pixels per axis unit (in each direction)?

For example, if I wish to write a second graph to a different png file at exactly the same scale, is there some way to do this?

Or, to put it differently, instead of specifying the size of the output png file in inches using figsize, I wish to specify the size in inches (or pixels) per graph unit.

This matplotlib tutorial seems to be about what interests me, but I don't understand how Sage relates to matplotlib, and how I can access the transData field, let alone control its value.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-10 22:13:31 +0100

ppurka gravatar image

Sage uses matplotlib in the backend to do the job of plotting and saving 2D figures. Therefore, Sage comes bundled with matplotlib. The difference is that in Sage you can input the symbolic functions, and Sage will generate the data points and pass them on to matplotlib.

Now, since Sage contains matplotlib, you can run matplotlib commands directly from Sage. For example, an import like

sage: from matplotlib import pyplot as plt

will make pyplot commands available from Sage, as plt.<command>. So, you can use matplotlib commands directly from within Sage.

Importing matplotlib plots back into Sage Graphics is, unfortunately, not yet implemented. You may follow ticket 5128 for any update on this matter, though I am not quite sure what prevented the ticket from getting merged.

edit flag offensive delete link more

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-11-10 19:19:13 +0100

Seen: 638 times

Last updated: Nov 10 '13