我正在尝试使用以下代码为我的数据制作密度曲线:
ggplot(velar_nonnasal_low_f, aes(x = F2_difference, linetype = type)) +
geom_density() +
ggtitle("Density of F2 difference for /æ, ɛ/ for females") +
xlab("F2 difference") +
scale_fill_manual(name = "Place of Articulation")
此代码在以前的数据框架中运行良好,但现在它生成下面的图而不是平滑曲线。如果这是一个容易回答的问题(我还在学习R),我很抱歉,但我无法弄清楚为什么ggplot会以这种方式绘制数据。
这是一些代码,以便您可以重现我的数据的一小部分。
编辑:这是我的实际数据的可重现代码。
type <- c("coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal", "coronal")
F2_difference <- c(46.992662, 18.174776, -90.708617, -59.842787, -147.212234, -272.596601, 38.560577, 64.413318, -107.797167, -148.581689, -207.521093, 37.117600, -110.178964, 209.738062, 456.686906, 39.369545, -29.394699, -36.435841, 2.056190, -22.414031, 4.705579, -188.352557, -212.596306, 159.445017, -139.284470, -278.304356, -121.685889, -118.666014, 804.253078, -42.737883, 203.878428, -34.867516, -221.979230, -128.715072, 85.145217
velar_nonnasal_low_f <- data.frame (type, F2_difference)
答案 0 :(得分:1)
我认为@navinkb的评论是正确的。为了复制图表,我做了这个:
n <- 33
type <- c(rep("coronal", n),
rep("labial", 35 - n))
F2_difference <- c(46.992662, 18.174776, -90.708617, -59.842787, -147.212234, -272.596601, 38.560577,
64.413318, -107.797167, -148.581689, -207.521093, 37.117600, -110.178964, 209.738062,
456.686906, 39.369545, -29.394699, -36.435841, 2.056190, -22.414031, 4.705579, -188.352557,
-212.596306, 159.445017, -139.284470, -278.304356, -121.685889, -118.666014, 804.253078,
-42.737883, 203.878428, -34.867516, -221.979230, -128.715072, 85.145217)
velar_nonnasal_low_f <- data.frame (type, F2_difference)
library(plotly)
ggplot(velar_nonnasal_low_f, aes(x = F2_difference, linetype = type)) +
geom_density() +
ggtitle("Density of F2 difference for /æ, ɛ/ for females") +
xlab("F2 difference") +
scale_fill_manual(name = "Place of Articulation")
我明白了:
但如果我使用您分享的数据,我会得到:
那么也许检查数据?