1
$\begingroup$

Is anyone able to confirm if this is a bug in version 10.1 on Windows 7 Pro? I am attempting to produce a DateListPlot with Tooltips but am getting a odd error.

data = Transpose@{DateRange[Today, DatePlus[{9, "Week"}], "Week"], 
 RandomReal[{25.5, 50.8}, 10]};

Function[{pair}, Tooltip[pair, NumberForm[pair[[2]], {3, 1}]]] /@ data

This works fine. Pairs have a Tooltip of the correct NumberForm. Now lets try in a DateListPlot.

DateListPlot[
 Function[{pair}, Tooltip[pair, NumberForm[pair[[2]], {3, 1}]]] /@ data,
 Joined -> False, Filling -> Axis]

I get repeated error:

NumberForm::iprf: Formatting specification {3.,1.} should be a positive integer or a pair of positive integers. >>

Somehow the integers in the format specification are being cast to reals. Notice the "." after them. The plot is made but the tooltips are not of the correct format.

Does anyone else get this?

$\endgroup$
  • $\begingroup$ I get the same errors in 10.1 under Mac OS X. $\endgroup$ – Cassini Apr 14 '15 at 15:48
  • $\begingroup$ It appears to be in 10.0.2 as well. I only have 10.1 and 10.0.2 installed so can't check if it goes back any further. $\endgroup$ – Edmund Apr 14 '15 at 16:02
1
$\begingroup$
data = Transpose@{DateRange[Today, DatePlus[{9, "Week"}], "Week"], 
    RandomReal[{25.5, 50.8}, 10]};

Using ToString avoids the problem:

DateListPlot[
 Function[{pair}, Tooltip[pair, ToString[NumberForm[pair[[2]], {3, 1}]]]] /@ data, Joined -> False, Filling -> Axis]

Or, more compactly:

DateListPlot[Tooltip[#, ToString[NumberForm[#[[2]], {3, 1}]]] & /@ data, Joined -> False, Filling -> Axis]
$\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.