# Tooltip for a ListPlot

I have the following values:

DataACT1;(* Being a list of countries - a column in my dataset*)
DataACT2; (* Being a list of happiness scores - a column in my dataset*)
DataACT3; (*List of GDPs - a column in my dataset*)


Then I combined DataACT2 and DataACT3 to generate a listplot:

    DataACT2Combination = Transpose[{DataACT2, DataACT3}];
ListPlot [Tooltip [DataACT2Combination, DataACT1],AxesLabel -> {"Happiness Score", "GDP (per capita)"},PlotLabel -> "GDP (per capita) and Happiness Score",PlotRange -> {{1, 10}, {1, 120000}} ] // Framed


Which gives me to this Plot, with the respective tooltip when going over the dots with the mouse:

The problem is that I want the tooltip to show me just one country per dot (the respective entry of DataACT1 for the combination of the respective DataACT2Combination. Right now Mathematica is giving me the entire entry of DataACT1. How can I change this?

You should generate a single tooltip for each country; Tooltip will not automatically thread over the list.

Let's generate some data:

SeedRandom[20200106]
listOfCountries =
WolframAlpha["countries world", {{"Result", 1}, "Output"},
InputAssumptions -> {"*MC.%7E-_*DataType-"},
PodStates -> {"Result__More", "Result__More"}] // ReleaseHold;
happiness = RandomInteger[{0, 10}, Length[listOfCountries]];
gdp = RandomReal[{0, 140000}, Length[listOfCountries]];


Then generate the pairs (Transpose) and associate the name of the country with its data (MapThreading an appropriate Tooltip):

annotated = MapThread[
Tooltip[#1, #2] &,
{Transpose@{happiness, gdp}, listOfCountries}
];
ListPlot[annotated]


This will generate a plot with each dot annotated with the name of the country it represents:

You could also form an association from your data and then let ListPlot deal with the annotations itself: it will generate some labels as well as all the tooltips you seek. This is perhaps more direct, but I find that it gives you less control on the presentation:

ListPlot@AssociationThread[listOfCountries -> Transpose@{happiness, gdp}]


• Thank you so much! This worked great! – Faye Drew Jan 7 '20 at 14:49
• @Faye you're very welcome! Glad it helped! – MarcoB Jan 7 '20 at 15:38