2017-08-13 6 views
0

ggmapを使ってGoogleマップに散布図を描きます。 scale_colour_brewer()のガイドフォントサイズのサイズを変更したい。 データはこのr-ggplot2でscale_colour_brewer()のガイドサイズを設定する方法は?

shopGlng shopGlat shopPower 
1 121.2149 31.04965  35 
2 121.5595 31.22596  40 
3 121.2326 31.00489  35 
4 121.5184 31.22838  35 
5 121.5160 31.15689  45 
6 121.4557 31.26370  35 
7 121.5009 31.25928  35 
8 121.1749 30.89317  35 
9 121.1990 31.04987  35 
10 121.5977 31.26352  35 

のように見える。この結果は以下の通りです私のコード

library(ggplot2) 
library(magrittr) 
library(ggmap) 

data = read.csv('file') 

# ny_center <- geocode("new york", source = "google") 
sh_center <- geocode("shanghai", source = "google") 
map <- get_googlemap(
    zoom = 11, 
    # Use Alternate New York City Center Coords 
    center = sh_center %>% as.numeric, 
    maptype = "hybrid", 
    sensor = FALSE) 

color <- as.character(data$shopPower/10) 

p <- ggmap(map) + 
    geom_point(size = 1, 
      data = data, 
      aes(x = shopGlng, 
       y = shopGlat, 
       color = color)) + 
    xlab("") + 
    ylab("") + 
    scale_colour_brewer(palette = "Set1", guide = "legend") 

p 

です。 enter image description here

カラーバーのフォントサイズを変更したいと思います。私がそうするために使っているのはどのパラームショーですか?

答えて

2

legend.textlegend.titleを使用すると、カラーバーのフォントサイズを設定できます。

p <- ggmap(map) + 
    geom_point(size = 1, 
       data = data, 
       aes(x = shopGlng, 
        y = shopGlat, 
        color = color)) + 
    xlab("") + 
    ylab("") + 
    scale_colour_brewer(palette = "Set1", guide = "legend")+ 
    theme(legend.text = element_text(size=15), 
      legend.title = element_text(size=15) ) 

enter image description here

関連する問題