我正在使用 R 編程語言。我生成了以下資料:
credibility_scoree = rnorm(100, 1, 0.3)
average_recorded_height_in_study = rnorm(100, 17,3)
my_data = data.frame(credibility_scoree, average_recorded_height_in_study )
my_data$credibility_score = ifelse(my_data$credibility_scoree>1,1,my_data$credibility_scoree)
my_data$credibility_score = my_data$credibility_score * my_data$credibility_score
my_data$credibility_scoree = NULL
my_data$study_number <- seq_along(my_data[,1])
my_data$adjusted_weight <- my_data$credibility_score * my_data$average_recorded_height_in_study
然后我嘗試使用以下庫繪制圖:
library(fitdistrplus)
fg <- fitdist(my_data$adjusted_weight, "gamma")
fln <- fitdist(my_data$adjusted_weight, "lnorm")
fg <- fitdist(my_data$adjusted_weight, "gamma")
fw <- fitdist(my_data$adjusted_weight, "weibull")
par(mfrow = c(2, 2))
plot.legend <- c("Weibull", "lognormal", "gamma")
denscomp(list(fw, fln, fg), legendtext = plot.legend)
qqcomp(list(fw, fln, fg), legendtext = plot.legend)
cdfcomp(list(fw, fln, fg), legendtext = plot.legend)
ppcomp(list(fw, fln, fg), legendtext = plot.legend)

從這些圖片中可以看出,圖例隱藏了圖例。
問題:是否有一種自動方法可以阻止這種情況發生?
謝謝
uj5u.com熱心網友回復:
我真的很抱歉plotstyle = "ggplot需要將添加添加到每一行......但我認為這可能會幫助你從那些奇怪的傳說位置。
library(patchwork)
a <- denscomp(list(fw, fln, fg), legendtext = plot.legend, plotstyle = "ggplot")
b <- qqcomp(list(fw, fln, fg), legendtext = plot.legend, plotstyle = "ggplot")
c <- cdfcomp(list(fw, fln, fg), legendtext = plot.legend, plotstyle = "ggplot")
d <- ppcomp(list(fw, fln, fg), legendtext = plot.legend, plotstyle = "ggplot")
a b c d

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/326982.html
