【问题标题】:R - plotly - hide colorbarR - plotly - 隐藏颜色条
【发布时间】:2015-11-24 16:42:31
【问题描述】:

如何在从他们的网站上获取的以下情节示例中隐藏颜色栏?

    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 代码中控制它。

【问题讨论】:

    标签: r colorbar plotly


    【解决方案1】:

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

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

    【讨论】:

    • 这也适用于 Python,谢谢! 'showscale': False
    【解决方案2】:

    另一种选择是使用%&gt;% hide_colorbar()

    【讨论】:

    • 这有效,似乎 showscale=FALSE 不再有效。万岁
    【解决方案3】:

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

       showscale :false,
       type: 'heatmap',
    

    【讨论】:

      猜你喜欢
      • 2021-09-23
      • 2020-02-26
      • 1970-01-01
      • 2021-12-26
      • 2016-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-22
      相关资源
      最近更新 更多