R - 图示 - 隐藏颜色条

时间:2015-08-30 14:53:52

标签: r colorbar plotly

如何在以下从其网站上拍摄的阴谋示例中隐藏彩条?

    df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')

# light grey boundaries
l <- list(color = toRGB("grey"), width = 0.5)

# specify map projection/options
g <- list(
  showframe = FALSE,
  showcoastlines = FALSE,
  projection = list(type = 'Mercator')
)

plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE, type = 'choropleth',
        color = GDP..BILLIONS., colors = 'Blues', marker = list(line = l),
        colorbar = list(tickprefix = '$', title = 'GDP Billions US$'),
        filename="r-docs/world-choropleth") %>%
  layout(title = '2014 Global GDP<br>Source:<a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">CIA World Factbook</a>',
         geo = g)

图参考没有提供答案:https://plot.ly/r/reference/#colorbar。我可以通过编辑图形来隐藏颜色栏,但我想在R代码中控制它。

3 个答案:

答案 0 :(得分:10)

尝试在跟踪级别添加showscale = FALSE

https://plot.ly/r/reference/#heatmap-showscale

答案 1 :(得分:7)

另一种选择是使用%>% hide_colorbar()

答案 2 :(得分:1)

我最终在这里用JavaScript搜索它。对于JS,在图表类型后使用showscale :false: -

   showscale :false,
   type: 'heatmap',