Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 327
Cobold Avatar asked Dec 10 '22 02:12

Cobold


1 Answers

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

like image 157
tkott Avatar answered Feb 27 '23 12:02

tkott