- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经从多个数据帧中创建了一个 ggplot。其中一个数据框用于绘制填充的多边形/矩形,而另一个用于创建等高线图。如果我在等高线图元素中指定一种颜色,它会在多边形的图例中显示为轮廓(而不是绘制的多边形本身的轮廓)。
如何仅从单个不相关的图例元素中删除轮廓?
可重现的例子:
df1 <- data.frame(
person = c("Avery", "Doug", "Avery", "Doug", "Avery", "Doug", "Avery", "Doug"),
place = c("A","A","B","B","C","C","D","D"),
Coord1 = c(10, 30, 70, 90, 70, 90, 10, 30),
Coord2 = c(70, 90, 70, 90, 10, 30, 10, 30)
)
df2 <- structure(list(place = c("A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D"), Coord1 = c(11.9321233389815,
5.65317891793307, 19.1326709658932, 27.9338809206353, 19.9660510683355,
21.0749048744809, 7.21913717149466, 20.1920548762508, 10.4543717875714,
25.757795926256, 12.1828845087838, -0.465353420455905, 7.11311351850768,
14.8155028526132, -2.1637642702189, 13.0813689628972, 4.7982168502595,
5.57686199262573, 4.00687188024056, 22.9457782880066, 18.3539124739061,
4.33984900298331, 17.8841935003471, -1.65929325512088, 4.69179993740943,
42.6151590341647, 27.615643609024, 10.0218739210389, 37.0107595807328,
42.2081901427891, 21.4907606643235, 24.3639224345837, 32.772343673693,
39.707188961395, 39.526308329454, 26.0304665678886, 29.9780452839205,
26.3307539307013, 30.3989518780307, 48.3076387197071, 18.9469498637539,
20.2952072925756, 16.6669862005188, 37.4700660304315, 17.8662145857614,
37.2600750819877, 25.7007521883461, 28.6742428655807, 40.314957702891,
30.0697139406434, 73.6583322470224, 79.3142178409643, 50.9322840242791,
70.5198852398892, 61.5150022794989, 66.3183258649759, 76.2469408002744,
82.2025917335132, 47.6021718929377, 66.3132462976689, 69.1291434239167,
83.4197156933065, 86.9407992718112, 76.4950208109435, 73.661826873959,
66.9162963609677, 75.1456713179674, 60.9887903971435, 71.9565881057142,
68.4266063305417, 57.6911530548141, 74.7773517795878, 69.6101844803799,
67.790228250546, 69.3010177449088, 102.70586821213, 70.9690781293641,
81.8211641205855, 89.1142208240172, 103.752341186373, 89.5593092939362,
80.6305724472789, 82.0007363853625, 65.8943427952359, 78.3936032524407,
83.0803062787287, 92.1760929466364, 78.9701119884041, 86.8932236845231,
97.1763793934393, 84.058342477451, 93.7849946833988, 83.1484361525486,
80.1491902221492, 85.9961991961048, 93.2550659070971, 78.3156355536891,
94.2129927101896, 93.4865526165191, 93.4934076661858, 75.4629285622502,
47.6731852393923, 72.88284171046, 75.438344587857, 58.0801523419401,
69.8230768794789, 60.5302214082446, 65.9778757219936, 70.5612025149866,
68.4370521177005, 58.1149422572855, 82.8226830631184, 65.7390566694014,
65.6285158427551, 64.1736763473425, 93.616329884223, 60.1827131711359,
48.6282110427849, 66.7586165042503, 75.5318338818184, 67.3206665449225,
59.0440215809036, 51.0189160405021, 84.6055490872487, 54.892120364794,
97.5277806090821, 87.3463009673921, 102.066058009738, 82.0203143022486,
90.9586925853003, 88.6949600210823, 103.884302040987, 87.4998069331291,
76.3591677407161, 81.8943250717613, 100.824382142449, 102.946636154418,
81.8333852359431, 94.7599932319231, 93.7316328376966, 79.8039952376426,
92.3881270619707, 71.2558895720234, 99.8119134521082, 112.401228355728,
83.0814548497863, 94.0539152929977, 79.4016592347326, 85.7829067433969,
75.948295755515, 3.73649805560632, 23.0903794794387, 8.67023149246646,
-6.07704226517408, -3.07641645158295, 9.54851319649848, 17.8889045992558,
5.10657758386499, 18.7016029853773, 25.4522147195668, 6.8023795377009,
15.3767651131782, 20.3683653225209, -20.3254139776893, 15.6691879496879,
9.45068374562864, 18.7361628847212, 12.623384426461, 10.17849269891,
-16.9581826824957, 17.4909319409575, 9.44644950565353, -5.38702617407262,
6.21805297402208, 14.1749418466783, 12.9105548124602, 27.1855440225952,
29.8482741922039, 29.7496920817558, 38.524389832422, 33.7023405759537,
45.3217768361544, 40.1308769909943, 34.4402395511235, 25.068583150376,
26.2353756696678, 21.8111750232141, 33.8629499457315, 29.7131703823705,
34.1556614684988, 34.1245105271038, 18.3147946286069, 27.3066155417929,
26.5207184421978, 34.0884687114446, 26.639481645307, 38.6173778182637,
37.8098024973006, 13.0741049202031, 45.5358046032432), Coord2 = c(69.9894126325745,
64.8743763485989, 82.4286751251657, 63.3941714859759, 71.6662421480457,
64.4679475985789, 70.9818141479016, 58.5333414006127, 57.5007274347188,
67.978883174351, 71.7750032484243, 83.0764732083471, 56.5706459545147,
78.6108303958077, 72.3287500312082, 80.4225709350104, 83.2909825415992,
79.4595795345076, 60.1437449584155, 57.8413316685676, 53.7079406423028,
70.9231623851271, 69.7788257690901, 75.1347791237738, 67.7044636198011,
94.3340903929599, 102.873693143552, 65.8173572622545, 76.2734860629939,
85.2060002479906, 90.1101352051085, 96.2874409924653, 109.760633210447,
94.6155820846595, 95.2601614162185, 69.4981680111657, 84.4916642548314,
84.207250490172, 95.2814397728582, 88.6024629127233, 105.45937855117,
101.73736873413, 96.3994065298907, 89.5148162082444, 85.656552291334,
87.1768687739584, 103.397297430617, 100.466406474931, 97.492149943699,
95.7799794375843, 58.689787023173, 91.7856309013427, 70.284597504488,
82.5264495002628, 72.563622499658, 67.9271039063317, 76.9752642043184,
77.0427295652995, 60.493215584824, 71.9177768464766, 85.2536338000138,
78.6037513000414, 79.9167528070661, 45.2538960490244, 73.7270619632537,
74.1775039120291, 79.3753619281975, 72.5802290852752, 77.6589441840394,
65.0442876775209, 75.9474471250248, 67.6324983845202, 66.7269504282668,
61.4684933637993, 84.9370241657568, 100.807408193669, 90.6253499380336,
82.4392258080415, 85.978657057683, 85.5556977940698, 80.0069018830692,
92.0205306026153, 92.2799374212157, 92.075887951686, 84.046647740422,
95.2469867954641, 90.4378832940894, 103.868141681032, 96.1678027516943,
97.556915790983, 75.8136031118073, 87.269403250105, 102.176170079899,
83.303319611484, 77.0422898434913, 94.9522487152654, 93.5056368803038,
99.6066565241826, 93.2540063907868, 75.3235503045194, 4.79683173913879,
-1.77333441979239, 22.2927646778249, 21.2002682830845, 9.2462559574228,
12.9328717922413, 9.71104299233956, 6.02183609528862, 16.5548144989934,
14.9138467115507, 26.4290598776307, 13.2859100121563, 24.6139296632551,
6.01920473648369, 6.44403579988305, 15.0356163044265, 14.0083469209857,
-0.983183926446912, 11.305792234271, 17.6465875981944, -8.94856332381213,
7.36961719889383, 7.92121709811615, -0.418766330916343, -5.42220613778122,
33.1278663709957, 22.5146385498018, 46.6482380411691, 21.1315055557743,
23.3535222367336, 37.0589046029771, 20.5508910389587, 34.3154424989857,
37.5906644856971, 28.9704448512218, 30.6411807554989, 35.4051444540154,
30.0311466912122, 28.7535914372174, 28.4106840578911, 36.8662136858688,
12.898132148862, 46.7570642830409, 30.8475454612592, 19.28210909481,
19.5978468800625, 34.6039683478465, 21.0831790287953, 34.2925742059241,
53.7786968993373, 19.0172370755723, 9.21397428746006, -2.37886313478754,
6.79453923040543, 22.6413009302484, 33.2099355799597, 6.58849285636098,
-11.7836723204909, 5.86738511098067, 3.81888634358306, 20.5825579992258,
9.8827774793369, 14.4441862792073, 12.3532766231854, 10.2334773998435,
22.8131908769118, 23.8680133376392, 9.59780868195676, 24.4068082968655,
11.2009206443726, 13.4244085452577, 22.0625356242069, 12.2526091738859,
-2.39754291555823, 2.00084520595361, 36.7097665883357, 16.9122643222195,
20.0379767031296, 41.4658882877744, 24.0612860080661, 24.7786616325539,
33.9205960391195, 32.0684115690426, 26.5208653130137, 47.3248746356669,
37.8352815877295, 42.4135950414131, 33.8021211637222, 28.309616360779,
24.4645546802529, 32.9897820259554, 17.8194684139265, 36.2084800081616,
37.6500899883031, 22.4961071408182, 47.6368585912597, 57.0362400846021,
43.7894593761563, 23.2634280784332, 54.7477709366998)), row.names = c(NA,
-200L), class = c("tbl_df", "tbl", "data.frame"))
ggplot() +
stat_density_2d(data = df2,
aes(x = Coord1, y = Coord2, group=place, shape="Yuki"),
geom = "polygon", contour = TRUE, colour="darkorchid3", bins = 7, alpha=0.2, show.legend=TRUE) +
geom_polygon(data = df1, aes(x = Coord1, y = Coord2, fill = person), alpha = 0.6) +
geom_point(data = df1, aes(x = Coord1, y = Coord2), size = 1.5, show.legend=FALSE) +
geom_text_repel(data = df1, aes(x = Coord1, y = Coord2, label = place), colour="black") +
ggtitle("Combined Plot", subtitle = "Avery, Doug, Yuki") +
labs(fill = "Person", shape = "") +
guides(shape = guide_legend(order = 2), fill = guide_legend(order = 1))
上面的代码产生了这个图:
最佳答案
将图例放在正确的布局中,但在边界方面做任何事情似乎真的很棘手。我没有使用您的颜色,而是使用 white
颜色仍然独特但不会显示在图例边框上。
fill_color <- c("green", "red", "#444444")
names(fill_color) <- c("Avery", "Doug", "Yuki")
line_color <- c("green", "red", "darkorchid3")
names(line_color) <- c("Avery", "Doug", "Yuki")
ggplot() +
stat_density_2d(data = df2,
# Here using the fill aes instead of shape aes like your
# original input which cause the legend was put into
# two different categories.
aes(x = Coord1, y = Coord2, group=place, fill = "Yuki", color="Yuki",),
geom = "polygon", contour = TRUE,
bins = 7, alpha=0.2, show.legend=TRUE) +
geom_polygon(data = df1, aes(x = Coord1, y = Coord2, fill = person, color = person),
colour = "transparent", alpha = 0.6) +
geom_point(data = df1, aes(x = Coord1, y = Coord2), size = 1.5,
show.legend=FALSE) +
geom_text_repel(data = df1, aes(x = Coord1, y = Coord2, label = place),
colour="black") +
ggtitle("Combined Plot", subtitle = "Avery, Doug, Yuki") +
scale_color_manual(values = line_color, guide = FALSE) +
scale_fill_manual(values = fill_color) +
labs(fill = "Person", shape = "") +
guides(shape = guide_legend(order = 2), fill = guide_legend(order = 1)) +
theme(legend.key = element_rect(fill = NA))
scale_fill_manual
更新操作调色板和 scale_color_manual
]
关于使用多个数据框从图中的ggplot图例中删除不正确的彩色轮廓?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65767760/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!