[英]R - plotly - hide colorbar
How can I hide the colorbar in the following plotly example taken from their website? 如何在以下从他们的网站上获取的剧情示例中隐藏彩条?
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)
The figure reference does not provide an answer: https://plot.ly/r/reference/#colorbar . 图引用没有提供答案: https : //plot.ly/r/reference/#colorbar 。 I can hide the colorbar via editing the graph, but I would like to control this in the R code.
我可以通过编辑图形来隐藏颜色栏,但我想在R代码中控制它。
Try adding showscale = FALSE
at the trace level. 尝试在跟踪级别添加
showscale = FALSE
。
https://plot.ly/r/reference/#heatmap-showscale https://plot.ly/r/reference/#heatmap-showscale
另一种选择是使用%>% hide_colorbar()
I ended up here searching for it in JavaScript. 我最终在这里用JavaScript搜索它。 For JS use
showscale :false
after chart type:- 对于JS,使用
showscale :false
后图表类型: -
showscale :false,
type: 'heatmap',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.