如何用label_dollar表示60K中的数字60000?
How can I use label_dollar to represent a number 60000 in 60K?
当我在下面使用这个功能时:
scale_x_continuous(labels = label_dollar())
图表显示如下:
不过,我用的是这个功能:
scale_x_continuous(labels = label_number_si(prefix = "$"))
为了表示这样的数字:
我可以使用第一个函数得到第二个结果吗?
您可以更改 scale
和 suffix
参数来实现此目的。
df <- data.frame(x = c(10000,20000,30000,40000),
y = 1:4)
ggplot(df) +
geom_col(aes(x = x, y = y)) +
scale_x_continuous(labels = scales::label_dollar(scale = .001,
suffix = "K"))
当我在下面使用这个功能时:
scale_x_continuous(labels = label_dollar())
图表显示如下:
不过,我用的是这个功能:
scale_x_continuous(labels = label_number_si(prefix = "$"))
为了表示这样的数字:
我可以使用第一个函数得到第二个结果吗?
您可以更改 scale
和 suffix
参数来实现此目的。
df <- data.frame(x = c(10000,20000,30000,40000),
y = 1:4)
ggplot(df) +
geom_col(aes(x = x, y = y)) +
scale_x_continuous(labels = scales::label_dollar(scale = .001,
suffix = "K"))