[英]Error in `check_required_aesthetics()`: ! geom_dotplot requires the following missing aesthetics: y
The problem is that whilst I try to plot using geom_dotplot, I receive the error:问题是,当我尝试使用 geom_dotplot 进行绘图时,我收到错误:
Error in `check_required_aesthetics()`:
! geom_dotplot requires the following missing aesthetics: y
The data for this problem is:这个问题的数据是:
sum.qmerge<-structure(list(absdif = c(0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.01,
0, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0, 0.01, 0.01, 0.01, 0.01,
0.02, 0.02, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0.01, 0.01,
0.01, 0.01, 0.01, 0, 0, 0.01, 0.01, 0.01, 0.01, 0, 0, 0, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0, 0.01, 0.02, 0.02, 0.02, 0.01,
0.01, 0.01, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01, 0.02, 0.02,
0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.03, 0.03, 0.03, 0.02, 0.02,
0.02, 0, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0, 0, 0.01, 0, 0,
0, 0, 0, 0.01, 0.01, 0.01, 0, 0, 0, 0, 0.01, 0.01, 0.01, 0.01,
0.01, 0, 0, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0.01, 0.01
), landscape = c("cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random")), row.names = c(NA,
-147L), class = c("tbl_df", "tbl", "data.frame"))
The code I am using to plot this data is:我用来绘制这些数据的代码是:
ggplot(sum.qmerge)+geom_dotplot(aes(x = landscape, y = absdif),dotsize=0.5,binwidth = 0.2)+
theme(aspect.ratio = 1)+
xlab("Landscape Type")+
ylab("Absolute Difference")
I have tried adding the aesthetic function to both ggplot() and geom_dotplot() but I keep receiving the error.我尝试将美学功能添加到 ggplot() 和 geom_dotplot() 但我一直收到错误消息。 What is the solution?
解决办法是什么? Many thanks.
非常感谢。
You can get the dotplot
by adjusting the binaxis
and stackdir
options:您可以通过调整
dotplot
和stackdir
选项来获得binaxis
图:
library(tidyverse)
sum.qmerge <- structure(list(absdif = c(
0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.01,
0, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0, 0.01, 0.01, 0.01, 0.01,
0.02, 0.02, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0.01, 0.01,
0.01, 0.01, 0.01, 0, 0, 0.01, 0.01, 0.01, 0.01, 0, 0, 0, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0, 0.01, 0.02, 0.02, 0.02, 0.01,
0.01, 0.01, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01, 0.02, 0.02,
0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.03, 0.03, 0.03, 0.02, 0.02,
0.02, 0, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0, 0, 0.01, 0, 0,
0, 0, 0, 0.01, 0.01, 0.01, 0, 0, 0, 0, 0.01, 0.01, 0.01, 0.01,
0.01, 0, 0, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.02, 0.01, 0.01
), landscape = c(
"cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "cluster", "cluster", "cluster",
"cluster", "cluster", "cluster", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "regular", "regular",
"regular", "regular", "regular", "regular", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random", "random", "random",
"random", "random", "random", "random", "random"
)), row.names = c(
NA,
-147L
), class = c("tbl_df", "tbl", "data.frame"))
ggplot(sum.qmerge, aes(landscape, absdif)) +
geom_dotplot(binaxis = "y", stackdir = "center", dotsize = 0.2) +
theme(aspect.ratio = 1) +
xlab("Landscape Type") +
ylab("Absolute Difference")
#> Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
Created on 2022-06-23 by the reprex package (v2.0.1)由reprex 包于 2022-06-23 创建 (v2.0.1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.