将方形或三角形标记(不是圆形)添加到 R plotly map
add square or triangle markers (not circles) to R plotly map
我可以像本例一样在地图上绘制圆形标记。但是我想在add_markers中将标记形状从圆形更改为正方形,但我在帮助(add_markers)或在线示例中找不到解决方案。我试图添加 type=list("squares") 但不幸的是它没有改变任何东西。
require(plotly)
df<- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ebola.csv')
# restrict from June to September
df <- subset(df, Month %in% 6:9)
# ordered factor variable with month abbreviations
df$abbrev <- ordered(month.abb[df$Month], levels = month.abb[6:9])
# September totals
df9 <- subset(df, Month == 9)
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases")
)
p
有一个名为 symbol
的参数。您可以使用
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = ~abbrev
)
p
您也可以指定符号,使用
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = ~abbrev, symbols = c('circle', 'square', 'x', 'triangle')
)
p
如果您只想将圆圈切换为另一个符号,请使用:
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = 'triangle'
)
p
希望对您有所帮助。
我可以像本例一样在地图上绘制圆形标记。但是我想在add_markers中将标记形状从圆形更改为正方形,但我在帮助(add_markers)或在线示例中找不到解决方案。我试图添加 type=list("squares") 但不幸的是它没有改变任何东西。
require(plotly)
df<- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ebola.csv')
# restrict from June to September
df <- subset(df, Month %in% 6:9)
# ordered factor variable with month abbreviations
df$abbrev <- ordered(month.abb[df$Month], levels = month.abb[6:9])
# September totals
df9 <- subset(df, Month == 9)
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases")
)
p
有一个名为 symbol
的参数。您可以使用
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = ~abbrev
)
p
您也可以指定符号,使用
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = ~abbrev, symbols = c('circle', 'square', 'x', 'triangle')
)
p
如果您只想将圆圈切换为另一个符号,请使用:
p <- df %>%
plot_geo(
locationmode = 'country names', sizes = c(1, 600), color = I("black")
) %>%
add_markers(
y = ~Lat, x = ~Lon, locations = ~Country,
size = ~Value, color = ~abbrev, text = ~paste(Value, "cases"),
symbol = 'triangle'
)
p
希望对您有所帮助。