Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have an external data file data which contains the position of stars of a galaxy simulations and it looks like this

data = Import["NGC_1566.out", "Table"];
L0 = ListPlot[data, Frame -> True, Axes -> False, 
     PlotStyle -> {Darker[Green], PointSize[0.001]}, 
     PlotRange -> {{-60, 60}, {-60, 60}}, AspectRatio -> 1]

enter image description here

and here is a real image of the NGC 1566

enter image description here

Now I would like to plot and fit my data on top of the real image. Any suggestions?

share|improve this question
1  
ImageCompose and some adjustments to the size and aspectratio of your plot should get you there. –  Karsten 7. Aug 4 at 15:03
    
@Karsten7. Great thanks! BTW, could you elaborate a little bit more your suggestions in a short answer, so I could accept it? –  Vaggelis_Z Aug 4 at 15:15

3 Answers 3

up vote 3 down vote accepted

With the image of your plot

graph = With[{grImp = Import["http://i.stack.imgur.com/KffdP.jpg"]},
            ColorReplace[grImp, First@DominantColors@grImp -> Transparent]
            ];

and the image

img = Import["http://i.stack.imgur.com/3WFIL.jpg"];

One can prepare a composition interactively using

Manipulate[Module[{irGra},
  irGra = ImageResize[graph, {s1, s2}];
  ImageCompose[img, irGra, Scaled[{p1, p2}]]
  ],
 {{p1, 0.448}, 0.3, 0.8}, {{p2, 0.495}, 0.3, 0.8}, {{s1, 347.5}, 200, 500}, {{s2, 298.}, 200, 500}
 ]

ImageComposition

share|improve this answer
    
ImageCorrelate like, e.g. in the answers to this question, could be used to find the correct position. –  Karsten 7. Aug 4 at 15:56
    
Just a minor question: at the end, how can I export the joined plot in a .jpg format without showing the Manipulation controls? –  Vaggelis_Z Aug 4 at 16:17
1  
@Vaggelis_Z Right click -> Save Image As... . If you want to use the composed image later in your notebook, e.g. for Export, than you can simply Set (=) it to a global symbol inside of Manipulate, e.g. ic = ImageCompose[img, irGra, Scaled[{p1, p2}]]. –  Karsten 7. Aug 4 at 16:48

Not an excellent fit, but close:

L0 = ListPlot[data, Frame->True, Axes->False, PlotStyle -> {Darker[Green],PointSize[0.001]},
  PlotRange -> 1.9 * {{-60,60},{-60,60}}, AspectRatio -> 1]

and, with im as the JPEG :

ImageCompose[im, L0, {270, 290}]

but the credit goes to Karsten, not me!

share|improve this answer

One more way will be to use Prolog option with ListPlot. In that case we can use your image as a texture in the background too!

image = Import["http://i.stack.imgur.com/3WFIL.jpg"];
plotRange={{-60, 60}, {-60, 60}};
bdbox = Flatten[MapAt[Reverse, Outer[List, ##], 2], 1] & @@ plotRange;
back = {Texture[image], EdgeForm[],Polygon[bdbox, 
VertexTextureCoordinates -> {{1/5.5, 1/5.5}, {1/5.5,4.4/5.5},
{4.4/5.5, 4.4/5.5}, {4.4/5.5, 1/5.5}}]};

Then we can call your ListPlot. You can play with the VertexTextureCoordinates using Manipulate for example to hit the right zoom you need. I set the numbers above from my visual judgement only.

data = Import["NGC_1566.out", "Table"];
L0 = ListPlot[data, Frame -> True, FrameStyle -> Darker[Green],Axes -> False,
PlotStyle -> {Darker[Green], PointSize[0.001]},PlotRange ->plotRange,
AspectRatio -> 1,ImageSize -> 600, Prolog -> back, PlotRangeClipping -> False]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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