【发布时间】:2021-06-07 02:29:08
【问题描述】:
在这段代码的帮助下,我可以获得每个条的总数,但是如何使用悬停或工具提示功能显示这个总数
#Data
hp=read.csv(textConnection(
"class,year,amount
a,99,100
a,100,200
a,101,150
b,100,50
b,101,100
c,102,70
c,102,80
c,103,90
c,104,50
d,102,90"))
hp$year=as.factor(hp$year)
d = ggplot(hp, aes(reorder(class, -amount, sum), amount, fill = year)) +
geom_col()
#geom_text(aes(label = stat(y), group = class),stat = 'summary', fun = sum,vjust = -1)
【问题讨论】:
-
您用
ggplotly标记了您的问题,但似乎根本没有使用该软件包?你有没有尝试过什么? Base ggplot2 不允许悬停交互,但应该使用ggplotly。这个现有的问题可能会有所帮助:stackoverflow.com/questions/34605919/… -
我试过了,但它没有显示栏的总数@MrFlick