私はここから変更されたコードを使用することによって、私の問題を説明してみましょう:私の例では https://stats.stackexchange.com/questions/22805/how-to-draw-neat-polygons-around-scatterplot-regions-in-ggplot2ggplot2とboxplotdouのプロットを結合するには?
を、私はアイリスデータセットを使用します。 - 同じ寸法で
私の目的は、ハル散布図にダブルボックスプロット(boxplotdou)をプロットすることである。
私の試みは、これまでのところ、これを生産しています。現在のコードは次のとおりです。
library(ggplot2)
library(boxplotdbl)
df <- iris
find_hull <- function(df) df[chull(df$Sepal.Length, df$Sepal.Width), ]
hulls <- ddply(df, "Species", find_hull)
plot <- ggplot(data = df, aes(x = Sepal.Length, y = Sepal.Width, colour=Species, fill = Species)) +
geom_point() +
geom_polygon(data = hulls, alpha = 0.5) +
labs(x = "Sepal.Length", y = "Sepal.Width")
plot
par(new = TRUE)
# This is quite close what I'm trying to achieve, without axes. But it is in wrong position
#boxplotdou(Sepal.Length~Species, iris, Sepal.Width~Species, iris, factor.labels=FALSE, draw.legend=FALSE, name.on.axis=FALSE, ann = FALSE, axes = FALSE)
# This shows the axes, which do not match the underlying plot
boxplotdou(Sepal.Length~Species, iris, Sepal.Width~Species, iris, factor.labels=FALSE, draw.legend=FALSE, name.on.axis=FALSE, ann = FALSE)
私は(... ggplot内の()boxplotdouを挿入しようとしたが、私はエラーを得た:「プロットにoを追加する方法がわからない」
すべてのヘルプは、あなたの額面(新しい= TRUE)した後にこれを入れた後。
-Kari
しないでください。 – tchakravarty
私はggplot2のすべてを試してみたいと思います。ボックスプラットバーとボックスの上限と下限の値を計算する2番目のデータフレームを作成する必要があります。次に、geom_rectでボックスをプロットします。バーはgeom_errorbarでプロットすることができます。 ggstanceパッケージからgeom_errorbarhが必要になる場合があります。 https://github.com/lionel-/ggstance – timcdlucas