我正在使用ggmap route函数来计算和显示使用DC Capital Bikeshare数据的数百条路线.我成功地解决了一个小问题,路线不跟随道路,特别是弯曲的道路(见下面的截图).有没有办法将我的代码调到所有更详细的路径?
library(tidyverse)
library(ggmap)
# Example dataset
feb_14 <- read.csv('https://raw.githubusercontent.com/smitty1788/Personal-Website/master/dl/CaBi_Feb_2017.csv', stringsAsFactors = FALSE)
# Subset first 300 rows, keep start and end Lat/Long strings
start<-c(feb_14[1:300, 14])
dest<-c(feb_14[1:300, 15])
# df of individual routes
routes <- tibble(
start,
dest)
# Function to calculate route
calculationroute <- function(startingpoint, stoppoint) {
route(from = startingpoint,
to = stoppoint,
mode = 'bicycling',
structure = "route")}
# Calculate route path for all individual trips
calculatedroutes <- mapply(calculationroute,
startingpoint = routes$start,
stoppoint = routes$dest,
SIMPLIFY …Run Code Online (Sandbox Code Playgroud) 我正在试图找出正确的方法来显示位于条形图中每个条形顶部的标签.我也希望他们在数字后显示%.
这是我的Plunker:https://plnkr.co/edit/FbIquWxfLjcRTg7tiX4E ? p = preview
我尝试使用以下链接中的问题代码.但是,我无法让它正常工作(意味着整个图表无法显示)
var yTextPadding = 20;
svg.selectAll(".bartext")
.data(data)
.enter()
.append("text")
.attr("class", "bartext")
.attr("text-anchor", "top")
.attr("fill", "white")
.attr("x", function(d,i) {
return x(i)+x.rangeBand()/2;
})
.attr("y", function(d,i) {
return height-y(d)+yTextPadding;
})
.text(function(d){
return d;
});
Run Code Online (Sandbox Code Playgroud)