在刻度标签中更改逗号和千位分隔符

时间:2017-04-16 10:03:46

标签: r plotly

在如下图所示的图表中,我想将千位分隔符更改为一个点"。",但我不知道如何按顺序使用tickformat参数为拿到它,为实现它。

require(plotly)
p <- plot_ly(x=~c(2012,2013,2014,2015,2016), y=~c(1200000,975000,1420000,1175000,1360000), type='bar') %>%
     layout(yaxis = list(title="Income in €", tickformat=",d", gridcolor = "#bbb"), xaxis = list(title="Year"), margin=list(l=80))
p

enter image description here

1 个答案:

答案 0 :(得分:3)

据我所知,如果您使用tickformatseparators会被忽略。因此,您可以指定tickformatseparators

require(plotly)
p <- plot_ly(x=~c(2012, 2013, 2014, 2015, 2016), y=~c(1200000, 975000, 1420000, 1175000, 1360000), type = 'bar') %>%
  layout(separators = '.,', 
         yaxis = list(title='Income in Euro'))
p

enter image description here