Cobold
Cobold

Reputation: 2613

How to stop axis from resizing

I plotted a line with this code:

Manipulate[Plot[y = m (x - a) + b, {x, -10, 10}],
 {m, -10, 10}, {a, -10, 10}, {b, -10, 10}]

When I change the m (slope of the line) with the slider the axis get's re-sized and the line get's move up or down and finally flipped over but I want to see how the line rotates around without the axis moving and re-sizing. What should I do?

Upvotes: 5

Views: 5525

Answers (1)

tkott
tkott

Reputation: 460

By default, all Plot type functions in mathematica have the property PlotRange->Automatic. That is, it tells Mathematica to take the best guess as to the range given the function.

Since the plot is recalculated (and hence the plot range as well) at each change of m, it changes the range it shows, leading to the behavior you describe.

What you need to do is specify the range to plot ahead of time, so that it doesn't change:

Manipulate[
  Plot[y = m (x - a) + b, {x, -10, 10}, PlotRange -> {-200, 200}]
  , {m, -10, 10}, {a, -10, 10}, {b, -10, 10}]

PS. You should post future MMA questions to http://Mathematica.StackExchange.com

Upvotes: 15

Related Questions