R qplot 错误消息:形状调色板最多可以处理 6 个离散值,因为超过 6 个变得难以区分
R qplot error message: The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate
我正在尝试做一个 qplot 来做一个散点图矩阵。
qplot(X, Y, data=Customers, shape = Z,facets=ColA~ColB, size=I(3), xlab="X",ylab="Y")
其中 Z 是具有 6 个以上水平的分类变量。
我收到此错误消息:
"The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate. Consider specifying shapes manually if you must have them"
我的问题是,如何手动指定形状?
我的第一个建议是避免 qplot
。简短的语法对任何人都没有好处。尝试
ggplot(Customers, aes(x = X, y = Y, shape = Z)) +
theme_bw() +
geom_point(size = 3) +
xlab("X") + ylab("Y") +
facet_grid(ColA ~ ColB)
您现在可以轻松阅读和添加额外图层,即手动颜色。请参阅 documentation 了解如何以各种方式指定颜色。
ggplot(Customers, aes(x = X, y = Y, shape = Z)) +
theme_bw() +
geom_point(size = 3) +
xlab("X") + ylab("Y") +
scale_colour_manual(values = c("red", "blue", "green", _more_colors_)) +
facet_grid(ColA ~ ColB)
我最喜欢的是
scale_color_brewer(palette = "Set1")
您最好直接通过 ggplot 调用绘图并手动设置形状比例,而不是使用 qplot:
ggplot(data=Customers, aes(x=X, y=Y, shape=Z)) +
geom_point(size=1) +
labs(x="X",y="Y")+
scale_shape_manual(values=c(4,29,30,53,23,53,64,53,23)) +
facet_grid(ColA~ColB)
此页面包含所有可用于在 ggplot 中绘图的形状的图例:https://www.datanovia.com/en/blog/ggplot-point-shapes-best-tips/
Qplot 是一种 "quick and dirty" 绘图方法,通过 ggplot 调用绘图命令可以让您更好地控制输出。
我正在尝试做一个 qplot 来做一个散点图矩阵。
qplot(X, Y, data=Customers, shape = Z,facets=ColA~ColB, size=I(3), xlab="X",ylab="Y")
其中 Z 是具有 6 个以上水平的分类变量。
我收到此错误消息:
"The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate. Consider specifying shapes manually if you must have them"
我的问题是,如何手动指定形状?
我的第一个建议是避免 qplot
。简短的语法对任何人都没有好处。尝试
ggplot(Customers, aes(x = X, y = Y, shape = Z)) +
theme_bw() +
geom_point(size = 3) +
xlab("X") + ylab("Y") +
facet_grid(ColA ~ ColB)
您现在可以轻松阅读和添加额外图层,即手动颜色。请参阅 documentation 了解如何以各种方式指定颜色。
ggplot(Customers, aes(x = X, y = Y, shape = Z)) +
theme_bw() +
geom_point(size = 3) +
xlab("X") + ylab("Y") +
scale_colour_manual(values = c("red", "blue", "green", _more_colors_)) +
facet_grid(ColA ~ ColB)
我最喜欢的是
scale_color_brewer(palette = "Set1")
您最好直接通过 ggplot 调用绘图并手动设置形状比例,而不是使用 qplot:
ggplot(data=Customers, aes(x=X, y=Y, shape=Z)) +
geom_point(size=1) +
labs(x="X",y="Y")+
scale_shape_manual(values=c(4,29,30,53,23,53,64,53,23)) +
facet_grid(ColA~ColB)
此页面包含所有可用于在 ggplot 中绘图的形状的图例:https://www.datanovia.com/en/blog/ggplot-point-shapes-best-tips/
Qplot 是一种 "quick and dirty" 绘图方法,通过 ggplot 调用绘图命令可以让您更好地控制输出。