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$

1 Answer 1

6
$\begingroup$

Use the 3-arg version of Overlay:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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