作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下数据框和图。在情节的图例中,点的形状没有显示,线条太粗。有办法解决这个问题吗?
library(ggplot2)
library(ggalt)
x <- rnorm(100)
y <- rnorm(100)
group <- rep(c("A","B","C","D"), 25)
dat <- data.frame(x,y,group)
ggplot(dat, aes(x=x, y=y, shape=group, color=group)) +
geom_point() +
geom_encircle(data=subset(dat, group=='A'), aes(x=x,y=y),size=2, linetype=2) +
geom_encircle(data=subset(dat, group=='B'), aes(x=x,y=y), size=3, linetype=3) +
geom_encircle(data=subset(dat, group=='C'), aes(x=x,y=y),size=4, linetype=4) +
geom_encircle(data=subset(dat, group=='D'), aes(x=x,y=y))
最佳答案
与其在同一个图例中调整大小,不如将形状和线型拆分为不同的图例。不完全是您要找的东西,但我认为它看起来不错。
library(ggplot2)
library(ggalt)
x <- rnorm(100)
y <- rnorm(100)
group <- rep(c("A","B","C","D"), 25)
dat <- data.frame(x,y,group)
ggplot(dat, aes(x=x, y=y, shape=group, color=group)) +
geom_point() +
geom_encircle(aes(size=group, linetype = group)) +
scale_size_manual(values=c("A" = 2, "B" = 3, "C" = 4, "D" = 1)) +
scale_shape_discrete(name = 'Shapes') +
scale_color_discrete(name = 'Linetypes') +
scale_linetype_discrete(name = 'Linetypes') +
guides(shape = guide_legend(override.aes = list(size = 3)),
linetype = guide_legend(override.aes = list(shape = NA)),
size = FALSE) +
theme(legend.key.size = unit(1, 'cm'),
legend.box = 'horizontal')
关于r - 在 ggplot 图例中正确显示线型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46900721/
我是 ggplot 的新手,所以请耐心等待。我正在绘制 35 个小区域地理的增长预测,即使使用了很棒的 directlabels 对于一个地块来说,这是一个不健康的数量。图书馆。但是我需要所有系列进行
在我下面的图表中,我希望图例反射(reflect)实际的线型,即“距离”的蓝线也应该在图例中用虚线表示。我如何实现这一目标? 在我的代码下面。谢谢! data <- structure(list(Ye
我有一个使用 step-before 插值的折线图(尽管如果使用 step-after,同样的问题也适用)。我希望垂直线段的颜色比水平线段的颜色浅。我怎样才能做到这一点? 最佳答案 单一路径必须是单一
我正在使用 React 和 Google Charts,我刚刚发现一个我找不到解决方案的问题。 我有这个组件 这里是数据和选项的值: const data = [ ["Year",
我是一名优秀的程序员,十分优秀!