Group Abstract Group Abstract

Message Boards Message Boards

1
|
101 Views
|
1 Reply
|
4 Total Likes
View groups...
Share
Share this post:

How to create an inset zoom plot for function visualization?

Posted 6 days ago

enter image description here

The overall image is the same as above, but the details are not clear in the full view. How can I, like in the image above, display an enlarged view of a specified local region alongside the main plot when drawing the complete image?

Here is a current example: when plotting the overall function image, it is impossible to clearly show the size relationship of the function values when the independent variable takes 7 and 8. The code is as follows:

Plot[Log[x]/Sqrt[x], {x, 0, 10}, PlotRange -> {Automatic, Automatic}, 
 AxesOrigin -> {0, 0}, 
 Epilog -> {Red, Dashed, InfiniteLine[{#, 0}, {0, 1}] & /@ {7, 8}}]

enter image description here

Below is the narrowed plotting range of the function, which is equivalent to locally magnifying the function image between the independent variables 7 and 8.

Plot[Log[x]/Sqrt[x], {x, 0, 10}, 
 PlotRange -> {Automatic, {0.733, 0.737}}, AxesOrigin -> {0, 0}, 
 Epilog -> {Red, Dashed, InfiniteLine[{#, 0}, {0, 1}] & /@ {7, 8}}]

enter image description here

My current idea is, how can I combine these two figures together, just like shown in the very first image above? For this example function, when plotting the overall image, display a locally magnified function image of the independent variable between 7 and 8 alongside it, so that the clear size relationship between the function values corresponding to these two independent variables can be distinctly shown.

POSTED BY: Bill Blair

Re style: De gustibus and all that. I changed the dashed lines to Prolog so they wouldn't go over the inset. Maybe you don't want that. (For best control, use Show[graphics1, plot, graphics2,...], but it can be more work.)

With[{base = 
   Plot[Log[x]/Sqrt[x], {x, 0, 10}, 
    PlotRange -> {Automatic, Automatic}, AxesOrigin -> {0, 0}, 
    Prolog -> {Red, Dashed, InfiniteLine[{#, 0}, {0, 1}] & /@ {7, 8}}]},
 Show[
  base,
  Graphics[{Inset[Show[base
      , Frame -> True, Background -> LightGray, Ticks -> Automatic, 
      Axes -> Automatic, PlotRange -> {{6.5, 8.5}, {0.733, 0.737}}, 
      ImageSize -> 120], Scaled[{0.8, 0.6}]]}]]
 ]

enter image description here

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard