plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.53k stars 622 forks source link

pies and subplot not working as expected #655

Open timelyportfolio opened 8 years ago

timelyportfolio commented 8 years ago

Based on this StackOverflow post, it seems pie charts are not working as I would expect with subplot. I will admit though that this is my first ever attempt at pie charts in Plotly. I did verify by inspecting DOM that both pies do exist in the examples below.

    # devtools::install_github('ropensci/plotly")

    library(plotly)
    ds_r <- data.frame(labels1 = c("Baseline", "DTC", "Detailing", "Flex"),
                       values1 = c(63.5, 8.5, 20.6, 7.4))

    ds_l <- data.frame(labels2 = c("Baseline"),
                       values2 = c(100))

    p <- plot_ly(
      ds_r, labels = ~labels1, values = ~values1, type = "pie", 
      showlegend = F
    )

    p2 <- plot_ly(
      ds_l,labels = ~labels2, values = ~values2, type = "pie", 
      showlegend = F
    )

    subplot(p, p2, nrows = 1)

image

empty axes

    # devtools::install_github('ropensci/plotly")
    # an "empty" plotlyjs axis for layout
    emptyAxis <- list(
      title = "", 
      zeroline = FALSE,
      showline = FALSE, 
      showticklabels = FALSE, 
      showgrid = FALSE
    )

    p <- plot_ly(
      ds_r, labels = ~labels1, values = ~values1, type = "pie", 
      showlegend = F
    ) %>% layout(xaxis = emptyAxis, yaxis  = emptyAxis)

    p2 <- plot_ly(
      ds_l,labels = ~labels2, values = ~values2, type = "pie", 
      showlegend = F
    ) %>% layout(xaxis = emptyAxis, yaxis  = emptyAxis)

    subplot(p, p2, nrows = 1)

image

cpsievert commented 7 years ago

This is fixed in the dev version.

ghost commented 5 years ago

The example above still does not work for me (i.e provided the same plot as above). I also receive the following warning: Warning message: 'layout' objects don't have these attributes: 'NA' Valid attributes include: 'font', 'title', 'titlefont', 'autosize', 'width', 'height', 'margin', 'paper_bgcolor', 'plot_bgcolor', 'separators', 'hidesources', 'showlegend', 'colorway', 'datarevision', 'template', 'clickmode', 'dragmode', 'hovermode', 'hoverdistance', 'spikedistance', 'hoverlabel', 'selectdirection', 'grid', 'calendar', 'xaxis', 'yaxis', 'ternary', 'scene', 'geo', 'mapbox', 'polar', 'radialaxis', 'angularaxis', 'direction', 'orientation', 'editType', 'legend', 'annotations', 'shapes', 'images', 'updatemenus', 'sliders', 'barmode', 'bargap', 'mapType'

sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] bindrcpp_0.2.2 plotly_4.8.0.9000 ggplot2_3.0.0

loaded via a namespace (and not attached): [1] Rcpp_0.12.18 later_0.7.4 pillar_1.3.0 compiler_3.5.0 git2r_0.23.0
[6] plyr_1.8.4 bindr_0.1.1 tools_3.5.0 digest_0.6.17 viridisLite_0.3.0 [11] jsonlite_1.5 memoise_1.1.0 tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.2
[16] rlang_0.2.2 shiny_1.1.0 rstudioapi_0.7 crosstalk_1.0.0 curl_3.2
[21] yaml_2.2.0 stringr_1.3.1 withr_2.1.2 dplyr_0.7.6 httr_1.3.1
[26] htmlwidgets_1.3 devtools_1.13.6 grid_3.5.0 tidyselect_0.2.4 glue_1.3.0
[31] data.table_1.11.8 R6_2.2.2 reshape2_1.4.3 purrr_0.2.5 tidyr_0.8.1
[36] magrittr_1.5 promises_1.0.1 scales_1.0.0 htmltools_0.3.6 assertthat_0.2.0 [41] xtable_1.8-3 mime_0.5 colorspace_1.3-2 httpuv_1.4.5 labeling_0.3
[46] stringi_1.2.4 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4

cpsievert commented 5 years ago

Huh, yea, I must have been referring to the empty axes problem in that comment. I don't think pies have ever worked nicely with subplot()

millerh1 commented 2 years ago

Is there a roadmap to fixing this particular issue? I'm still getting this with 4.9.4.1. Thank you!