r - ggplot2 从绝对值值中获取条形图
问题描述
嘿,我有以下代码:
t<- rep(c(1,2,4,8,16,24,32),4)
y1 <- c(1,1.99,4.01,7.94, 15.98, 23.74, 27.17)
y2 <- c(1,2, 4, 7.98, 15.92, 23.77, 30.37)
y3 <- c(1,2.01, 4.04, 8.12, 16.19, 24.03, 31.14)
y4 <- c(1,1.96, 3.81, 6.46, 9.81, 10.26, 9.15)
total <- c(y1,y2,y3,y4)
rel.df <- data.frame(color=rep(c("a", "b", "c", "d"), each=7),t,total)
ggplot(rel.df, aes(x=t, y = total, fill = color)) +
geom_bar(position = "dodge", stat ="identity", width=0.5)
我想绘制一个条形图,将我的每个 ys 显示为关于 t 值的单独组,我目前得到的是:是否有可能将组与 t 值(1,2, 4,8,16,24,32),没有扩展 x 轴?所以我想要,x 值具有相同的图形距离,例如,第 4 组与第 2 组的距离与第 8 组的距离一样远。
解决方案
推荐阅读
- ios - 基本的 SwiftUI 选择器在屏幕变化时发出严重警告和奇怪的动作
- python - 为什么我的代码输出错误:代码无法访问?
- android - Android TextToSpeech 从系统获取语音速率
- python - Pyside2,如何避免 .parent().parent().parent().parent()
- android - 框架布局的目的?
- go - 动态处理不同版本的协议
- python - 将图例添加到绘制的直方图
- python - AttributeError: 'str' object has no attribute 'decode'. Could not find anywhere
- typescript - 在 typescript 类之外定义静态方法
- html - 如何制作像 Tesla Cybertruck 订单网站上的输入文本字段?