4
$\begingroup$

I used Jens' legendmaker to Overlay graphics to get a nice legend on my ListPlot.

My question is if is there any way to make the output from Overlay behave like output from ListPlot in terms of the ability to zoom in to investigate, get co-ordinates, drawing tools, ability to right click on the graphic itself and save high resolution graphic as a host of things etc? I was able to right click the cell and save selection as a very low resolution jpeg.

Thanks,

EDIT:

boundaryplot = ListPlot[{H0SPlot, H0DPlot},PlotRange -> Full]
opts = Sequence[Background -> LightOrange, RoundingRadius -> 10];
labels = {"H0S", "H0D"}
Overlay[{boundaryplot, legendMaker[labels, opts]}, All, 1,Alignment -> {0.5, 0.5}]

While the Overlay options enable me to zoom in etc, when I right click on the image to save graphic as , I tried jpeg and pdf, it only saves the ListPlot and not the Legend. When I right click on the cell itself and use save selection as then I am able to save as jpeg something lower-res that also includes the legend.

$\endgroup$
6
  • $\begingroup$ I wouldn't be surprised if the answer was no. Why not make all the resizings, annotations, etc. on the list plot first before doing the overlay? That seems to work very well. $\endgroup$
    – rm -rf
    Commented Sep 24, 2012 at 22:30
  • 3
    $\begingroup$ Have you looked at the second and third parameters to Overlay which let you specify which of the layers is interactable? $\endgroup$
    – amr
    Commented Sep 24, 2012 at 22:34
  • 1
    $\begingroup$ @amr Excellent! You should write that as an answer. Changing the Overlay call to something like Overlay[{plot, legend}, All, 1, Alignment -> {Right, Top}] allows you to interact with the graphics as usual. $\endgroup$
    – rm -rf
    Commented Sep 24, 2012 at 22:46
  • 1
    $\begingroup$ ... also see this related question on Overlay with multiple layers each with interactive content. $\endgroup$
    – kglr
    Commented Sep 25, 2012 at 2:06
  • $\begingroup$ Thanks Amr and RM! The wolfram more information barely touched upon what the 2nd and 3rd arguments do. I still don't understand what the second argument does. If either of you write up an answer then I'd be happy to accept it. Kguler, thanks for the link. that was very helpful. I don't know what I didn't find that myself. I should look harder. $\endgroup$
    – Amatya
    Commented Sep 25, 2012 at 2:20

1 Answer 1

3
$\begingroup$

Overlay's second parameter specifies which layers are visible and in what order. The third parameter specifies which layer can be interacted with. For your usage you can use the Overlay[layers, All, 1] form.

Here's a small demonstration for Overlay. I got a little carried away <_< but it should make clear what the second parameter can be used for.

shapes = {{Blue, Disk[]}, {Red, Rectangle[]}, {Yellow, Polygon[{{-1, -1}, {0, 1}, {1, -1}}]}};

indices = Range[Length[shapes]];
visibleChoices = MapIndexed[#1 -> Row[Graphics[#, ImageSize -> 20] & /@ Part[shapes, #1]] &, Subsets[indices]];
interactableChoices = MapIndexed[#2[[1]] -> Graphics[#1, ImageSize -> 20] &, shapes];

Manipulate[
 Column@{"Overlay arguments",
   Grid[{{Graphics[{Opacity[.7], #}, ImageSize -> 20] & /@ shapes,
      direction[visible], interactable}}, Frame -> All, FrameStyle -> Lighter[Gray, .7]],

   Overlay[Graphics[{Opacity[.7], #}] & /@ shapes,
    direction[visible], interactable, Alignment -> Center]},

 {{visible, indices}, visibleChoices},
 {{direction, Identity}, {Identity -> ascending, Reverse -> descending}},
 {{interactable, 0}, interactableChoices, ControlType -> SetterBar}]

Overlay demonstration

Note: I didn't worry about preserving the user's adjustments. I think that would involve messing with ImageSize and PlotRange or other stuff and it would have complicated the demonstration.

Although I only implemented ascending/descending order, the second parameter can be any permutation, meaning you can arbitrarily reorder the layers.

$\endgroup$
1
  • $\begingroup$ oh man! Thats such a cool demonstration! Thank you. $\endgroup$
    – Amatya
    Commented Sep 27, 2012 at 5:38

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.