1
$\begingroup$

I have this plot of $f(x)=\ln x$ and the tangent line at $x=e$, and I'd like to specify the PlotRange so that it's the rectangle with its centroid at $(e,1)$, kind of like how ViewCenter is used for 3D graphics. Supposing I'm plotting over $[0,2e]$, is there a good way to do this without manually determining the vertices of such a rectangle?

I'm trying to make this visual demonstration of linear approximations showing that, as you zoom in on the plot, the distance between the tangent and the curve gets smaller and smaller to the point of making it hard to distinguish between the two. So, on top of centering the plot, I'd like to use Manipulate give the option of adjusting this zooming window, but I'm not sure how to set up the PlotRange to begin with.

$\endgroup$
  • 2
    $\begingroup$ Manipulate[ Plot[{Log[x], (x - E)/E + 1}, {x, E (1 - E^-a), E (1 + E^-a)}, Frame -> True, GridLines -> Automatic], {a, 0, 5}] Does this qualify as not manually determining the rectangle? $\endgroup$ – LLlAMnYP Jul 13 '15 at 20:03
4
$\begingroup$

Could you use

PlotRange->{{e-w,1-h},{e+w,1+h}}

Where w,h are the 1/2 width and 1/2 height of the zoom box?

$\endgroup$
  • $\begingroup$ I think you meant {{E-w, E+w}, {1-h, 1+h}}? But yes, this should do the trick. $\endgroup$ – user170231 Jul 13 '15 at 20:08
1
$\begingroup$

How about this? Expanding on John McGee's answer:

Manipulate[
 Plot[{Log[x], x/E}
  , {x, E - a, E + a}
  , PlotRange -> All
  , ImageSize -> 400
  , ImagePadding -> {{50, 10}, {50, 10}}]
 , {a, E, E/100, -(E/100)}
]

The ImagePadding is necessary in order to get rid of the annoying jitter that occurs when the axes labels change. PlotRange -> All makes sure that the entire set of y-values are shown for the given PlotRange. This makes things slightly more general in that you don't need to specify the y range.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.