如何在以下从他们的网站上获取的剧情示例中隐藏彩条?
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 …Run Code Online (Sandbox Code Playgroud) 考虑以下 R 代码,以 plotly 生成等值线图:
#devtools::install_github("ropensci/plotly")
library(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 …Run Code Online (Sandbox Code Playgroud) 在RI中,您希望从特定类别的Google趋势中获得前10个搜索字词.例如,类别autmotive的前10个搜索字词包含在此网址中:
url <- "https://www.google.com/trends/explore#cat=0-47&geo=US&cmpt=q&tz=Etc%2FGMT-1"
Run Code Online (Sandbox Code Playgroud)
要检索搜索字词,我尝试了以下操作:
library("rvest")
top_searches <- url %>%
read_html() %>%
html_nodes(xpath='//*[@class="trends-bar-chart-name"]') %>%
html_table()
Run Code Online (Sandbox Code Playgroud)
但是,此代码会生成一个空列表(请注意,我使用Selectorgadget来计算'xpath').
我想在一个地图中将两种类型的地图组合在一起,即泡沫和等值线图.目标是通过将鼠标悬停在地图上来显示国家/地区(等值区)以及城市级别(气泡)的人口规模.
等值线图的图解示例代码如下:
library(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 …Run Code Online (Sandbox Code Playgroud) 我需要附加到 aws S3 上的 json 文件,python 代码正在 EC2 实例上运行。
在本地设置中,我可以轻松地执行此操作,如下所示:
import json
#example data
json_data = {"id": "123", "name": "XYZ", "transaction": [20.0, 30.0]}
# path
local_path = '/home/ubuntu/test.json'
with open(local_path, 'a', encoding='utf-8-sig') as file:
json.dump(json_data, file)
file.write('\n')
file.close()
Run Code Online (Sandbox Code Playgroud)
在 EC2 上,我可以按如下方式连接到 S3:
import boto
s3_open = boto.connect_s3(host='s3.eu-central-1.amazonaws.com')
Run Code Online (Sandbox Code Playgroud)
我定义了S3的路径:
s3_path = 's3://my-bucket/test.json'
Run Code Online (Sandbox Code Playgroud)
如何使用上述逻辑附加到该文件?