4
$\begingroup$

Plotting a word cloud in the shape of Big Bird works fine, but Tooltips seems to stop working when I superimpose the image.

Here is the word cloud:

background = Import["https://i.stack.imgur.com/LB4EY.png"];
mask = ColorNegate@Dilation[DeleteSmallComponents[Binarize[background, 0.9]], 1];
data = EntityValue[CountryData[], {"Name", "Population"}]; 
wc = WordCloud[{Tooltip[#[[1]], #[[2]]], #[[2]]} & /@ data, mask, 
     ImageSize -> ImageDimensions[background]]

enter image description here

While you can't see it in the image on Stackexchange, if you mouse over the entries in Mathematica, you can see a Tooltip pop up for each entry. Now I want to superimpose the Big Bird image because it's hard to tell what the shape is. Here are two ways to do it:

Overlay[{SetAlphaChannel[background, 0.2], wc}]
ImageCompose[SetAlphaChannel[background, 0.2], wc]

enter image description here

Observe that in both the above, the Tooltips stop working. Does anyone know how to superimpose the image on the graphic so that the Tooltips will continue to function?

$\endgroup$
6
$\begingroup$

Use the 3-arg version of Overlay:

Overlay[{SetAlphaChannel[background, 0.2], wc}, All, 2]
| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ That seems to work. I guess now I understand the meaning of the third argument! $\endgroup$ – bill s Aug 3 '18 at 23:40

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.