Graphical Input 2

Ivan Cnop
icnop@vub.ac.be

Localising a drawing

This technique may be useful for setting PlotRange determined by a Graphic input.

Borders and rectangles

left[pts_List] := Min[Map[First, pts]]

under[pts_List] := Min[Map[Last, pts]]

right[pts_List] := Max[Map[First, pts]]

top[pts_List] := Max[Map[Last, pts]]

rect[pts_List] := 
      Rectangle[{left[pts], under[pts]}, {right[pts], top[pts]}]

Apply this

Make a drawing by hand in an empty graph:

Plot[0, {x, -2, 2}, PlotRange -> {{-2, 2}, {-2, 2}}, 
      AspectRatio ->  Automatic]

Feed thses points

pts = {{0.302161, 0.89929}, {0.230218, 0.913678}, {0.172663, 
            0.928067}, {0.0863316, 0.956844}, {0.0143886, 
            0.956844}, {-0.0575547, 0.971233}, {-0.115109, 
            0.971233}, {-0.187052, 0.956844}, {-0.244607, 
            0.928067}, {-0.31655, 0.884901}, {-0.402882, 
            0.827346}, {-0.446048, 0.769792}, {-0.503602, 
            0.697849}, {-0.53238, 0.640294}, {-0.546768, 
            0.58274}, {-0.575545, 0.510797}, {-0.575545, 
            0.438853}, {-0.589934, 0.36691}, {-0.589934, 
            0.309356}, {-0.604323, 0.251801}, {-0.604323, 
            0.122303}, {-0.604323, 0.064749}, {-0.604323, 
            0.00719428}, {-0.589934, -0.0503602}, {-0.53238, -0.136692}, {-0.503602, -0.194247}, {-0.474825, -0.26619}, {-0.446048, -0.323744}, {-0.402882, -0.381299}, {-0.345327, -0.424465}, {-0.287773, -0.467631}, {-0.230218, -0.482019}, {-0.172664, -0.496408}, {-0.100721, -0.539574}, {-0.0431659, -0.539574}, {0.0143886, -0.553962}, {0.0863316, -0.553962}, {0.158275, -0.553962}, {0.230218, -0.553962}, {0.302161, -0.553962}, {0.388493, -0.525185}, {0.446048, -0.525185}, {0.503602, -0.496408}, {0.561157, -0.438853}, {0.618711, -0.395687}, {0.647488, -0.323744}, {0.690654, -0.26619}, {0.73382, -0.208635}, {0.762598, -0.151081}, {0.791375, -0.0935261}, {0.791375, -0.0359716}, {0.805763, 
            0.0215831}, {0.834541, 0.0935261}, {0.848929, 
            0.179858}, {0.863318, 0.251801}, {0.877707, 0.323744}, {0.877707, 
            0.395687}, {0.877707, 0.453242}, {0.877707, 0.525185}, {0.848929, 
            0.58274}, {0.820152, 0.640294}, {0.762598, 0.68346}, {0.705043, 
            0.726626}, {0.6331, 0.769792}, {0.575545, 0.798569}, {0.503602, 
            0.856124}, {0.431659, 0.884901}, {0.374104, 0.913678}, {0.31655, 
            0.928067}, {0.258995, 0.928067}, {-0.172664, 
            0.381299}, {-0.115109, 0.381299}, {-0.258996, 
            0.424465}, {-0.230218, 0.482019}, {-0.172664, 
            0.525185}, {-0.115109, 0.525185}, {-0.0575547, 
            0.525185}, {0, 0.496408}, {0.345327, 0.381299}, {0.402882, 
            0.381299}, {0.244607, 0.453242}, {0.302161, 0.496408}, {0.374104, 
            0.525185}, {0.431659, 0.553962}, {0.503602, 0.553962}, {0.546768, 
            0.496408}, {0.0863316, 0.151081}, {0.0431659, 
            0.0935261}, {0.0143886, 
            0.0359716}, {0, -0.0215828}, {0.0287771, -0.0935261}, {0.0863316, -0.0935261}, {0.158275, -0.0935261}, {0.172663, -0.0359716}, {-0.244607, -0.151081}, {-0.187052, -0.165469}, {-0.158275, -0.223024}, {-0.100721, -0.251801}, {-0.0431659, -0.280578}, {0.0143886, -0.294967}, {0.071943, -0.294967}, {0.129498, -0.294967}, {0.187052, -0.294967}, {0.244607, -0.280578}, {0.287773, -0.223024}, {0.302161, -0.151081}, {0.359716, -0.179858}, {0.359716, -0.237412}, {0.330939, -0.294967}, {0.273384, -0.323744}, {0.215829, -0.323744}, {0.158275, -0.338133}, {0.10072, -0.36691}, {0.0431659, -0.36691}, {-0.0143888, -0.36691}, {-0.0719433, -0.36691}, {-0.115109, -0.309356}, {-0.172664, -0.26619}, {-0.201441, -0.194247}, {-0.21583, -0.136692}};

Plot inside rectangle

ListPlot[pts, PlotRange -> {{-2, 2}, {-2, 2}}, 
      AspectRatio ->  Automatic]

Show[{Graphics[{Hue[ .17], rect[pts]}], ListPlot[pts]}, 
      PlotRange -> {{-2, 2}, {-2, 2}}, 
      AspectRatio ->  Automatic,  Axes ->  True]

Maximal magnification

maxPlot[pts_List] := 
        ListPlot[pts, 
          PlotRange -> {{left[pts], right[pts]}, {under[pts], 
                top[pts]}}
, 
          AspectRatio ->  Automatic];

maxPlot[pts]