2
$\begingroup$

For my thesis, I have produced all my plots with Mathematica. Now, I need to incorporate two plots, which are produced by another software and I don't have the source code anymore. Here is one of the plots:

enter image description here

Is there any way that I can import this image in Mathematica in order to change its fonts, colors, style, etc.?

One command which I found is:

ImageGraphics[img, Method -> "DualMarchingSquares"]

but this still does not allow me to modify the style of the plot.

$\endgroup$
2

1 Answer 1

4
$\begingroup$

First you need to import the image. The coordinates of the image will depend on how you import it. Therefore, the actual values in the following will presumably be different in your case.

I use "DuckCapture" the import the picture without frame. This gives me

im

enter image description here

Next you create the frame as you want it. E.g.

Graphics[{}, Frame -> True, 
 FrameStyle -> {{{Red, Large}, Automatic}, {{Large, Green}, 
    Automatic}}, PlotRange -> {{2, 9}, {-5, 100}}, AspectRatio -> 1]

enter image description here

Now you need to place the scaled image inside the frame. This needs some fiddling and your numbers will be different (it needs some work):

gr = Graphics[{im}, AspectRatio -> 0.95, Frame -> False];
Graphics[{Point[{0, 0}], Inset[gr, {2, 0}, {0, 0}, 7.3]}, 
 Frame -> True, 
 FrameStyle -> {{{Red, Large}, Automatic}, {{Large, Green}, 
    Automatic}}, PlotRange -> {{2, 9}, {-5, 100}}, AspectRatio -> 1]

enter image description here

Addendum

To extract only part of a picture you can use e.g. "ImageTrim". E.g.:

im1

enter image description here

ImageTrim[im1, {{40, 40}, {310, 250}}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ No, the black frame inside is an artefact of DuckCapture $\endgroup$ Dec 24, 2022 at 12:48
  • 1
    $\begingroup$ Have a look to what I added $\endgroup$ Dec 24, 2022 at 13:01

Your Answer

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