Although there is a trick in TEX magnifying glass but I want to know is there any function to magnifying glass on a plot with Mathematica?
For example for a function as Sin[x] and at x=Pi/6
Below, this is just a picture desired from the cited site. the image got huge unfortunately I don't know how can I change the size of an image here!
Answer
Insetting a magnified part of the original Plot
A) by adding a new Plot
of the specified range
xPos = Pi/6;
range = 0.2;
f = Sin;
xyMinMax = {{xPos - range, xPos + range},
{f[xPos] - range*GoldenRatio^-1, f[xPos] + range*GoldenRatio^-1}};
Plot[f[x], {x, 0, 5},
Epilog -> {Transparent, EdgeForm[Thick],
Rectangle[Sequence @@ Transpose[xyMinMax]],
Inset[Plot[f[x], {x, xPos - range, xPos + range}, Frame -> True,
Axes -> False, PlotRange -> xyMinMax, ImageSize -> 270], {4., 0.5}]}, ImageSize -> 700]
B) by adding a new Plot
within a Circle
mf = RegionMember[Disk[{xPos, f[xPos]}, {range, range/GoldenRatio}]]
Show[{Graphics@Circle[{xPos, f[xPos]}, {range, range/GoldenRatio}],
Plot[f[x], {x, xPos - range, xPos + range}] /.
Graphics[{{{}, {}, {formating__, line_Line}}}, stuff___] :>
Graphics[{{{}, {}, {formating,
Line[Pick[line[[1]], mf[line[[1]]]]]}}}, stuff]},
PlotRange -> All, ImageSize -> 200, AspectRatio -> 1,
AxesOrigin -> {0, 0}]
Plot[f[x], {x, 0, 5},
Epilog -> {Transparent, EdgeForm[Thick],
Disk[{xPos, f[xPos]}, {range, range/GoldenRatio}],
Inset[%, {4.1, 0.5}]}, ImageSize -> 700]
C) by adding the Line
segments within a Circle
of the original Plot
Show[{Graphics[{Green,
Circle[{xPos, f[xPos]}, {range, range/GoldenRatio}]}],
Plot[f[x], {x, 0, 5}] /.
Graphics[{{{}, {}, {formating__, line_Line}}}, stuff___] :>
Graphics[{{{}, {}, {formating,
Line[Pick[line[[1]], mf[line[[1]]]]]}}}, stuff]},
PlotRange -> All, ImageSize -> 200, AspectRatio -> 1]
Plot[f[x], {x, 0, 5},
Epilog -> {Green, Line[{{xPos + range, f[xPos]}, {3.38, 0.5}}],
Transparent, EdgeForm[Green],
Disk[{xPos, f[xPos]}, {range, range/GoldenRatio}],
Inset[%, {4.1, 0.5}]}, ImageSize -> 700]
Comments
Post a Comment