Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 是否为轴刻度上的数字添加后缀?_R_Ggplot2 - Fatal编程技术网

R 是否为轴刻度上的数字添加后缀?

R 是否为轴刻度上的数字添加后缀?,r,ggplot2,R,Ggplot2,number可以方便地为数字添加后缀以进行标记。有没有办法对轴上的记号执行此操作 例如,在下面的屏幕截图中,我想将M附加到轴刻度 我的代码现在看起来像这样: scale\u y\u continuous(labels=scales::dollar,n.breaks=3,expand=expansion(mult=c(0,0.05))我可以为labels值传递什么吗 scales::dollar具有后缀选项。所以像这样的事情应该行得通 scale_y_continuous(labels = fun

number
可以方便地为数字添加后缀以进行标记。有没有办法对轴上的记号执行此操作

例如,在下面的屏幕截图中,我想将
M
附加到轴刻度

我的代码现在看起来像这样:
scale\u y\u continuous(labels=scales::dollar,n.breaks=3,expand=expansion(mult=c(0,0.05))
我可以为
labels
值传递什么吗


scales::dollar
具有
后缀
选项。所以像这样的事情应该行得通

scale_y_continuous(labels = function(x) scales::dollar(x, suffix = 'M'), 
                   n.breaks = 3, expand = expansion(mult = c(0, 0.05)))