Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Currently I'm working on a diagram showing the merit order of power plants in the Netherlands. On the horizontal axes you see the cumulative power and on the vertical axes you see the costs per MWh. The cheapest units on the left and the more expensive to the right.

The function RectangleChart looks just fine to make this diagram. The width is the maximum power of each power plant and the hight is the cost/MWh. There are a lot of units and that's why I would like to use the Tooltip wrapper to display the power plants name when I hover the mouse cursor over the rectangle.

When i use:

RectangleChart[Tooltip[{{1, 1}, {2, 2}}, "test"]]

I get two rectangle bars and, when I hover over them, I get the Tooltip "test". But when i use:

RectangleChart[{{1, 1}, Tooltip[{2, 2}, "twee"]}]

the second rectangle bar does not show. When I wrap also the {1, 1} with Tooltip, I get the error message:

RectangleChart::ldata : {{1, 1}, {{2, 2}} is not a valid dataset or list of datasets.>>

When I add a third rectangle bar and wrap it with Tooltip, all seems to be OK again.

RectangleChart[{Tooltip[{1, 1}, "een"], Tooltip[{2, 2}, "twee"], Tooltip[{3, 3}, "drie"]}]

I'm using Mathematica version 9, on a MAC OSX 10.8.3.

Do you see the same behavior when using only two rectangle bars in RectangleChart?

share|improve this question
    
I get the same results. Looks like a bug to me. –  m_goldberg Mar 17 '13 at 9:41
    
This works as expected in version 7. –  Mr.Wizard Mar 17 '13 at 10:57
    
@Mr.Wizard. I tested with V9.0.1. I can't imagine what WRI did that screws up with exactly two data points. –  m_goldberg Mar 17 '13 at 11:00
1  
@m_goldberg actually that's pretty easy; if you use an unrestricted pattern like {x_, y_} :> . . . intending to operate on the integers in {{1, 2}, {3, 4}, {5, 6}} you hit a corner case with {{1, 2}, {3, 4}} wherein x_ matches all of {1, 2} and you get a bug. –  Mr.Wizard Mar 17 '13 at 11:03
1  
I have received confirmation from WRI that this is a bug that surfaced in V9.0.1. –  m_goldberg Mar 21 '13 at 5:17

1 Answer 1

up vote 1 down vote accepted

To explore your problem, I defined the following functions

data[n_Integer?Positive] := RandomInteger[{1, 5}, {n, 2}]
labels[pre_String, n_Integer] := DictionaryLookup[pre ~~ ___ ~~ "ing", n]
tt[n_Integer?Positive] := MapThread[Tooltip, {data@n, labels["tw", n]}]

With these I could quickly generate a large number of test cases.

Quiet@Table[RectangleChart@tt@k, {k, 12}]

enter image description here

Every chart that actually plotted had the correct set of tooltips. It looks like you will be all right if don't have exactly two data points.

P.S. I have reported this to WRI tech support as a suspected bug.

Update

I have received a response from WRI tech support confirming this a bug that surfaced in V.9.0.1. Here is the relevant section of that response:

I have reproduced this problem with Tooltip and RectangleChart and agree that there is some unintended behavior here. It appears that everything was working as recently as Mathematica 9.0.0, but that this does [not] work properly with lists of 2 Tooltips in 9.0.1.

I have filed a report with our developers on this issue.

share|improve this answer
    
Because of the large number of data points, i have a lot of power plants, in practice the "bug" did not hurt to much. Thanks for reporting it to Wolfram. –  Dick Barends Mar 19 '13 at 19:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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