Вызов Par (NEW = True) без графика после выполнения 2 команд построения - PullRequest
0 голосов
/ 14 мая 2018
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) : calling par(new=TRUE) with no plot после использования par (new = TRUE).

Кажется, я не могу понять проблему.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...