Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Iris example produces only axes, no plot

I am new to plotly, trying it out in R ( and sorry if this is not the right forum ). I tried the following simple code in RStudio console:

plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)

This produced just the axes with the labels, no data/plot. There was an error downloading the plot as png. The same problem with the following attempt:

plot_ly(x = ~rnorm(50), type = “histogram”)

RStudio version 1.0.44. What am I doing wrong?

sessionInfo()

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8

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

other attached packages:
[1] htmlwidgets_0.6 plotly_3.6.0 RSQLServer_0.2.099 readr_0.2.2 caret_6.0-70 ggplot2_2.1.0
[7] lattice_0.20-33 purrr_0.2.2 dplyr_0.5.0

loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 nloptr_1.0.4 plyr_1.8.4 viridis_0.3.4 base64enc_0.1-3
[6] iterators_1.0.8 tools_3.3.1 digest_0.6.9 lme4_1.1-12 evaluate_0.10
[11] jsonlite_0.9.22 tibble_1.2 nlme_3.1-128 gtable_0.2.0 mgcv_1.8-12
[16] Matrix_1.2-6 foreach_1.4.3 DBI_0.5-1 yaml_2.1.13 parallel_3.3.1
[21] SparseM_1.7 gridExtra_2.2.1 rJava_0.9-8 knitr_1.15.1 httr_1.2.0
[26] stringr_1.0.0 RevoUtils_10.0.1 MatrixModels_0.4-1 rprojroot_1.0-2 stats4_3.3.1
[31] grid_3.3.1 nnet_7.3-12 R6_2.1.2 rmarkdown_1.3 minqa_1.2.4
[36] tidyr_0.6.0 reshape2_1.4.1 car_2.1-2 magrittr_1.5 htmltools_0.3.5
[41] scales_0.4.0 codetools_0.2-14 MASS_7.3-45 splines_3.3.1 assertthat_0.1
[46] pbkrtest_0.4-6 colorspace_1.2-6 quantreg_5.26 RevoUtilsMath_10.0.0 stringi_1.1.1
[51] munsell_0.4.3

Thanks in advance!!

hey @loves_math,

The examples above are attempting to use formulas (~) which are implemented in Plotly 4.0 https://github.com/ropensci/plotly/blob/master/NEWS.md#400----13-june-2016. Instead you need to use plain expression (see link again) or upgrade to a newer version; the current cran release is 4.5.6

That did it! Thanks a lot! Removed the ~ and it worked!!