facet_grid と facet_wrap の間の一種の「ハイブリッド」レイアウトでプロットを作成しようとしています。
例:
library(reshape2)
library(ggplot2)
data(diamonds)
# sample and reshape diamond dataset
diamonds_l <- melt(diamonds[sample(1:nrow(diamonds), 200),
c("cut", "depth", "table", "price", "x")],
id.vars = c("cut","x"))
これは私が望むプロットの配置です(列と深さの品質、表、行の価格)
ggplot( diamonds_l, aes( x = value, y = x, colour= cut))+
geom_point( ) +
facet_wrap( variable ~ cut, scales = "free_x", nrow=3)
ただし、facet_grid 設計 (列/行ごとに 1 つのヘッダーのみ) を好みますが、scales = "free_x" はこのレイアウトでは機能しません
ggplot( diamonds_l, aes( x = value, y = x, colour= cut))+
geom_point( ) +
facet_grid(variable ~ cut, scales = "free_x")
ここでは機能しますが、それは私が望む配置ではありません (行としての品質)
ggplot( diamonds_l, aes( x = value, y = x, colour= cut))+
geom_point( ) +
facet_grid(cut ~ variable, scales = "free_x")
うまくいかない理由はわかりましたが、回避策があるかどうか疑問に思っていましたか?
ありがとう!
ファビアン