5
$\begingroup$

My code right now plots a function, and animates an image moving along the curve of the function. I want to reduce the size of the image for this animation but I can't figure out how. If I try to change

image = Import["image.png"]

to

image = Import["image.png",ImageSize -> Tiny]

it just makes the image blurry in the animation. This is the animation code:

Animate[Plot[{f[z]}, {z, 0, 50}, 
  PlotRange -> {{0, 50}, {0, 10}}, 
  Epilog -> Inset[image, {x, f[x]}]], {x, 
  0, 30}]

Does anyone know how to fix this?

$\endgroup$
5
  • $\begingroup$ Just set the image size to a somewhat larger value. $\endgroup$ Commented Feb 18, 2015 at 3:13
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Commented Feb 18, 2015 at 3:20
  • $\begingroup$ Although this is dealing with an image, the actual focus lies on the Inset, which is discussed here:Scale Insetted Characters to Plot $\endgroup$
    – Jens
    Commented Feb 18, 2015 at 4:33
  • $\begingroup$ @Jens I think the selected duplicate is poor. Chat link: chat.stackexchange.com/transcript/message/20126893#20126893 $\endgroup$
    – Mr.Wizard
    Commented Feb 18, 2015 at 16:00
  • $\begingroup$ Possible duplicate: (73838). Related: (59235), (73522) $\endgroup$
    – Mr.Wizard
    Commented Feb 18, 2015 at 17:07

2 Answers 2

5
$\begingroup$

Use the fourth parameter of Inset:

enter image description here

f = Sin[#] + 5 &;
image = ExampleData[{"TestImage", "Lena"}];

Animate[Plot[{f[z]}, {z, 0, 50}, PlotRange -> {{0, 50}, {0, 10}}, 
  Epilog -> Inset[image, {x, f[x]}, Automatic, 10]], {x, 0, 30}]

enter image description here

$\endgroup$
1
$\begingroup$

You can also use Show with the option ImageSize:

image = Show[ExampleData[{"TestImage", "Lena"}], ImageSize -> 40];
f = 5 + Sin[#] + Sin[Sqrt[2] #] &;

Animate[Plot[{f[z]}, {z, 0, 50}, PlotRange -> {{0, 50}, {0, 10}}, 
  Epilog -> Inset[image, {x, f[x]}]], {x, 0, 50}]

enter image description here

$\endgroup$

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.