Я хотел бы добавить заголовок к моей легенде.Аргументы «заливка» и «цвет» имеют одну и ту же переменную: varC (14 факторов).
Я печатаю свой ggplot с функцией style () .Без функции стиля это работает нормально, но когда я ее добавляю, это не так.Графически преобразует легенду заголовка в аннотацию на вершине легенды ... Как два добавить две аннотации с правильной позиции?Любые предложения?
g.mean <- ggplot(ex,aes(x = xx,y=yy,color=varC)) +
geom_line() +
geom_ribbon(aes(ymin=Born_Inf, ymax=Born_Sup, fill=varC), alpha=0.1) +
labs(title="My graph title",x="xlab name",y="ylab name",color="legend line title",fill="legend ribbon title")
g.final <- style(ggplotly(g.mean, tooltip = c("varC","x","y")),hoverinfo = "value
ДАННЫЕ:
ex <- structure(list(varC = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Factor 1 ",
"Factor 2 ", "Factor 3 ", "Factor 4 ", "Factor 5 ", "Factor 6 ",
"Factor 7 ", "Factor 8 ", "Factor 9 ", "Factor 10 ", "Factor 11 ",
"Factor 12 ", "Factor 13 ", "Factor 14 "), class = "factor"),
xx = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24), Born_Inf = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), Born_Sup = c(17581.818,
14155.036, 25524.2469999999, 24951.481, 34183.878, 37728.0175,
48010.01, 44755.596, 48046.356, 60104.931, 54418.6015, 37435.019,
64601.3079999999, 47246.4585, 61987.7755, 69326.731, 62304.4115,
53449.3399999999, 53437.4199999999, 55794.946, 68453.62,
47811.165, 68513.1679999999, 74041.6689999999, 28746.7845,
36246.73, 39189.0449999999, 35805.25, 48883.4844999999, 45351.89,
51977.1845, 54361.4, 55435.92, 48106.5175, 51940.6849999999,
53094.3600000001, 63513.4865, 59929.0134999999, 53139.8539999999,
58254.362, 54360.603, 59249.0440000001, 63612.2044999999,
66954.895, 60910.28, 56237.05, 57178.5909999997, 60968.39
), yy = c(4551.10238709677, 3337.98638709677, 5493.43058064516,
6092.89220779221, 6200.23681818182, 7618.28039473684, 7724.1440397351,
7773.62516778524, 8370.17382550336, 9662.57210884354, 10685.8747222222,
8006.27307692308, 9465.91507042254, 9798.04366197183, 10589.8792142857,
11966.4210869565, 10929.867173913, 10249.8120437956, 11350.3767153285,
11389.0071428571, 11460.8877099237, 25611.2023076923, 12201.0593076923,
12520.087890625, 8221.18950793651, 10309.0262063492, 9699.0276031746,
9848.93274603175, 11287.6371428571, 12661.5044178628, 12017.5153225806,
13292.703095624, 13974.0070607553, 12037.6256105611, 13703.6894859038,
13536.1771285476, 14665.8368855219, 15646.843125, 14033.6686495726,
14743.2014188034, 13643.2409948542, 14126.7188773748, 15954.5895789474,
14838.0072614841, 15773.8243493761, 16819.1530755396, 13888.5933272727,
14795.7577614679)), .Names = c("varC", "xx", "Born_Inf",
"Born_Sup", "yy"), row.names = c(NA, 48L), class = "data.frame")