I am plotting
f[x_] := 2*x + 1
Plot[f[x], {x, -10, 10}]
BUT I want to scale my axes differently. By default it is 1:2 , meaning 1 unit on $y$ axis is equal to 2 units on $x$ axis. I want to manually specify it. I tried to use AspectRatio
, but this only changes my graph, and not the axes... What can I do?
Answer
I could interpret this question a couple of different ways. One is that you would like to scale the proportion of your plot. One can use ScalingFunctions
(though undocumented for Plot
) to specify the intended relationship, which will be correctly handled with AspectRatio -> Automatic
. For example:
Table[
Plot[3 Sin[2 x], {x, 0, 7}, ScalingFunctions -> {scale, Identity},
AspectRatio -> Automatic, PlotRange -> All],
{scale, {{2 # &, #/2 &}, Identity, {#/2 &, 2 # &}}}
] // GraphicsRow
Note that unlike setting the proportion using a specific value for AspectRatio
I did not have to manually calculate this value; it was computed automatically.
Another interpretation is that you wish to relabel one of the plot axes, easily done with a coefficient in the right place:
GraphicsRow[{
Plot[3 Sin[2 x], {x, 0, 7}],
Plot[(3 Sin[2 x])/2, {x, 0, 7}],
Plot[3 Sin[2 (x/2)], {x, 0, 14}]
}]
These two behaviors may be combined to produce most any scaling you desire.
Comments
Post a Comment