setting breaks and labels in ggplot

倾然丶 夕夏残阳落幕 提交于 2019-12-01 18:00:44
Didzis Elferts

If you are adding argument labels= to scale_fill_gradient() then you should also add argument breaks= that is the same lenghts as your labels.

+ scale_fill_gradient(high = "springgreen4", low= "grey90", name="Sum", 
          labels = c("5,000,000", "4,000,000", "3,000,000", "2,000,000", "1,000,000"),
           breaks = c(5000000, 4000000, 3000000, 2000000, 1000000))

In this case a better solution would be to just use the dollar format from the scales library. That will automatically add dollar signs and commas.

library(scales)
+ scale_fille_gradient(labels=dollar)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!