【发布时间】:2022-01-06 01:52:14
【问题描述】:
我有以下数据框:
dat <- structure(list(kd_hdp = c(
-1.30681818181818, -0.896, -0.952,
-0.952, -1.208, -1.108, -1.108, -1.008
), dose = structure(c(
3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L
), .Label = c(
"0.3mM", "1mM", "3mM",
"10mM", "20mM"
), class = "factor"), status = structure(c(
1L,
4L, 4L, 3L, 1L, 1L, 1L, 2L
), .Label = c(
"-", "+", "++", "+++",
"++++"
), class = "factor")), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -8L))
数据如下:
> dat
# A tibble: 8 × 3
kd_hdp dose status
<dbl> <fct> <fct>
1 -1.31 3mM -
2 -0.896 3mM +++
3 -0.952 3mM +++
4 -0.952 3mM ++
5 -1.21 3mM -
6 -1.11 3mM -
7 -1.11 3mM -
8 -1.01 3mM +
当我用以下代码绘制它时:
library(tidyverse)
ggplot(dat, aes(x = status, y = kd_hdp)) +
geom_col() +
theme(axis.text.x=element_text( size = 25),
axis.text.y=element_text( size = 25)
)
我明白了:
请注意,绘图的 y 轴延伸到 > -4,其中
kd_hdp 的最小值是 -1.21。
如何让 ggplot 生成具有精确值作为输入数据的 y 轴?
【问题讨论】: