最近、次の本を読んで日本地図を描くのにハマっている。 実践Data Scienceシリーズ Rではじめる地理空間データの統計解析入門 (KS情報科学専門書) 作者:村上 大輔講談社Amazon ggplot2 でシンプルに日本地図を描くとこんな感じになる。 library(tidyverse) library(sf) library(NipponMap) shp <- system.file("shapes/jpn.shp", package = "NipponMap") pref <- read_sf(shp) %>% filter(name != "Okinawa") ggplot(pref) + geom_sf() このとき、デフォルトでは x軸と y軸に経度と緯度が表示される。 これ、いらなくないですか? しかもこれ (axes) を消すのはけっこう面倒なコードを書く必要がある。
概要Healy (2018) “Data Visualization: A Practical Introduction” の邦訳『データ分析のためのデータ可視化入門』をもらったので, この本のレビューと本書ではあまり取り上げられていない, R グラフィックスをさらに活用するためのヒントを提示する. 2021/9/24 追記: 『Python ユーザでも『データ可視化入門』で練習できるようにパッケージを作った + Plotnine との互換性ガイド - ill-identified diary』に書いたように, Python でも matplotlib のような煩雑な構文に惑わされずにこの本で紹介されているような方法を実現するためのパッケージ/用例を作ってみた. 概要 初めに 本書の特徴 どういう本なのか どういう人が読むとよいか 邦訳に対する細かいツッコミどころ 本書を読んだ人におすすめ
追記(2021/03/26): 開発版では「facet_*() の場合」も動くようになりました。 こういうデータが手元にあるとします。 library(readr) library(dplyr, warn.conflicts = FALSE) library(ggplot2) library(lubridate, warn.conflicts = FALSE) d_raw <- read_csv( "https://stopcovid19.metro.tokyo.lg.jp/data/130001_tokyo_covid19_patients.csv", col_types = cols( No = col_integer(), 全国地方公共団体コード = col_integer(), 公表_年月日 = col_date(), 発症_年月日 = col_date(), 確定_年月日 = c
This document explains PCA, clustering, LFDA and MDS related plotting using {ggplot2} and {ggfortify}. {ggfortify} let {ggplot2} know how to interpret PCA objects. After loading {ggfortify}, you can use ggplot2::autoplot function for stats::prcomp and stats::princomp objects. library(ggfortify) df <- iris[1:4] pca_res <- prcomp(df, scale. = TRUE) autoplot(pca_res) PCA result should only contains n
Tutorial R Tutorial ggplot2 ggplot2 Short Tutorial ggplot2 Tutorial 1 - Intro ggplot2 Tutorial 2 - Theme ggplot2 Tutorial 3 - Masterlist ggplot2 Quickref Foundations Linear Regression Statistical Tests Missing Value Treatment Outlier Analysis Feature Selection Model Selection Logistic Regression Advanced Linear Regression Advanced Regression Models Advanced Regression Models Time Series Time Serie
こういう感じで時系列プロットの端点にラベルを表示したい。 この方が時系列とラベルの対応がわかりやすくて良い。 データ視覚化のデザイン #1|Go Ando / THE GUILD|note ggrepel パッケージを使うと簡単にできるが、いくつか注意点があるのでここで紹介したい。 まずはデータを用意する。 library(tidyverse) set.seed(314) d <- map_dfr( c("setosa", "versicolor", "virginica"), ~ tibble( idx = 1:400, value = cumsum(runif(400, -1, 1)), type = . ) ) ggplot(d, aes(idx, value, colour = type)) + geom_line() 普通にプロットするとこんな感じだが、右端にラベルをつけたい。
タイトルに書いたように「凡例だけが描画したい」ことが時々あるかと思います(止むを得ずに凡例の位置が図から分断されてしまうときとか)。そんな時には、ここで紹介する方法を使うと良いです。やり方はいくつかあります。ここではgtableパッケージを使う場合の2例とlemonパッケージを使う方法の3通りを紹介します。 ⚠️ ggplot2の図の描画に使われているgridシステムやこの記事で扱うgtableとの関係について知りたい人は、毎度おなじみ id:yutannihilation さんの下記の記事を読みましょう。 notchained.hatenablog.com まずは凡例を含む図を作りましょう🎨 library(ggplot2) p <- ggplot(mtcars, aes(wt, mpg)) + geom_point(aes(color = factor(cyl), shape = f
I have the below data.frame called df. My problem has to do with the order on the y-axis. I want that the names on the y-axis are ordered according to the variable depth. If I do this: ggplot(df,aes(x=factor(name),y=depth)) + geom_bar(stat='identity') + coord_flip() + labs(y='depth',x='species') I got graph1 below which is not ordered. Therefore I followed the instructions found here, I ordered th
Alluvial Plots in ggplot2 Jason Cory Brunson 2023-02-13 The {ggalluvial} package is a {ggplot2} extension for producing alluvial plots in a {tidyverse} framework. The design and functionality were originally inspired by the {alluvial} package and have benefitted from the feedback of many users. This vignette defines the essential components of alluvial plots as used in the naming schemes and docum
Plotly ggplot2 Open Source Graphing Library With ggplotly() by Plotly, you can convert your ggplot2 figures into interactive ones powered by plotly.js, ready for embedding into Dash applications. ggplotly is free and open source and you can view the source, report issues or contribute on GitHub. Head over to the community forum to ask questions and get help.
ggplot2 で左から右に内訳をドリルダウンしていく棒グラフ(ツリーマップ?)を書きました。 新規訪問で自然検索経由のデスクトップを利用している男性の25歳〜34歳のCVが多いことがわかります。 ついで再訪問でソーシャル経由訪問のモバイルを利用している男性の25歳〜34歳のCVが多いようです。 R のコードです。 library(googleAnalyticsR) library(cowplot) library(tidyr) library(dplyr) library(plyr) ga_auth() account_list <- ga_account_list() ga_id <- account_list[3,'viewId'] CVfilter <- filter_clause_ga4(list(met_filter("goal3Completions", "GREATER_T
各都道府県を四角で表示する日本地図データの紹介です。ggplot2パッケージなどで利用が可能です。 windows 11のR version 4.1.2で確認しています。 #tidyverseパッケージがなければインストール if(!require("tidyverse", quietly = TRUE)){ install.packages("tidyverse");require("tidyverse") } JpanMiniMap <- tibble( #都道府県名 Pref = c("北海道", "青森県", "岩手県", "宮城県", "福島県", "茨城県", "千葉県", "秋田県", "山形県", "新潟県", "栃木県", "埼玉県", "東京都", "群馬県", "山梨県", "神奈川県", "富山県", "長野県", "静岡県", "石川県", "福井県", "岐阜県
The jet colormap is widely used (at least in my research community). Here is an example to use jet colormap in ggplot2, but it is not limited to ggplot. All R function can use jet.colors() as topo.colors() or rainbow(). # default plot from Hadley's site. ggplot(melt(volcano), aes(x=X1, y=X2, fill=value)) + geom_tile() # define jet colormap jet.colors <- colorRampPalette(c("#00007F", "blue", "#007F
Laptop users: You should have R installed; if not: Open a web browser and go to http://cran.r-project.org and download and install it Also helpful to install RStudio (download from http://rstudio.com) In R, type install.packages("tidyverse") to install a suite of usefull packages including ggplot2 Everyone: Download workshop materials: Download materials from http://tutorials.iq.harvard.edu/R/Rgra
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く