作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在每个栏的顶部添加数据标签。但我希望它不是 +e,而是 10^ 格式。有很多关于斧头的文献。没有标签。我的代码如下:
amino.acids<-c(rep("Lysine",4),rep("Tryptophan",4),rep("Valine",4))
Source<-(rep(c("Cow","Cat","Monkey","Human"),3))
Values<-c(46846813,3186186135,6816135168,3178168,
461351,681684351,3584684351,68463513511,
8463510351,8435186468,1358486,6843513065)
df<-data.frame(Source,amino.acids,Values)
ggplot(df, aes(x=reorder(Source, -Values),y=Values, fill=Source))+
geom_bar(stat = "identity", color="black")+
facet_wrap(~amino.acids)+
scale_y_log10(label = trans_format("log10",math_format(10^.x)))+
xlab("")+ylab("Transformations Potential (Qu/Ha)")+
theme(axis.text.x = element_text(angle = 45, hjust=1),
legend.position = "none")
添加geom_text(label = trans_format("log10",math_format(10^.x)))
失败。
最佳答案
您还需要在scale_y_log10中设置中断。
library(ggplot2)
library(scales)
ggplot(df, aes(x=reorder(Source, -Values),y=Values, fill=Source))+
geom_bar(stat = "identity", color="black")+
facet_wrap(~amino.acids)+
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", scales::math_format(10^.x)))+
xlab("")+ylab("Transformations Potential (Qu/Ha)")+
theme(axis.text.x = element_text(angle = 45, hjust=1),
legend.position = "none")
关于r - 将科学计数法 +e 转换为 geom_text 中带上标的 10^(y),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61749815/
我是一名优秀的程序员,十分优秀!