Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205491

Tooltip for calculated shares in a stacked and filled bar chart

$
0
0

I've plotted a bar chart in ggplot and converted it using ggplotly. I want the tooltip to display relative and absolute frequencies within each bar of the chart. I try to do this the following way:

gg + stat_count(geom="text",
             aes(label=..count.., "share"=scales::percent(..count../tapply(..count.., ..x..  sum)[..x..])), position=position_fill(vjust=0.5), colour="white")

This information is printed to the tooltip, but in a not so good looking way: uggly tooltip

I've tried to get rid of this formula part in different ways, but wasn't successful so far. Can any of you help?


Viewing all articles
Browse latest Browse all 205491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>