1
$\begingroup$

Problem with ListPlot when each point has a Tooltip and there are exactly two points(or for a multi-plot Listplot[{list1, list2...}] with individual Tooltips per point and each plot having exactly two points).

The points don't appear on the plot (or the associated tooltips) in the 3rd and 4th case below.

1 point is ok, also 3 points or more is ok. I thought it might be to do with two points maybe being just outside the plot region, but extending PlotRangePadding and PlotRange didn't reveal the points.

Any ideas for a workaround? I've submitted this to support in case it is a bug.

ListPlot[{{{1, 1}, {2, 2}}, {{1, 1}, {2, 2}}}]
ListPlot[{{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"]}, {Tooltip[{1, 1}, "1b"]}}]
ListPlot[{{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"]},
          {Tooltip[{1.1, 1}, "1b"], Tooltip[{2.1, 2}, "2b"]}}]
ListPlot[{{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"]}}]
ListPlot[{{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"], Tooltip[{3, 3}, "3"]}}]
ListPlot[{{Tooltip[{1, 1}, "1"]}}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ I can confirm this behavior on 9.0.1 Windows - if you look at the FullForm of the affected plots, the list of points is empty. $\endgroup$ – ciao Jun 21 '14 at 8:38
  • $\begingroup$ Same on v8 Linux. $\endgroup$ – Öskå Jun 21 '14 at 8:57
  • $\begingroup$ A permanent frustration. I recently put a bounty on this - to no avail. link $\endgroup$ – eldo Jun 21 '14 at 8:58
2
$\begingroup$

Appending an dummy "missing" point appears to work around this issue, e.g.:

test3 = {{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"]}, 
         {Tooltip[{1, 1}, "1b"], Tooltip[{2, 2}, "2b"], Missing[]}};
test4 = {{Tooltip[{1, 1}, "1"], Tooltip[{2, 2}, "2"], Missing[]}};
|improve this answer|||||
$\endgroup$
  • $\begingroup$ @rasger, Excellent solution! That prompted me to do:If[Length[data[[i]]==2,Append[data[[i]],data[[i]][[-1]]]] so for lists of lists where some have 2 points, it duplicates the last point (otherwise ListLogPlot wasn't happy with Missing[]) Thank you. $\endgroup$ – DrBubbles Jun 21 '14 at 15:53

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.