plotly / plotly/plotly.R

geom_GeomDrawGrob() has yet to be implemented in plotly.

Ouverte
#1,935 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

PROBLEM DESCRIPTION

I want to use plotly::ggplotly() over a series of ggplot graphs that are grouped together using cowplot::plot_grid(). Essentially, this would create a sleek dashboard-like image within an R Markdown or Shiny application.

The intended ggplot class graph to be interacted with plotly::ggplotly() is the following:

Screen Shot 2021-03-26 at 10 56 14 AM

However, I ran into the following error message when trying this:

geom_GeomDrawGrob() has yet to be implemented in plotly.
  If you'd like to see this geom implemented,
  Please open an issue with your example code at
  https://github.com/ropensci/plotly/issuesgeom_GeomDrawGrob() has yet to be implemented in plotly.
  If you'd like to see this geom implemented,
  Please open an issue with your example code at
  https://github.com/ropensci/plotly/issues

Below is all the code necessary to construct the relevant dataframes and graphs to reproduce the above error message. The code is separated into three chunks. I also added two screenshots at the end of the outputs of the final two chunks of my notebook.


library(tidyverse)
library(cowplot)
library(plotly)

my_data1 <- structure(list(day = structure(c(18593, 18654, 18683, 18554, 
                                             18600, 18601, 18665, 18635, 18680, 18595, 18709, 18662, 18568, 
                                             18562, 18431, 18467, 18475, 18679, 18649, 18498, 18448, 18686, 
                                             18682, 18606, 18577, 18526, 18468, 18552, 18459, 18611, 18454, 
                                             18622, 18558, 18407, 18583, 18640, 18485, 18555, 18598, 18458, 
                                             18619, 18693, 18668, 18528, 18584, 18466, 18656, 18663, 18446, 
                                             18372, 18385, 18383, 18358, 18542, 18695, 18655, 18630, 18664, 
                                             18626, 18702, 18535, 18676, 18705, 18553, 18591, 18628, 18556, 
                                             18691, 18673, 18487, 18416, 18441, 18394, 18409, 18381, 18404, 
                                             18418, 18490, 18707, 18443, 18401, 18408, 18386, 18367, 18323, 
                                             18382, 18370, 18678, 18511, 18540, 18436, 18629, 18541, 18500, 
                                             18482, 18457, 18464, 18534, 18657, 18516, 18424, 18435, 18529, 
                                             18651, 18445, 18537, 18681, 18444, 18465, 18543, 18559, 18429, 
                                             18415, 18419, 18527, 18473, 18393, 18403, 18398, 18636, 18594, 
                                             18612, 18641, 18509, 18592, 18480, 18551, 18646, 18571, 18548, 
                                             18506, 18666, 18507, 18696, 18642, 18484, 18567, 18703, 18477, 
                                             18544, 18687, 18697, 18550, 18699, 18667, 18532, 18684, 18472, 
                                             18545, 18643, 18557, 18560, 18447, 18604, 18617, 18570, 18414, 
                                             18399, 18375, 18613, 18449, 18688, 18579, 18608, 18590, 18461, 
                                             18633, 18675, 18631, 18706, 18609, 18605, 18652, 18489, 18450, 
                                             18522, 18581, 18501, 18514, 18438, 18589, 18463, 18588, 18580, 
                                             18531, 18538, 18494, 18471, 18632, 18510, 18432, 18420, 18417, 
                                             18413, 18392, 18410, 18698, 18700, 18701, 18513, 18566, 18669, 
                                             18433, 18491, 18395, 18547, 18377, 18597, 18658, 18660, 18602, 
                                             18671, 18610, 18440, 18572, 18614, 18456, 18546, 18478, 18710, 
                                             18483, 18578, 18689, 18670, 18638, 18634, 18524, 18650, 18616, 
                                             18692, 18462, 18499, 18496, 18625, 18428, 18422, 18389, 18412, 
                                             18387, 18434, 18549, 18481, 18442, 18486, 18488, 18425, 18615, 
                                             18396, 18368, 18405, 18379, 18690, 18492, 18523, 18644, 18452, 
                                             18645, 18708, 18661, 18517, 18508, 18575, 18504, 18476, 18497, 
                                             18502, 18582, 18426, 18519, 18453, 18596, 18520, 18586, 18530, 
                                             18624, 18659, 18505, 18574, 18576, 18694, 18460, 18515, 18423, 
                                             18503, 18427, 18653, 18639, 18533, 18469, 18587, 18539, 18455, 
                                             18437, 18430, 18711, 18400, 18380, 18369, 18391, 18366, 18402, 
                                             18384, 18365, 18363, 18360, 18359, 18374, 18569, 18627, 18623, 
                                             18674, 18599, 18521, 18470, 18672, 18573, 18607, 18421, 18563, 
                                             18620, 18677, 18518, 18618, 18704, 18536, 18451, 18637, 18647, 
                                             18648, 18525, 18474, 18685, 18493, 18585, 18603, 18479, 18561, 
                                             18565, 18564, 18439, 18621, 18512, 18390, 18495, 18397, 18411, 
                                             18373, 18388, 18406, 18376), class = "Date")
                           , total_values2 = c(2564, 
                                               1676, 1586, 1034, 2646, 2554, 1503, 1755, 1552, 2462, 713, 1794, 
                                               1158, 982, 277, 705, 594, 1403, 1805, 524, 409, 1420, 1487, 2434, 
                                               1319, 855, 661, 898, 707, 2044, 598, 1311, 1028, 8, 1555, 1650, 
                                               618, 1012, 2613, 663, 1331, 1264, 1626, 929, 1650, 697, 1822, 
                                               1771, 565, 3, 3, 3, 1, 911, 1340, 1699, 1631, 1738, 1491, 1379, 
                                               907, 1411, 1462, 831, 1937, 1353, 978, 1574, 1373, 567, 59, 315, 
                                               5, 9, 3, 9, 88, 515, 932, 488, 7, 9, 6, 1, 1, 1, 1, 1451, 604, 
                                               956, 366, 1675, 933, 566, 579, 690, 684, 882, 1755, 722, 157, 
                                               311, 820, 1717, 561, 956, 1490, 517, 702, 915, 869, 224, 49, 
                                               62, 868, 736, 7, 6, 5, 1721, 2812, 2015, 1579, 684, 1579, 630, 
                                               1031, 1649, 1104, 989, 599, 1683, 639, 1294, 1787, 636, 849, 
                                               1635, 682, 986, 1638, 1304, 1004, 1333, 1704, 734, 1578, 672, 
                                               889, 1665, 1012, 894, 420, 2795, 1553, 960, 62, 6, 4, 2289, 680, 
                                               1521, 1503, 2391, 1892, 610, 1599, 1366, 1813, 1087, 2203, 2764, 
                                               1794, 566, 665, 764, 1459, 543, 635, 430, 1972, 721, 1734, 1335, 
                                               751, 824, 563, 718, 1712, 570, 296, 53, 72, 39, 2, 6, 1320, 1272, 
                                               1376, 741, 938, 1615, 269, 558, 7, 965, 3, 2951, 1729, 1808, 
                                               2474, 1477, 2381, 402, 1257, 1798, 729, 831, 685, 517, 555, 1319, 
                                               1460, 1598, 1725, 1607, 815, 1687, 1414, 1301, 574, 497, 507, 
                                               1376, 228, 96, 8, 28, 5, 234, 922, 639, 484, 582, 578, 185, 1606, 
                                               5, 1, 3, 1, 1464, 545, 840, 1623, 644, 1684, 952, 1686, 667, 
                                               614, 1332, 501, 624, 481, 567, 1622, 155, 763, 704, 2928, 752, 
                                               1784, 937, 1519, 1871, 654, 1161, 1373, 1433, 763, 730, 123, 
                                               507, 148, 1799, 1659, 930, 558, 1686, 841, 528, 379, 258, 174, 
                                               8, 3, 4, 2, 2, 4, 1, 1, 1, 2, 1, 1, 1078, 1503, 1277, 1413, 2812, 
                                               777, 730, 1408, 1157, 2612, 79, 953, 1295, 1583, 700, 1418, 1506, 
                                               944, 720, 1612, 1620, 1688, 805, 702, 1465, 532, 1656, 2725, 
                                               646, 1041, 1074, 944, 438, 1114, 578, 2, 552, 4, 11, 4, 7, 4, 4)
                           , total_values1 = c(3491, 2301, 2172, 1306, 3557, 3489, 2089, 
                                               2328, 2162, 3377, 925, 2449, 1569, 1260, 373, 958, 861, 2018, 
                                               2472, 668, 536, 1986, 2076, 3269, 1799, 1093, 873, 1168, 909, 
                                               2568, 775, 1710, 1281, 11, 2100, 2272, 793, 1293, 3465, 858, 
                                               1719, 1807, 2222, 1190, 2197, 889, 2557, 2461, 760, 3, 4, 3, 
                                               1, 1182, 1848, 2302, 2210, 2415, 1940, 1910, 1213, 1916, 2069, 
                                               1101, 2492, 1847, 1258, 2359, 1770, 759, 71, 445, 10, 9, 3, 10, 
                                               117, 681, 1238, 665, 7, 13, 9, 1, 1, 1, 1, 2059, 790, 1215, 452, 
                                               2208, 1213, 708, 751, 911, 883, 1143, 2436, 919, 202, 386, 1060, 
                                               2336, 678, 1256, 2029, 673, 900, 1190, 1189, 280, 50, 81, 1129, 
                                               981, 10, 8, 7, 2368, 3984, 2505, 2157, 885, 2039, 825, 1394, 
                                               2189, 1478, 1283, 764, 2313, 803, 1821, 2416, 802, 1143, 2376, 
                                               878, 1274, 2201, 1762, 1312, 1900, 2307, 979, 2199, 882, 1130, 
                                               2227, 1273, 1169, 559, 3686, 1959, 1227, 71, 9, 4, 3094, 908, 
                                               2062, 2096, 3245, 2440, 825, 2162, 1882, 2464, 1528, 2964, 3655, 
                                               2436, 729, 846, 1023, 1985, 674, 829, 533, 2536, 895, 2379, 1896, 
                                               1001, 1097, 701, 938, 2270, 719, 396, 81, 97, 45, 2, 7, 1809, 
                                               1833, 1839, 955, 1185, 2304, 354, 709, 9, 1258, 3, 3918, 2468, 
                                               2536, 3393, 2059, 3005, 529, 1794, 2366, 901, 1117, 923, 676, 
                                               729, 1771, 2004, 2215, 2318, 2138, 1112, 2408, 1919, 1839, 761, 
                                               612, 667, 1767, 280, 137, 10, 33, 6, 308, 1190, 837, 644, 737, 
                                               776, 243, 2071, 6, 1, 3, 1, 2012, 676, 1078, 2148, 824, 2272, 
                                               1265, 2329, 872, 774, 1727, 633, 860, 626, 710, 2124, 196, 991, 
                                               926, 3882, 1006, 2426, 1173, 1994, 2608, 804, 1616, 1850, 1979, 
                                               977, 921, 155, 648, 183, 2503, 2196, 1181, 734, 2353, 1139, 692, 
                                               477, 327, 211, 11, 3, 4, 2, 2, 4, 1, 1, 1, 2, 1, 1, 1413, 1996, 
                                               1721, 1901, 3677, 1053, 953, 1915, 1673, 3440, 105, 1244, 1666, 
                                               2188, 892, 1826, 2120, 1252, 959, 2239, 2222, 2256, 1064, 950, 
                                               2111, 684, 2204, 3554, 815, 1332, 1456, 1200, 571, 1483, 755, 
                                               2, 692, 4, 14, 4, 10, 4, 4))
                      , row.names = c(NA, -350L), class = "data.frame")

my_data2 <- structure(list(month = c("2020-03", "2020-04", "2020-05", "2020-06", "2020-07", "2020-08", "2020-09", "2020-10", "2020-11", "2020-12", "2021-01", "2021-02", "2021-03")
                           , total_values1 = c(1, 42, 283, 8809, 26114, 22968, 29367, 38217, 65061, 82621, 71126, 60691, 43393)
                           , total_values2 = c(1, 42, 229, 6787, 20033, 17793, 22612, 29385, 48197, 62709, 52290, 43860, 31251), total_values2_claims = c(14, 97, 216, 183, 257, 240, 290, 471, 457, 1628, 680, 439, 298)
                           , total_values3 = c(16, 97, 225, 192, 259, 255, 305, 483, 481, 1744, 706, 458, 312))
                      , row.names = c(NA, -13L), class = c("tbl_df", "tbl", "data.frame"))


my_data3 <- structure(list(month = c("2020-03", "2020-04", "2020-05", "2020-06", "2020-07", "2020-08", "2020-09", "2020-10", "2020-11", "2020-12", "2021-01", "2021-02", "2021-03")
                           , total_values1 = c(1, 42, 283, 809, 26114, 22968, 29367, 38217, 65061, 82621, 71126, 60691, 43393)
                           , total_values2 = c(1, 42, 229, 6787, 20033, 17793, 22612, 29385, 48197, 62709, 52290, 43860, 31251))
                      , row.names = c(NA, -13L)
                      , class = c("tbl_df", "tbl", "data.frame"))

graph1 <- my_data1 %>%
  ggplot() +
  geom_line(aes(x=day,y=total_values1)) +
  geom_point(aes(x=day,y=total_values1)) +
  theme_bw() +
  ylab('') +
  xlab('') +
  ggtitle('Graph 1')

graph2 <- my_data2 %>%
  ggplot() +
  geom_line(aes(x=month,y=total_values3,group=1),linetype='dotted') +
  geom_point(aes(x=month,y=total_values3)) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=.5)) +
  ylab('') +
  xlab('') +
  ggtitle('Graph 2')

graph3 <- my_data3 %>%
  ggplot() +
  geom_line(aes(x=month,y=total_values1,group=1, colour='black')) +
  geom_point(aes(x=month,y=total_values1)) +
  geom_line(aes(x=month,y=total_values2,group=1, colour='grey'), linetype='dashed') +
  geom_point(aes(x=month,y=total_values2)) +
  scale_color_discrete(name = "Legend", labels = c("total_values1", "total_values2")) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=.5)) +
  ylab('') +
  xlab('') +
  ggtitle('Graph 3')

top_row <- cowplot::plot_grid(graph1, graph2
                     , align = "h")

final_graph <- cowplot::plot_grid(top_row, graph3
                                  , ncol = 1)
final_graph

Screen Shot 2021-03-26 at 10 56 14 AM

ggplotly(final_graph)

Screen Shot 2021-03-26 at 10 58 16 AM

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par l’exemple fourni de cowplot::plot_grid() et le point d’entrée plotly::ggplotly(), puis suivez le chemin du geom non pris en charge geom_GeomDrawGrob(). C’est terminé lorsque le graphique regroupé peut être transmis à ggplotly() sans cette erreur et reste interactif.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.