Quantcast
Channel: グラフ - 廿TT
Viewing all articles
Browse latest Browse all 123

色付きミニ棒グラフ(searchConsoleR)

$
0
0

色付き棒グラフ行列(ggplot2) - 廿TTで書いた theme_spark でもうちょっとあそんでみる。

theme_spark <-function(base_size =11, base_family =""){
  theme_grey(base_size = base_size, base_family = base_family)%+replace%
    theme(panel.background = element_rect(fill ="white",colour =NA),
          panel.grid =element_blank(),
          axis.line.y = element_blank(),
          panel.border = element_blank(),
          strip.text.x = element_blank(),
          strip.text.y = element_text(angle =0),
          strip.background = element_blank())}

サーチコンソールのデータの図示。

f:id:abrahamcow:20180214090628p:plain

高さでインプレッション、色でクリック率を表して、トータルのインプレッションが多い順に並べている。

library(tidyverse)library(searchConsoleR)

scr_auth()
sc_websites <- list_websites()

scdata <- search_analytics(sc_websites[1,1],
                           dimensions = c("date","page"),
                           rowLimit =50000)

scdata2 <-scdata %>% 
  group_by(page)%>% 
  summarise(totalCTs=sum(clicks),totalIMPs=sum(impressions))%>% 
  dplyr::filter(totalIMPs>=100*90)%>% 
  left_join(scdata,by="page")%>% 
  mutate(pagePath=sub("http://abrahamcow.hatenablog.com/","",page))%>% 
  arrange(date,desc(totalIMPs))%>% 
  mutate(pagePath=factor(pagePath,levels=pagePath[!duplicated(pagePath)]))

p1<-ggplot(scdata2,aes(x=date,y=impressions,fill=ctr))+
  geom_col(width=1)+
  facet_grid(pagePath~.,scales ="free_y")+
  scale_fill_continuous(labels=scales::percent)+
  theme_spark()

print(p1)

統計グラフの本よみたい。おすすめあったら教えて下さい。

The Visual Display of Quantitative Information

The Visual Display of Quantitative Information

The Grammar of Graphics (Statistics and Computing)

The Grammar of Graphics (Statistics and Computing)

The Elements of Graphing Data

The Elements of Graphing Data

Fundamentals of Data Visualization


Viewing all articles
Browse latest Browse all 123

Trending Articles