# Difficulty using pre-made plots with Manipulate

I am using the GeoGraphics function to create a "Hammer" projection of the sky to plot astronomical data. Since every data set has to be mapped using the Hammer projection algorithm individually I am trying to create a template image which I will then overlay the data sets onto. A snippet of the code is below:

    Master = Graphics @@
GeoGraphics[{}, GeoRange -> {All, {-180, 180}},
GeoGridLinesStyle -> Directive[Green, Dashed],
GeoProjection -> "Hammer", GeoGridLines -> Automatic,
GeoBackground -> Black, Axes -> True, ImagePadding -> 1,
ImageSize -> 800,
Ticks -> {Table[{N[i Degree],
Row[{i + 180, " \[Degree]"}]}, {i, -180, 180, 30}],
Table[{N[i Degree], Row[{i, " \[Degree]"}]}, {i, -90, 90, 15}]},
AxesStyle -> White, TicksStyle -> 15];

points2 = {{61.258333,
50.66875}, {-58.914583, -43.44125000000003}, {79.108333,
143.166667}, {41.7275,
11.38798}, {38.32, -23.38583299999999}, {-78.946139,
54.731667}, {-66.98, 85.412083}};

HammerLong1 = (2 Sqrt[2] Cos[10.66875] Sin[41.258333/2])/
Sqrt[1 + Cos[10.66875] Cos[41.258333/2]]*180/\[Pi]

HammerLat1 = (Sqrt[2] Sin[10.66875])/
Sqrt[1 + Cos[10.66875] Cos[41.258333/2]]*180/\[Pi]

plot3 = Graphics @@
GeoGraphics[{AbsolutePointSize@7, Blue, Point@GeoPosition@points2,
AbsolutePointSize@14, Green,
GeoRange -> {All, {-180, 180}}, PlotRangePadding -> [email protected],
GeoGridLinesStyle -> Directive[Green, Dashed],
GeoProjection -> "Hammer", GeoBackground -> None];

id = ImageDimensions[Master];
Manipulate[Graphics[{Black, Rectangle[{0, 0}, id],
Switch[chart, "   Plot 1   ", Inset[Master, Center, Center, id],
"   Plot 2   ",Inset[plot3, Center, Center, id]]},
PlotRange -> {{0, First[id]}, {0, Last[id]}},
ImageSize -> id], {{chart, "   Plot 1   ",
"Displayed: "}, {"   Plot 1   ", "   Plot 2   "}},
ControlType -> RadioButtonBar, SaveDefinitions -> True,
AppearanceElements -> "ResetButton"]


As the code is currently written only one radio button can be selected at a time, which doesn't allow me to overlay multiple data sets over the background image.

The solution using Switch was the first success out of many failed efforts to use Manipulate with the pre-computed graphics images, but I have a feeling that it is not the best option. Any and all help would be appreciated!

• HammerLong1, HammerLat1 to go :)
– Kuba
Commented Jan 26, 2018 at 19:36
• Ugh. Apologies. If you can't tell, I'm new to this :( Commented Jan 26, 2018 at 19:45

Does it work for you?

Manipulate[
Graphics[
{Dynamic[{First@Master, First@plot3}[[charts]]]}
, Sequence @@ Rest@Master, Background -> Black
],
{{charts, {1}}, {1 -> "Plot 1", 2 -> "Plot 2"}},
ControlType -> TogglerBar, SaveDefinitions -> True,
AppearanceElements -> "ResetButton"]


I use First to strip Graphics and only manage primitives sets inside the main Graphics.

• Wow! This does work wonderfully, thank you! I'm not quite sure I understand the full motivation of the solution though. The documentation on First doesn't illuminate the usage here. Commented Jan 26, 2018 at 19:59
• @EdMcClain the first element of Graphics is a list of primitives and the rest are options.
– Kuba
Commented Jan 26, 2018 at 20:13
• Thank you so much! Commented Jan 26, 2018 at 21:01
• @EdMcClain worth to notice that it does not matter much here but it is an useful idiom in general. I found my old topic with a little bit more explanation: mathematica.stackexchange.com/a/148412/5478
– Kuba
Commented Jan 26, 2018 at 21:02