@@ -719,10 +719,39 @@ subplot(p, nrows = 9)
719719# https://plot.ly/r/subplots/
720720# ----------------------------------------------------------------------------
721721
722+ # ' Basic subplot
723+ library(plotly )
724+ subplot(
725+ plot_ly(economics , x = date , y = uempmed ),
726+ plot_ly(economics , x = date , y = unemploy ),
727+ margin = 0.05
728+ ) %> % layout(showlegend = FALSE )
729+
730+ # ' Sharing an axis
731+ subplot(
732+ plot_ly(economics , x = date , y = uempmed ),
733+ plot_ly(economics , x = date , y = unemploy ),
734+ margin = 0.03 ,
735+ nrows = 2 ,
736+ # fyi, share doesn't work (yet)
737+ share = " x"
738+ ) %> % layout(showlegend = FALSE )
739+
722740# ----------------------------------------------------------------------------
723741# https://plot.ly/r/multiple-axes/
724742# ----------------------------------------------------------------------------
725743
744+ library(plotly )
745+ ay <- list (
746+ tickfont = list (color = " red" ),
747+ overlaying = " y" ,
748+ side = " right"
749+ )
750+ plot_ly(x = 1 : 3 , y = 10 * (1 : 3 ), name = " slope of 10" ) %> %
751+ add_trace(x = 2 : 4 , y = 1 : 3 , name = " slope of 1" , yaxis = " y2" ) %> %
752+ layout(title = " Double Y Axis" , yaxis2 = ay )
753+
754+
726755# ----------------------------------------------------------------------------
727756# https://plot.ly/r/insets/
728757# ----------------------------------------------------------------------------
0 commit comments