plotly / plotly.R

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

Plotly Subplot Function Issue #1934

Open Wanda-Sankey opened 3 years ago

Wanda-Sankey commented 3 years ago

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form, but instead ask on the community forum http://community.plot.ly/c/api/r or stackoverflow http://stackoverflow.com.

Please include a minimal reprex. The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it. If you've never heard of a reprex before, start by reading https://github.com/tidyverse/reprex#readme, and follow the advice further down the page. Do NOT include session info unless it's explicitly asked for, or you've used reprex::reprex(..., si = TRUE) to hide it away.

Delete these instructions once you have read them.


I am trying to plot two plotly images side by side using the tutorial laid out here. However, I keep getting this error:

Warning messages:
1: No source found 
2: No config found 
3: 'layout' objects don't have these attributes: 'NA'
Valid attributes include:
'font', 'title', 'uniformtext', 'autosize', 'width', 'height', 'margin', 'paper_bgcolor', 'plot_bgcolor', 'separators', 'hidesources', 'showlegend', 'colorway', 'datarevision', 'uirevision', 'editrevision', 'selectionrevision', 'template', 'modebar', 'meta', 'transition', '_deprecated', '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', 'colorscale', 'coloraxis', 'metasrc', 'barmode', 'bargap', 'mapType'

My plotly objects are defined in the same way as follows:

  log10_plot <- plot_ly(data=log10numi_frame,x=log10numi_frame$`Log10 Cell Index`,y=log10numi_frame$`Log10 nUMI`, type="scatter", mode = "lines", name=paste0(sample," nUMI"), line=list(color="#000000")) %>% layout(autosize = F, width = 700, height = 350, xaxis = list(title = "Cells in decreasing order by genic UMI count"), yaxis= list(title = "Log10(Genic UMI count)"))
  if(! is.na(kneedle_cumfrac_knee)){
    log10_plot <- add_segments(log10_plot,x=kneedle_cumfrac_knee, xend =kneedle_cumfrac_knee, y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("Kneedle (Cumulative Fraction) Knee (",round(kneedle_cumfrac_knee,digits=1),")"), text = "Kneedle (Cumulative Fraction) Knee", line=list(color="#E69F00"))
  }
  if(! is.na(kneedle_log10_knee)){
    log10_plot <- add_segments(log10_plot,x=kneedle_log10_knee, xend = kneedle_log10_knee,y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("Kneedle (Log10) Knee (",round(kneedle_log10_knee,digits=1),")"), text = "Kneedle (Log10) Knee", line=list(color="#56B4E9"))
  }
  if(! is.na(second_deriv_min_knee)){
    log10_plot <- add_segments(log10_plot, x=second_deriv_min_knee, xend = second_deriv_min_knee, y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("Second Derivative Knee (", round(second_deriv_min_knee,digits=1),")"), text = "Second Derivative Knee", line=list(color="#009E73"))
  }
  #if(! is.na(DropletUtils_knee)){
  #  log10_plot <- add_segments(log10_plot,x=DropletUtils_knee, xend = DropletUtils_knee,y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("DropletUtils Knee (",round(DropletUtils_knee,digits=1), ")"), text = "DropletUtils Knee")
  #}
  if(! is.na(DropletUtils_inflection)){
    log10_plot <- add_segments(log10_plot,x=DropletUtils_inflection, xend = DropletUtils_inflection,y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("DropletUtils (Inflection) Knee (",round(DropletUtils_inflection,digits=1),")"), text = "DropletUtils (Inflection) Knee", line=list(color="#F0E442"))
  }
  if(! is.na(emptydrops_num_cells)){
    log10_plot <- add_segments(log10_plot,x=emptydrops_num_cells, xend = emptydrops_num_cells, y=min(log10numi_frame$`Log10 nUMI`), yend=max(log10numi_frame$`Log10 nUMI`), name=paste0("DropletUtils (EmptyDrops) Knee (",round(emptydrops_num_cells,digits=1),")"), text = "DropletUtils (EmptyDrops) Knee", line=list(color="#0072B2"))
  }

Currently I am calling this when I get the error:

subplot(log10_plot, cum_frac_plot)
alanocallaghan commented 2 years ago

You should really provide a reproducible example to make it easier to diagnose the issue