ggplot scale_alpha_manual用于数据中的离散变量和连续变量

时间:2020-03-14 17:29:37

标签: r ggplot2

我有一些看起来像这样的数据

         variable      value   rfvalue  stdfvalue mean_value                    model
1 Protocol Active  0.7975318  0.000000 0.00000000  0.8833071 2013-07-24 to 2019-07-22
2 Protocol Active  0.2716946  0.000000 0.00000000  0.3929385 2011-10-12 to 2017-10-10
3            Wind  0.7384344  1.806452 0.07128713  0.2818933 2010-01-01 to 2015-12-31
4 Protocol Active  1.2555754  0.000000 0.00000000  0.8833071 2013-07-24 to 2019-07-22
5 Protocol Active  0.8638037  0.000000 0.00000000  0.8833071 2013-07-24 to 2019-07-22
6            Wind -0.4009561 13.419355 0.54027120  0.4125869 2013-07-24 to 2019-07-22

我可以使用以下内容绘制数据:

d %>% 
  ggplot() +
  coord_flip() +
  ggforce::geom_sina(aes(
    x = variable,
    y = value,
    color = stdfvalue,
    alpha = value),
    method = "counts", maxwidth = 1, size = 1) +
  facet_wrap(~model) +
  scale_color_gradient(
    low = "darkblue",
    high = "darkred",
    breaks = c(0, 1),
    labels = c("     Low", "     High"), 
    guide = guide_colorbar(barwidth = 12, barheight = 0.3))

但是,在我的完整数据集上,绘图如下:

enter image description here

(我将darkblue更改为yellow的位置)。 Wind变量看起来不错,它是一个连续变量,但是Protocol Active变量“隐藏”了我要显示的某些数据。它是(0,1)的离散变量,我想更加强调1的值。我尝试添加scale_alpha_manual(values = c(1, 0.1), guide = FALSE),这将返回错误。我也似乎无法使scale_alpha_manual既可以用于离散的也可以用于连续的。

一种尝试是创建两个geom_sina图,并根据两个变量对它们进行过滤-我希望将不同的alpha值应用于它们。我无法使它正常工作。

 ggplot() +
  coord_flip() +
  ggforce::geom_sina(aes(
    x = variable,
    y = value,
    color = stdfvalue),
    method = "counts", maxwidth = 1, size = 1, data = d %>% filter(variable == "Protocol Active")
  ) +
  ggforce::geom_sina(aes(
    x = variable,
    y = value,
    color = stdfvalue,
    alpha = 0.1),
    method = "counts", maxwidth = 1, size = 1, data = d %>% 
      filter(variable == "Wind")
  ) +
  facet_wrap(~model) +
  scale_color_gradient(
    low = "yellow",
    high = "blue1",
    breaks = c(0, 1),
    labels = c("     Low", "     High"), 
    guide = guide_colorbar(barwidth = 12, barheight = 0.3))

我的问题是,如何设置离散变量的alpha,以便可以更强调地显示某个类。知道是否可以在同一图上设置scale_alpha_continuousscale_alpha_discrete会很有趣。我也乐意听到其他解决方法。

数据:

    d <- structure(list(variable = c("Wind", "Wind", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Wind", "Protocol Active", 
"Wind", "Wind", "Wind", "Wind", "Wind", "Protocol Active", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Protocol Active", 
"Protocol Active", "Wind", "Protocol Active", "Wind", "Wind", 
"Protocol Active", "Protocol Active", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Wind", "Protocol Active", "Protocol Active", 
"Protocol Active", "Protocol Active", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Protocol Active", "Wind", "Wind", 
"Protocol Active", "Wind", "Protocol Active", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Protocol Active", 
"Protocol Active", "Protocol Active", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Protocol Active", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Wind", "Wind", 
"Wind", "Wind", "Protocol Active", "Wind", "Protocol Active", 
"Wind", "Wind", "Protocol Active", "Protocol Active", "Wind", 
"Protocol Active", "Wind", "Protocol Active", "Wind", "Wind", 
"Protocol Active", "Protocol Active", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Protocol Active", 
"Wind", "Wind", "Wind", "Wind", "Wind", "Protocol Active", "Wind", 
"Protocol Active", "Protocol Active", "Protocol Active", "Wind", 
"Protocol Active", "Wind", "Wind", "Protocol Active", "Wind", 
"Wind", "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active", 
"Protocol Active", "Protocol Active", "Protocol Active", "Wind", 
"Wind", "Protocol Active", "Wind", "Wind", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Wind", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Protocol Active", 
"Protocol Active", "Wind", "Wind", "Protocol Active", "Wind", 
"Wind", "Protocol Active", "Wind", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Wind", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Protocol Active", "Wind", "Wind", 
"Wind", "Wind", "Protocol Active", "Wind", "Protocol Active", 
"Protocol Active", "Protocol Active", "Protocol Active", "Wind", 
"Wind", "Wind", "Wind", "Wind", "Protocol Active", "Protocol Active", 
"Wind", "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active", 
"Wind", "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active", 
"Protocol Active", "Protocol Active", "Protocol Active", "Wind", 
"Wind", "Protocol Active", "Protocol Active", "Wind", "Protocol Active"
), value = c(-0.0989474654197693, 0.629822552204132, -0.0962040945887566, 
1.29249930381775, 0, 0.434465348720551, -0.28844028711319, 0.217110589146614, 
0, 0.315992414951324, 0.538330733776093, -0.096613846719265, 
0.845123291015625, 0, -0.398098558187485, -0.275375932455063, 
0.623717963695526, 0.767583787441254, -0.220980376005173, 0, 
0.856497704982758, -0.0572838261723518, 0, 0, 0.503492951393127, 
0.283374071121216, -0.0997775197029114, 0, -0.185573473572731, 
0.541458964347839, 0.828957080841064, 0.298303335905075, -0.0101631181314588, 
0, -0.15062090754509, 0.81750363111496, 0.598546028137207, 0, 
0.826459050178528, 0.250531941652298, 0, -0.297038346529007, 
0.415378659963608, 0, -0.242933213710785, 0.753650367259979, 
-0.161409094929695, -0.752240180969238, 0, 0.736700534820557, 
0, -0.0983792245388031, 1.13214647769928, 0.286624670028687, 
0.849360644817352, 0.906382441520691, 0.768399834632874, 0.542866706848145, 
-0.312404543161392, 0, 0.483780354261398, 0, 0.791863441467285, 
0.487868845462799, -0.336384683847427, 0.365867704153061, 0.458498805761337, 
-0.326053828001022, 0.786870658397675, 0.625235676765442, 1.05334162712097, 
1.27674341201782, -0.402126729488373, 1.35678279399872, 0, -0.0197668727487326, 
0.977747678756714, 0.666797459125519, -0.267341256141663, 0.655228078365326, 
0.0420738272368908, 0.430610090494156, 0, -0.122896425426006, 
0.267312049865723, -0.18688802421093, 0.650719821453094, 0, 0, 
0.00512066995725036, 0.715728044509888, 0.593662261962891, 0.810122668743134, 
0.635514199733734, 0.599373757839203, 0, 0, -0.549852848052979, 
1.05160856246948, -0.0583889335393906, 0.485096544027328, 0, 
1.2462295293808, -0.339758694171906, -0.306385368108749, -0.29257345199585, 
-0.198688685894012, -0.140972256660461, 0, -0.0293861590325832, 
0.26350411772728, 0, 0.714957416057587, -0.100245490670204, 0, 
-0.0799269378185272, -0.141207844018936, 0, -0.260594755411148, 
-0.495336472988129, 0.0901876837015152, -0.392557889223099, 0.269983738660812, 
-0.415697365999222, 0.537323653697968, 1.01686215400696, 0.707460880279541, 
0.279224544763565, 0.56487512588501, -0.134432524442673, 0.54803729057312, 
0.477457016706467, -0.189187243580818, 0.871891617774963, 0.69837349653244, 
-0.58046156167984, 0.443165421485901, -0.421287506818771, 1.06587362289429, 
0.272987455129623, 0.540521800518036, 0, 0, 0.536158978939056, 
0, 0.0309308655560017, 0.625024020671844, 0, -0.286852031946182, 
0.626144170761108, 0.507866978645325, 0.529027938842773, -0.101144313812256, 
0, 0.777739226818085, 0, -0.414799422025681, 1.35438084602356, 
0.860056400299072, 0.590310633182526, 0.667994678020477, 0.537133276462555, 
-0.0919286012649536, -0.29287400841713, 0.899238407611847, 0.0362688936293125, 
0, -0.550533652305603, 0, 0.5471071600914, 1.18974375724792, 
0.381776362657547, 0.682958662509918, -0.35002875328064, -0.254838764667511, 
0.856454491615295, 0.0177191141992807, 0.781686365604401, 0.759931743144989, 
1.08820796012878, 0.626882433891296, -0.242740288376808, 0.770202159881592, 
0.904597997665405, 0.892723023891449, -0.386538952589035, 0, 
-0.393929898738861, -0.103308126330376, -0.377305179834366, 0.483622252941132, 
0.743905782699585, 0.778063476085663, 0, -0.440237790346146, 
-0.12215880304575, 0.73518306016922, 0, -0.288508862257004, 1.30829179286957
), rfvalue = c(3.96153846153846, 2.03703703703704, 4.83870967741935, 
0, 0, 2.48387096774194, 12.4117647058824, 2.87096774193548, 0, 
0, 3.1875, 4.375, 3.11538461538462, 0, 11.3636363636364, 8.20833333333333, 
0.653846153846154, 0.935483870967742, 4.51612903225806, 0, 0, 
3.80645161290323, 0, 0, 0, 0, 4.16129032258065, 0, 6.0625, 2.83870967741935, 
0, 0, 3.7, 0, 7.58064516129032, 0, 1.96551724137931, 0, 0, 0, 
0, 11.8064516129032, 0, 0, 8.48387096774194, 0, 4.06451612903226, 
24.5, 0, 1.23076923076923, 0, 7.55555555555556, 0, 0, 0.612903225806452, 
0.566666666666667, 2.07142857142857, 0, 10.3548387096774, 0, 
0, 0, 0, 0, 5.55555555555556, 0, 0, 10.6363636363636, 2.2, 2.87096774193548, 
0, 0, 12.9259259259259, 0, 0, 3.73076923076923, 0, 0, 8.83870967741935, 
1.07407407407407, 3.32258064516129, 2.7037037037037, 0, 4.66666666666667, 
0, 6.59375, 1.48148148148148, 0, 0, 3.57575757575758, 0, 0.259259259259259, 
0, 1.96296296296296, 1.88888888888889, 0, 0, 13.6818181818182, 
0, 4.24, 0, 0, 1, 11.3214285714286, 10.741935483871, 5.54838709677419, 
3.94117647058824, 6.44117647058824, 0, 7.16129032258065, 0, 0, 
0, 3.96774193548387, 0, 4.48387096774194, 4.16129032258065, 0, 
5.12121212121212, 15.7741935483871, 3.78787878787879, 7, 0, 7.52, 
0, 0, 1, 0, 2.51612903225806, 5.24242424242424, 0, 2.21875, 5.16129032258065, 
0, 0, 15.962962962963, 1.96875, 11.8666666666667, 0.407407407407407, 
0, 1.87096774193548, 0, 0, 0, 0, 3.42424242424242, 2.2, 0, 6.87096774193548, 
2.41666666666667, 0, 1.74193548387097, 8.04761904761905, 0, 2.16129032258065, 
0, 13.4516129032258, 0.555555555555556, 0, 2.14285714285714, 
0, 0, 4.32352941176471, 4.56521739130435, 1.88888888888889, 3.64705882352941, 
0, 20.2222222222222, 0, 0, 0, 0, 2.38709677419355, 11.6774193548387, 
9.41935483870968, 0.407407407407407, 3.09677419354839, 0, 0, 
0.807692307692308, 2.72, 6.09677419354839, 0, 0.833333333333333, 
0, 9.125, 0, 14, 4.70588235294118, 6.43333333333333, 0, 0, 0, 
0, 13.0645161290323, 5.61290322580645, 0, 0, 11.8076923076923, 
0), stdfvalue = c(0.157298598329322, 0.0798326069229873, 0.195379537953795, 
0, 1, 0.099009900990099, 0.505299941758882, 0.113583763574862, 
1, 0, 0.125955684553306, 0.174040775874274, 0.123035537307093, 
1, 0.457029590825428, 0.329599628113069, 0.0233611779697013, 
0.035250133523233, 0.180167349118747, 1, 0, 0.151018711778327, 
1, 1, 0, 0, 0.167656765676568, 1, 0.242752655628746, 0.111832219700118, 
0, 0, 0.148778877887789, 1, 0.304195596700493, 0, 0.0769380308955367, 
1, 0, 0, 1, 0.480528052805281, 0, 1, 0.340751290724586, 0, 0.1618895021067, 
0.988956534050687, 1, 0.0467223559394025, 1, 0.306563989732307, 
0, 0, 0.0221945285146282, 0.0205500550055006, 0.0807629295523958, 
0, 0.416180641507538, 1, 0, 1, 0, 0, 0.221844667830793, 0, 0, 
0.427867782327458, 0.0859691349285006, 0.113138436102725, 0, 
0, 0.520531807102337, 0, 1, 0.15003808073115, 0, 0, 0.355112456234051, 
0.0403773446389898, 0.133333333333333, 0.108006356191175, 1, 
0.188338833883388, 0, 0.264253605127292, 0.0573479538526123, 
1, 1, 0.141677285383926, 0, 0.00738328587684385, 0, 0.0768346531802707, 
0.073836699437554, 1, 1, 0.550899051394591, 0, 0.168574260229364, 
0, 1, 1, 0.460678925035361, 0.43214052578482, 0.221554397519102, 
0.156897653132822, 0.258078591949509, 1, 0.29042904290429, 0, 
1, 0, 0.15973597359736, 1, 0.180858085808581, 0.167656765676568, 
1, 0.204256925763368, 0.635807963919055, 0.152375237523752, 0.280334135636415, 
0, 0.301390344046439, 0, 0, 1, 0, 0.0992225980653967, 0.211901190119012, 
0, 0.0881600660066007, 0.206278559135956, 0, 0, 0.643268782020021, 
0.0779290429042904, 0.482992299229923, 0.0138776245832207, 0, 
0.0731113880481871, 1, 1, 0, 1, 0.137493749374937, 0.086428105156964, 
1, 0.275109270025987, 0.094742555099344, 0, 0.0686468646864686, 
0.326701241552727, 1, 0.0844016752453723, 1, 0.541577416157806, 
0.019873532068654, 0, 0.0850542197076851, 0, 0, 0.171956592349527, 
0.181743193248343, 0.0746607994132747, 0.144564466024269, 1, 
0.824935826916025, 1, 0, 0, 0, 0.093545190063621, 0.469735514014423, 
0.382838283828383, 0.0138776245832207, 0.124092409240924, 0, 
0, 0.0304138106118304, 0.107473740430835, 0.24413981366091, 0, 
0.0314631463146315, 0, 0.366699305679188, 1, 0.57029702970297, 
0.189943700252378, 0.257388267497286, 0, 0, 0, 1, 0.526140881846775, 
0.227062706270627, 0, 1, 0.475010618717259, 0), mean_value = c(0.412586940491501, 
0.357086707604185, 0.281893344972611, 0.88330711205256, 0, 0.281893344972611, 
0.281893344972611, 0.357086707604185, 0, 0.392938510590492, 0.412586940491501, 
0.412586940491501, 0.412586940491501, 0, 0.412586940491501, 0.357086707604185, 
0.412586940491501, 0.357086707604185, 0.357086707604185, 0, 0.88330711205256, 
0.412586940491501, 0, 0, 0.392938510590492, 0.392938510590492, 
0.281893344972611, 0, 0.357086707604185, 0.412586940491501, 0.88330711205256, 
0.392938510590492, 0.281893344972611, 0, 0.357086707604185, 0.88330711205256, 
0.357086707604185, 0, 0.88330711205256, 0.392938510590492, 0, 
0.281893344972611, 0.392938510590492, 0, 0.357086707604185, 0.88330711205256, 
0.357086707604185, 0.412586940491501, 0, 0.412586940491501, 0, 
0.281893344972611, 0.88330711205256, 0.392938510590492, 0.357086707604185, 
0.281893344972611, 0.412586940491501, 0.392938510590492, 0.412586940491501, 
0, 0.392938510590492, 0, 0.88330711205256, 0.392938510590492, 
0.412586940491501, 0.392938510590492, 0.392938510590492, 0.357086707604185, 
0.412586940491501, 0.412586940491501, 0.88330711205256, 0.88330711205256, 
0.357086707604185, 0.88330711205256, 0, 0.281893344972611, 0.88330711205256, 
0.392938510590492, 0.357086707604185, 0.412586940491501, 0.281893344972611, 
0.281893344972611, 0, 0.281893344972611, 0.392938510590492, 0.357086707604185, 
0.357086707604185, 0, 0, 0.412586940491501, 0.88330711205256, 
0.412586940491501, 0.88330711205256, 0.357086707604185, 0.357086707604185, 
0, 0, 0.412586940491501, 0.88330711205256, 0.412586940491501, 
0.392938510590492, 0, 0.88330711205256, 0.281893344972611, 0.357086707604185, 
0.412586940491501, 0.357086707604185, 0.357086707604185, 0, 0.281893344972611, 
0.392938510590492, 0, 0.88330711205256, 0.281893344972611, 0, 
0.281893344972611, 0.281893344972611, 0, 0.412586940491501, 0.357086707604185, 
0.281893344972611, 0.412586940491501, 0.392938510590492, 0.412586940491501, 
0.392938510590492, 0.88330711205256, 0.88330711205256, 0.392938510590492, 
0.357086707604185, 0.281893344972611, 0.392938510590492, 0.281893344972611, 
0.357086707604185, 0.88330711205256, 0.88330711205256, 0.412586940491501, 
0.281893344972611, 0.281893344972611, 0.357086707604185, 0.392938510590492, 
0.357086707604185, 0, 0, 0.392938510590492, 0, 0.281893344972611, 
0.357086707604185, 0, 0.412586940491501, 0.412586940491501, 0.392938510590492, 
0.281893344972611, 0.281893344972611, 0, 0.412586940491501, 0, 
0.412586940491501, 0.357086707604185, 0.88330711205256, 0.281893344972611, 
0.88330711205256, 0.392938510590492, 0.412586940491501, 0.412586940491501, 
0.281893344972611, 0.412586940491501, 0, 0.281893344972611, 0, 
0.392938510590492, 0.88330711205256, 0.392938510590492, 0.412586940491501, 
0.412586940491501, 0.281893344972611, 0.357086707604185, 0.281893344972611, 
0.88330711205256, 0.88330711205256, 0.281893344972611, 0.357086707604185, 
0.357086707604185, 0.88330711205256, 0.281893344972611, 0.88330711205256, 
0.357086707604185, 0, 0.281893344972611, 0.281893344972611, 0.412586940491501, 
0.392938510590492, 0.88330711205256, 0.88330711205256, 0, 0.357086707604185, 
0.281893344972611, 0.88330711205256, 0, 0.412586940491501, 0.88330711205256
), model = c("2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", 
"2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", 
"2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", 
"2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", 
"2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22"
)), row.names = c(NA, -200L), class = "data.frame")

1 个答案:

答案 0 :(得分:1)

如果我理解的正确,那么您想要实现的目标可以通过scale_alpha_identity完成。作为示例,我向您的数据集中添加了一个变量alpha,该变量定义了value到特定alpha级别的映射(或中断)。然后,将这个新变量映射到ggplot内部的alpha美观度上。默认情况下,不会显示图例,因此您必须通过指定所需的中断和标签来手动设置它。

关于第二个问题。据我所知,不可能将scale_xxx_discrete和scale_xxx_continuous混合使用。您可以将不同的变量映射到相同的比例,但是每种美学仅具有比例,它可以是离散的也可以是连续的。如果要对比例尺进行更多控制,则必须绘制两个图并将其粘在一起,例如由patchwork

# Packages ----------------------------------------------------------------
library(ggplot2)
library(ggforce)
library(dplyr)
# Data --------------------------------------------------------------------


d <- structure(list(variable = c(
  "Wind", "Wind", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active",
  "Wind", "Wind", "Wind", "Wind", "Wind", "Protocol Active", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Protocol Active",
  "Protocol Active", "Wind", "Protocol Active", "Wind", "Wind",
  "Protocol Active", "Protocol Active", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Wind", "Protocol Active", "Protocol Active",
  "Protocol Active", "Protocol Active", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Protocol Active", "Wind", "Wind",
  "Protocol Active", "Wind", "Protocol Active", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Protocol Active",
  "Protocol Active", "Protocol Active", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Protocol Active", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Wind", "Wind",
  "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active",
  "Wind", "Wind", "Protocol Active", "Protocol Active", "Wind",
  "Protocol Active", "Wind", "Protocol Active", "Wind", "Wind",
  "Protocol Active", "Protocol Active", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Protocol Active",
  "Wind", "Wind", "Wind", "Wind", "Wind", "Protocol Active", "Wind",
  "Protocol Active", "Protocol Active", "Protocol Active", "Wind",
  "Protocol Active", "Wind", "Wind", "Protocol Active", "Wind",
  "Wind", "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active",
  "Protocol Active", "Protocol Active", "Protocol Active", "Wind",
  "Wind", "Protocol Active", "Wind", "Wind", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Wind", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Protocol Active",
  "Protocol Active", "Wind", "Wind", "Protocol Active", "Wind",
  "Wind", "Protocol Active", "Wind", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Wind", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Protocol Active", "Wind", "Wind",
  "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active",
  "Protocol Active", "Protocol Active", "Protocol Active", "Wind",
  "Wind", "Wind", "Wind", "Wind", "Protocol Active", "Protocol Active",
  "Wind", "Wind", "Wind", "Protocol Active", "Wind", "Protocol Active",
  "Wind", "Protocol Active", "Wind", "Wind", "Wind", "Protocol Active",
  "Protocol Active", "Protocol Active", "Protocol Active", "Wind",
  "Wind", "Protocol Active", "Protocol Active", "Wind", "Protocol Active"
), value = c(
  -0.0989474654197693, 0.629822552204132, -0.0962040945887566,
  1.29249930381775, 0, 0.434465348720551, -0.28844028711319, 0.217110589146614,
  0, 0.315992414951324, 0.538330733776093, -0.096613846719265,
  0.845123291015625, 0, -0.398098558187485, -0.275375932455063,
  0.623717963695526, 0.767583787441254, -0.220980376005173, 0,
  0.856497704982758, -0.0572838261723518, 0, 0, 0.503492951393127,
  0.283374071121216, -0.0997775197029114, 0, -0.185573473572731,
  0.541458964347839, 0.828957080841064, 0.298303335905075, -0.0101631181314588,
  0, -0.15062090754509, 0.81750363111496, 0.598546028137207, 0,
  0.826459050178528, 0.250531941652298, 0, -0.297038346529007,
  0.415378659963608, 0, -0.242933213710785, 0.753650367259979,
  -0.161409094929695, -0.752240180969238, 0, 0.736700534820557,
  0, -0.0983792245388031, 1.13214647769928, 0.286624670028687,
  0.849360644817352, 0.906382441520691, 0.768399834632874, 0.542866706848145,
  -0.312404543161392, 0, 0.483780354261398, 0, 0.791863441467285,
  0.487868845462799, -0.336384683847427, 0.365867704153061, 0.458498805761337,
  -0.326053828001022, 0.786870658397675, 0.625235676765442, 1.05334162712097,
  1.27674341201782, -0.402126729488373, 1.35678279399872, 0, -0.0197668727487326,
  0.977747678756714, 0.666797459125519, -0.267341256141663, 0.655228078365326,
  0.0420738272368908, 0.430610090494156, 0, -0.122896425426006,
  0.267312049865723, -0.18688802421093, 0.650719821453094, 0, 0,
  0.00512066995725036, 0.715728044509888, 0.593662261962891, 0.810122668743134,
  0.635514199733734, 0.599373757839203, 0, 0, -0.549852848052979,
  1.05160856246948, -0.0583889335393906, 0.485096544027328, 0,
  1.2462295293808, -0.339758694171906, -0.306385368108749, -0.29257345199585,
  -0.198688685894012, -0.140972256660461, 0, -0.0293861590325832,
  0.26350411772728, 0, 0.714957416057587, -0.100245490670204, 0,
  -0.0799269378185272, -0.141207844018936, 0, -0.260594755411148,
  -0.495336472988129, 0.0901876837015152, -0.392557889223099, 0.269983738660812,
  -0.415697365999222, 0.537323653697968, 1.01686215400696, 0.707460880279541,
  0.279224544763565, 0.56487512588501, -0.134432524442673, 0.54803729057312,
  0.477457016706467, -0.189187243580818, 0.871891617774963, 0.69837349653244,
  -0.58046156167984, 0.443165421485901, -0.421287506818771, 1.06587362289429,
  0.272987455129623, 0.540521800518036, 0, 0, 0.536158978939056,
  0, 0.0309308655560017, 0.625024020671844, 0, -0.286852031946182,
  0.626144170761108, 0.507866978645325, 0.529027938842773, -0.101144313812256,
  0, 0.777739226818085, 0, -0.414799422025681, 1.35438084602356,
  0.860056400299072, 0.590310633182526, 0.667994678020477, 0.537133276462555,
  -0.0919286012649536, -0.29287400841713, 0.899238407611847, 0.0362688936293125,
  0, -0.550533652305603, 0, 0.5471071600914, 1.18974375724792,
  0.381776362657547, 0.682958662509918, -0.35002875328064, -0.254838764667511,
  0.856454491615295, 0.0177191141992807, 0.781686365604401, 0.759931743144989,
  1.08820796012878, 0.626882433891296, -0.242740288376808, 0.770202159881592,
  0.904597997665405, 0.892723023891449, -0.386538952589035, 0,
  -0.393929898738861, -0.103308126330376, -0.377305179834366, 0.483622252941132,
  0.743905782699585, 0.778063476085663, 0, -0.440237790346146,
  -0.12215880304575, 0.73518306016922, 0, -0.288508862257004, 1.30829179286957
), rfvalue = c(
  3.96153846153846, 2.03703703703704, 4.83870967741935,
  0, 0, 2.48387096774194, 12.4117647058824, 2.87096774193548, 0,
  0, 3.1875, 4.375, 3.11538461538462, 0, 11.3636363636364, 8.20833333333333,
  0.653846153846154, 0.935483870967742, 4.51612903225806, 0, 0,
  3.80645161290323, 0, 0, 0, 0, 4.16129032258065, 0, 6.0625, 2.83870967741935,
  0, 0, 3.7, 0, 7.58064516129032, 0, 1.96551724137931, 0, 0, 0,
  0, 11.8064516129032, 0, 0, 8.48387096774194, 0, 4.06451612903226,
  24.5, 0, 1.23076923076923, 0, 7.55555555555556, 0, 0, 0.612903225806452,
  0.566666666666667, 2.07142857142857, 0, 10.3548387096774, 0,
  0, 0, 0, 0, 5.55555555555556, 0, 0, 10.6363636363636, 2.2, 2.87096774193548,
  0, 0, 12.9259259259259, 0, 0, 3.73076923076923, 0, 0, 8.83870967741935,
  1.07407407407407, 3.32258064516129, 2.7037037037037, 0, 4.66666666666667,
  0, 6.59375, 1.48148148148148, 0, 0, 3.57575757575758, 0, 0.259259259259259,
  0, 1.96296296296296, 1.88888888888889, 0, 0, 13.6818181818182,
  0, 4.24, 0, 0, 1, 11.3214285714286, 10.741935483871, 5.54838709677419,
  3.94117647058824, 6.44117647058824, 0, 7.16129032258065, 0, 0,
  0, 3.96774193548387, 0, 4.48387096774194, 4.16129032258065, 0,
  5.12121212121212, 15.7741935483871, 3.78787878787879, 7, 0, 7.52,
  0, 0, 1, 0, 2.51612903225806, 5.24242424242424, 0, 2.21875, 5.16129032258065,
  0, 0, 15.962962962963, 1.96875, 11.8666666666667, 0.407407407407407,
  0, 1.87096774193548, 0, 0, 0, 0, 3.42424242424242, 2.2, 0, 6.87096774193548,
  2.41666666666667, 0, 1.74193548387097, 8.04761904761905, 0, 2.16129032258065,
  0, 13.4516129032258, 0.555555555555556, 0, 2.14285714285714,
  0, 0, 4.32352941176471, 4.56521739130435, 1.88888888888889, 3.64705882352941,
  0, 20.2222222222222, 0, 0, 0, 0, 2.38709677419355, 11.6774193548387,
  9.41935483870968, 0.407407407407407, 3.09677419354839, 0, 0,
  0.807692307692308, 2.72, 6.09677419354839, 0, 0.833333333333333,
  0, 9.125, 0, 14, 4.70588235294118, 6.43333333333333, 0, 0, 0,
  0, 13.0645161290323, 5.61290322580645, 0, 0, 11.8076923076923,
  0
), stdfvalue = c(
  0.157298598329322, 0.0798326069229873, 0.195379537953795,
  0, 1, 0.099009900990099, 0.505299941758882, 0.113583763574862,
  1, 0, 0.125955684553306, 0.174040775874274, 0.123035537307093,
  1, 0.457029590825428, 0.329599628113069, 0.0233611779697013,
  0.035250133523233, 0.180167349118747, 1, 0, 0.151018711778327,
  1, 1, 0, 0, 0.167656765676568, 1, 0.242752655628746, 0.111832219700118,
  0, 0, 0.148778877887789, 1, 0.304195596700493, 0, 0.0769380308955367,
  1, 0, 0, 1, 0.480528052805281, 0, 1, 0.340751290724586, 0, 0.1618895021067,
  0.988956534050687, 1, 0.0467223559394025, 1, 0.306563989732307,
  0, 0, 0.0221945285146282, 0.0205500550055006, 0.0807629295523958,
  0, 0.416180641507538, 1, 0, 1, 0, 0, 0.221844667830793, 0, 0,
  0.427867782327458, 0.0859691349285006, 0.113138436102725, 0,
  0, 0.520531807102337, 0, 1, 0.15003808073115, 0, 0, 0.355112456234051,
  0.0403773446389898, 0.133333333333333, 0.108006356191175, 1,
  0.188338833883388, 0, 0.264253605127292, 0.0573479538526123,
  1, 1, 0.141677285383926, 0, 0.00738328587684385, 0, 0.0768346531802707,
  0.073836699437554, 1, 1, 0.550899051394591, 0, 0.168574260229364,
  0, 1, 1, 0.460678925035361, 0.43214052578482, 0.221554397519102,
  0.156897653132822, 0.258078591949509, 1, 0.29042904290429, 0,
  1, 0, 0.15973597359736, 1, 0.180858085808581, 0.167656765676568,
  1, 0.204256925763368, 0.635807963919055, 0.152375237523752, 0.280334135636415,
  0, 0.301390344046439, 0, 0, 1, 0, 0.0992225980653967, 0.211901190119012,
  0, 0.0881600660066007, 0.206278559135956, 0, 0, 0.643268782020021,
  0.0779290429042904, 0.482992299229923, 0.0138776245832207, 0,
  0.0731113880481871, 1, 1, 0, 1, 0.137493749374937, 0.086428105156964,
  1, 0.275109270025987, 0.094742555099344, 0, 0.0686468646864686,
  0.326701241552727, 1, 0.0844016752453723, 1, 0.541577416157806,
  0.019873532068654, 0, 0.0850542197076851, 0, 0, 0.171956592349527,
  0.181743193248343, 0.0746607994132747, 0.144564466024269, 1,
  0.824935826916025, 1, 0, 0, 0, 0.093545190063621, 0.469735514014423,
  0.382838283828383, 0.0138776245832207, 0.124092409240924, 0,
  0, 0.0304138106118304, 0.107473740430835, 0.24413981366091, 0,
  0.0314631463146315, 0, 0.366699305679188, 1, 0.57029702970297,
  0.189943700252378, 0.257388267497286, 0, 0, 0, 1, 0.526140881846775,
  0.227062706270627, 0, 1, 0.475010618717259, 0
), mean_value = c(
  0.412586940491501,
  0.357086707604185, 0.281893344972611, 0.88330711205256, 0, 0.281893344972611,
  0.281893344972611, 0.357086707604185, 0, 0.392938510590492, 0.412586940491501,
  0.412586940491501, 0.412586940491501, 0, 0.412586940491501, 0.357086707604185,
  0.412586940491501, 0.357086707604185, 0.357086707604185, 0, 0.88330711205256,
  0.412586940491501, 0, 0, 0.392938510590492, 0.392938510590492,
  0.281893344972611, 0, 0.357086707604185, 0.412586940491501, 0.88330711205256,
  0.392938510590492, 0.281893344972611, 0, 0.357086707604185, 0.88330711205256,
  0.357086707604185, 0, 0.88330711205256, 0.392938510590492, 0,
  0.281893344972611, 0.392938510590492, 0, 0.357086707604185, 0.88330711205256,
  0.357086707604185, 0.412586940491501, 0, 0.412586940491501, 0,
  0.281893344972611, 0.88330711205256, 0.392938510590492, 0.357086707604185,
  0.281893344972611, 0.412586940491501, 0.392938510590492, 0.412586940491501,
  0, 0.392938510590492, 0, 0.88330711205256, 0.392938510590492,
  0.412586940491501, 0.392938510590492, 0.392938510590492, 0.357086707604185,
  0.412586940491501, 0.412586940491501, 0.88330711205256, 0.88330711205256,
  0.357086707604185, 0.88330711205256, 0, 0.281893344972611, 0.88330711205256,
  0.392938510590492, 0.357086707604185, 0.412586940491501, 0.281893344972611,
  0.281893344972611, 0, 0.281893344972611, 0.392938510590492, 0.357086707604185,
  0.357086707604185, 0, 0, 0.412586940491501, 0.88330711205256,
  0.412586940491501, 0.88330711205256, 0.357086707604185, 0.357086707604185,
  0, 0, 0.412586940491501, 0.88330711205256, 0.412586940491501,
  0.392938510590492, 0, 0.88330711205256, 0.281893344972611, 0.357086707604185,
  0.412586940491501, 0.357086707604185, 0.357086707604185, 0, 0.281893344972611,
  0.392938510590492, 0, 0.88330711205256, 0.281893344972611, 0,
  0.281893344972611, 0.281893344972611, 0, 0.412586940491501, 0.357086707604185,
  0.281893344972611, 0.412586940491501, 0.392938510590492, 0.412586940491501,
  0.392938510590492, 0.88330711205256, 0.88330711205256, 0.392938510590492,
  0.357086707604185, 0.281893344972611, 0.392938510590492, 0.281893344972611,
  0.357086707604185, 0.88330711205256, 0.88330711205256, 0.412586940491501,
  0.281893344972611, 0.281893344972611, 0.357086707604185, 0.392938510590492,
  0.357086707604185, 0, 0, 0.392938510590492, 0, 0.281893344972611,
  0.357086707604185, 0, 0.412586940491501, 0.412586940491501, 0.392938510590492,
  0.281893344972611, 0.281893344972611, 0, 0.412586940491501, 0,
  0.412586940491501, 0.357086707604185, 0.88330711205256, 0.281893344972611,
  0.88330711205256, 0.392938510590492, 0.412586940491501, 0.412586940491501,
  0.281893344972611, 0.412586940491501, 0, 0.281893344972611, 0,
  0.392938510590492, 0.88330711205256, 0.392938510590492, 0.412586940491501,
  0.412586940491501, 0.281893344972611, 0.357086707604185, 0.281893344972611,
  0.88330711205256, 0.88330711205256, 0.281893344972611, 0.357086707604185,
  0.357086707604185, 0.88330711205256, 0.281893344972611, 0.88330711205256,
  0.357086707604185, 0, 0.281893344972611, 0.281893344972611, 0.412586940491501,
  0.392938510590492, 0.88330711205256, 0.88330711205256, 0, 0.357086707604185,
  0.281893344972611, 0.88330711205256, 0, 0.412586940491501, 0.88330711205256
), model = c(
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10", "2013-07-24 to 2019-07-22",
  "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2011-10-12 to 2017-10-10", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2010-01-01 to 2015-12-31",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2011-10-12 to 2017-10-10",
  "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22", "2010-01-01 to 2015-12-31",
  "2011-10-12 to 2017-10-10", "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22",
  "2010-01-01 to 2015-12-31", "2013-07-24 to 2019-07-22", "2013-07-24 to 2019-07-22"
)), row.names = c(NA, -200L), class = "data.frame")



# Plot --------------------------------------------------------------------

d %>%
  mutate(alpha = case_when(
    variable == "Wind" ~ ifelse(value > 1, 1, 0.5),
    TRUE ~ ifelse(value > 0, 1, .2)
  )) %>%
  ggplot() +
  coord_flip() +
  ggforce::geom_sina(aes(
    x = variable,
    y = value,
    color = stdfvalue,
    alpha = alpha
  ),
  method = "counts", maxwidth = 1, size = 1
  ) +
  facet_wrap(~model) +
  scale_color_gradient(
    low = "yellow",
    high = "darkred",
    breaks = c(0, 1),
    labels = c("     Low", "     High"),
    guide = guide_colorbar(barwidth = 12, barheight = 0.3)
  ) +
  scale_alpha_identity(breaks = c(.2, .5, 1), labels = c("One", "Two", "Three"), guide = "legend") +
  theme(legend.position = "bottom")

reprex package(v0.3.0)于2020-03-15创建