我创建了以下 ggplot 来突出我的问题:
mydf = data.frame(x = c(1,2,3,4,5), y = c(1,2,3,4,5))
ggplot(data = mydf) +
geom_point(aes(x = x, y = y)) +
scale_x_continuous(labels = scales::dollar_format()) +
scale_y_continuous(labels = scales::unit_format(unit = "M"))
Run Code Online (Sandbox Code Playgroud)
这给出了以下惊人的高级 ggplot 图:
我的问题很简单 - 我怎样才能让一个轴同时具有 $ 和 M 单位标签,以便标签显示为 $1M $2M 等。这可能吗?是否也可以减少数字和M符号之间的差距,使其显示5M而不是5 M
一如既往的感谢!
Hacky,但有效:
ggplot(data = mydf) +
geom_point(aes(x = x, y = y)) +
scale_x_continuous(labels = scales::dollar_format()) +
scale_y_continuous(labels = scales::dollar_format(prefix="$", suffix = "M"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4578 次 |
| 最近记录: |