3
$\begingroup$

I chose as an example a familiar figure!

img = Import["Lena.jpg"];

Now let's confine her inside a frame

S0 = Show[img, Frame -> True]

enter image description here

Mathematica decides (I don't know how) to range the frame from 0 to about 300.

Is there a way to change the default range of the frame?

(a). A square frame like PlotRange -> {{-n,n},{-n,n}}

(b). A random frame with PlotRange -> {{a,b},{c,d}}

Many thanks in advance!

$\endgroup$
1

3 Answers 3

5
$\begingroup$
Graphics[ {
   Texture @ img, 
   Polygon[Scaled /@ {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
       VertexTextureCoordinates -> ({{0, 0}, {1, 0}, {1, 1}, {0, 1}})]
   },
   Axes        -> False, 
   Frame       -> True,
   PlotRange   -> {{-10, 15}, {-102, 4}},
   AspectRatio -> ImageAspectRatio @ img,
   BaseStyle   -> 18
]

enter image description here

$\endgroup$
9
  • $\begingroup$ Inset[] is another possibility. $\endgroup$ Commented Dec 12, 2015 at 15:39
  • $\begingroup$ Nice but there is a blue dot above Lena's hat at (1,1)! Is there a way to get rid of it? $\endgroup$
    – Vaggelis_Z
    Commented Dec 12, 2015 at 15:39
  • $\begingroup$ @J.M. good luck with placement/size ;) I don't know how to handle that, but if I missed something, I will gladly upvote such answer. $\endgroup$
    – Kuba
    Commented Dec 12, 2015 at 15:40
  • $\begingroup$ Now when I evaluate your code I get the following error ListPlot::argx: ListPlot called with 0 arguments; 1 argument is expected. $\endgroup$
    – Vaggelis_Z
    Commented Dec 12, 2015 at 15:41
  • $\begingroup$ v9.0 complains about the empty list! I have v10.2 in another PC and I will check it later on! $\endgroup$
    – Vaggelis_Z
    Commented Dec 12, 2015 at 15:45
4
$\begingroup$
i = ExampleData[{"TestImage", "Lena"}];
Show[i, Frame -> {{True, False}, {True, False}}, 
        FrameTicks -> {{{0, "Here"}, {200, "Mine"}, {400, "Yours"}},
                       {{0, "Here"}, {300, "Lena"}, {500, "Beauty"}}}]

Mathematica graphics

$\endgroup$
3
$\begingroup$
img = ExampleData[{"TestImage", "Lena"}];

r = Transpose[{#, #/5}] &[Range[0, 500, 100]];

Show[img, 
  Frame -> True, 
  FrameStyle -> Directive[Red, Thick], 
  FrameTicks -> {{r, None}, {r, None}}]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Hmm. This comment also applies to @belisarius answer. You use custom FrameTicks and therefore you lose all the sub ticks... $\endgroup$
    – Vaggelis_Z
    Commented Dec 12, 2015 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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