0
$\begingroup$

The format of my data looks like:

{"Name", "HDNumber", "SpectralClass", "BVColorIndex", \
"EffectiveTemperature", "Mass", "Luminosity", "AbsoluteMagnitude", \
"ApparentMagnitude", "RightAscension", "Declination", \
"ConstellationName"}

I import and join classes of formatted AstronomicalData like:

importClassBStar1 = Import["tableClassBStar1.tsv", {"Data", {All}}, "HeaderLines" -> 1];
importClassBStar2 = Import["tableClassBStar2.tsv", {"Data", {All}}, "HeaderLines" -> 1];
importClassBStar3 = Import["tableClassBStar3.tsv", {"Data", {All}}, "HeaderLines" -> 1];
importClassBStar4 = Import["tableClassBStar4.tsv", {"Data", {All}}, "HeaderLines" -> 1];

importClassBStar = Join[importClassBStar1, importClassBStar2, importClassBStar3, importClassBStar4];

I then use Manipulate to vary the plot type and the targeted class of AstronomicalData:

Manipulate[
plotType[Tooltip[{#6, #7}, {#3, #6, #7}] & @@@ category,
PlotRange -> Automatic, ImageSize -> Large,
AxesLabel -> {"Mass", "Luminosity"}, PlotStyle -> Red,
PlotLabel -> "Mass vs Luminosity"],
{{plotType, ListLogLogPlot }, {ListPlot, ListLogPlot, ListLogLogPlot}},
{{category, importSubgiant }, {
importClassAStar -> "ClassA",
importClassBStar -> "ClassB",
importClassMStar -> "ClassM",
importClassOStar -> "ClassO",
importSubgiant -> "Subgiant",
importSupergiant -> "Supergiant",
importVariableStar -> "VariableStar",
unionGiants -> "UnionGiants",
unionAll -> "UnionAll"
}}]

ListPicker[Dynamic[a],
{
importClassAStar -> "ClassA",
importClassBStar -> "ClassB",
importClassMStar -> "ClassM",
importClassOStar -> "ClassO",
importSubgiant -> "Subgiant",
importSupergiant -> "Supergiant",
importVariableStar -> "VariableStar",
unionGiants -> "UnionGiants",
unionAll -> "UnionAll"
}
] ;

What I would like to do is replace the static slot numbers:

plotType[Tooltip[{#6, #7}, {#3, #6, #7}]

with something like:

plotType[Tooltip[{column1, column2}, {#3, column1, column2}],
{{column1, #6}, {#4, #5, #6, #7, #8}}, 
{{column2, #7}, {#4, #5, #6, #7, #8}},

Any ideas would be welcomed. Thanks!

$\endgroup$
  • 1
    $\begingroup$ Have you seen Association and Dataset? $\endgroup$ – Edmund Jul 2 '16 at 20:08
  • $\begingroup$ I edited your answer to improve the formatting. It doesn't look syntactically complete - I apologise if I have introduced any errors. $\endgroup$ – mikado Jul 2 '16 at 20:38
  • $\begingroup$ If I replaceTooltip[{#6, #7}, {#3, #6, #7}] withTooltip[{Slot[6], Slot[7]}, {Slot[3], Slot[6], Slot[7]}] that works. But when I replace it withTooltip[{Slot[column1], Slot[column2]}, {Slot[3], Slot[column1], Slot[column2]}] it fails. Where column1 and column indexes are defined as {{column1, 6}, {4, 5, 6, 7, 8}}, {{column2, 7}, {4, 5, 6, 7, 8}} $\endgroup$ – Joseph Karpinski Jul 2 '16 at 22:18
1
$\begingroup$

Joseph,

You have to use the function With

So your line should be as follows

With[{c1=column1},Tooltip[{c1, #7}, {#3, #6, #7}] &] @@@ category,
$\endgroup$
0
$\begingroup$

That worked zKarp. Thank you! Still have to associate text to the selected numerical values but looks really good so far:

Manipulate[
 plotType[
  With[{c1 = column1, c2 = column2},
    Tooltip[{Slot[c1], Slot[c2]}, {Slot[3], Slot[c1], Slot[c2]}] &] @@@ 
   category,
  PlotRange -> Automatic, ImageSize -> Large,
  AxesLabel -> {"BVColorIndex", "AbsoluteMagnitude"}, PlotStyle -> Red,
  PlotLabel -> "AbsoluteMagnitude vs BVColorIndex"],
 {{column1, 4}, {4, 5, 6, 7, 8}}, {{column2, 8}, {4, 5, 6, 7, 8}},
 {{plotType, ListLogLogPlot }, {ListPlot, ListLogPlot, 
   ListLogLogPlot}},
 {{category, importSubgiant }, {
   importClassAStar -> "ClassA",
   importClassBStar -> "ClassB",
   importClassMStar -> "ClassM",
   importClassOStar -> "ClassO",
   importSubgiant -> "Subgiant",
   importSupergiant -> "Supergiant",
   importVariableStar -> "VariableStar",
   unionGiants -> "UnionGiants",
   unionAll -> "UnionAll"
   }}]
ListPicker[Dynamic[a],
  {
   importClassAStar -> "ClassA",
   importClassBStar -> "ClassB",
   importClassMStar -> "ClassM",
   importClassOStar -> "ClassO",
   importSubgiant -> "Subgiant",
   importSupergiant -> "Supergiant",
   importVariableStar -> "VariableStar",
   unionGiants -> "UnionGiants",
   unionAll -> "UnionAll"
   }
  ] ;

(* 
4=BVColorIndex,
5=Temperature,
6=Mass,
7=Luminosity,8=AbsoluteMagnitude *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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