library(bigrquery)
install.packages('readr')
project <- "grab-analysis" # put your project ID here
taxiQuery <- "SELECT ROUND(pickup_latitude, 4) as lat,
ROUND(pickup_longitude, 4) as long, COUNT(*) as
num_pickups FROM `bigquery-public-data.new_york.tlc_yellow_trips_2016` WHERE
(pickup_latitude BETWEEN 40.61 AND 40.91) AND
(pickup_longitude BETWEEN -74.06 AND -73.77 ) GROUP
BY lat, long"
taxiQuery1 <- "SELECT ROUND(pickup_latitude, 4) as lat,
ROUND(pickup_longitude, 4) as long, COUNT(*) as
num_pickups FROM `bigquery-public-data.new_york.tlc_green_trips_2016` WHERE
(pickup_latitude BETWEEN 40.61 AND 40.91) AND
(pickup_longitude BETWEEN -74.06 AND -73.77 ) GROUP
BY lat, long"
taxi_df <- query_exec(taxiQuery, project = project, max_pages = Inf,use_legacy_sql = FALSE)
taxi_df1 <- query_exec(taxiQuery1, project = project, max_pages = Inf,use_legacy_sql = FALSE)
require(ggplot2)
taxi_plot <- ggplot(data=taxi_df, aes(x = long, y = lat))
taxi_plot1 <- ggplot(data=taxi_df1, aes(x=long,y=lat))
final_plot = taxi_plot + geom_point(aes(alpha = as.factor(num_pickups)),size=0.4, color="white") +
scale_alpha_discrete(range = c(0.1,1), guide = FALSE) +
theme(panel.background = element_rect(fill="black", color="black"),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.text = element_blank(), axis.line = element_blank(),
axis.title = element_blank(), axis.ticks = element_blank(),
panel.border = element_blank(),
plot.background = element_rect(fill="black", color="black"))
plot(taxi_plot1 + geom_point(aes(alpha = as.factor(num_pickups)),
size=0.4, color="green") +scale_alpha_discrete(range = c(0.1,1), guide = FALSE))
我试图在taxi_df
和taxi_df1
代表的同一地块上绘制两种出租车的出租车接送点。但是,在使用par(new = TRUE)之后,我收到错误消息par(new = TRUE) : calling par(new=TRUE) with no plot
。
我似乎无法弄清楚问题。