Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

use both barmode 'group' and 'stack' in R-plotly

$
0
0

consider the following code in R (not in python):

library(plotly)

Animals <- c("giraffes", "orangutans", "monkeys")

SF_Zoo <- c(20, 14, 23)
LA_Zoo <- c(12, 18, 29)

SF_Zoo2 <- c(24, 18, 29)
LA_Zoo2<- c(15, 22, 33)
data <- data.frame(Animals, SF_Zoo, LA_Zoo)
data2 <- data.frame(Animals, SF_Zoo, LA_Zoo)

 p1<-plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
  add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
  layout(yaxis = list(title = 'Count'), barmode = 'stack')
   ####
  p2<-plot_ly(data2, x = ~Animals, y = ~SF_Zoo2, type = 'bar', name = 'SF Zoo') %>%
   add_trace(y = ~LA_Zoo2, name = 'LA Zoo2') %>%
  # add_trace(y = ~LA_Zoo2, name = 'SF Zoo2') %>%
   layout(yaxis = list(title = 'Count'), barmode = 'stack')

subplot(p1,p2,shareX =T, which_layout = "merge")

Is there any possibility to have in subplot"group" as the layout? see related #1835


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>