# Candlestick charts using quandl and plotly example not working (OS X and Ubuntu)

**URL:** <https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534>\
**Category:** Plotly R\
**Created:** [October 27, 2016, 4:13am UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534 "2016-10-27T04:13:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shevkoplyas](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/shevkoplyas/32/686_2.png) [@shevkoplyas](https://community.plotly.com/u/shevkoplyas)\
**Post date:** [October 27, 2016, 4:13am UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/1 "2016-10-27T04:13:27Z")

</div>

hi! I’ve tried [http://moderndata.plot.ly/candlestick-charts-using-quandl-and-plotly/](http://moderndata.plot.ly/candlestick-charts-using-quandl-and-plotly/) in RStudio on my Mac and on remote Ubuntu box and it failed in both cases. Steps to reproduce:

**On Mac:**

R version 3.3.1 (2016-06-21) – “Bug in Your Hair”  
Copyright (C) 2016 The R Foundation for Statistical Computing  
Platform: x86\_64-apple-darwin13.4.0 (64-bit)

RStudio: Version 0.99.903  
Quandl: 2.8.0

When run the example  
Error: could not find function “%\>%”

Then after adding obviously missing line (which was the reason of %\>% operator errror):

> library(plotly)

It gave me a warning that “layout” object is now “masked”:

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/2eb42b1354d78e0a4ac299e9bca48ea048079074.png)

> Warning message:  
> ‘layout’ objects don’t have these attributes: ‘color’  
> Valid attributes include:  
> ‘font’, ‘title’, ‘titlefont’, ‘autosize’, ‘width’, ‘height’, ‘margin’, ‘paper\_bgcolor’, ‘plot\_bgcolor’, ‘separators’, ‘hidesources’, ‘smith’, ‘showlegend’, ‘dragmode’, ‘hovermode’, ‘xaxis’, ‘yaxis’, ‘scene’, ‘geo’, ‘legend’, ‘annotations’, ‘shapes’, ‘images’, ‘updatemenus’, ‘ternary’, ‘mapbox’, ‘radialaxis’, ‘angularaxis’, ‘direction’, ‘orientation’, ‘barmode’, ‘bargap’, ‘mapType’

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/4b5aa2bf9681a4b631dc0be5d9cc44cd77bc1a93.png)

so something is already messed up, but lets try to comment the line which tries to set ‘color’ attribute (line 26):

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/d643586a3b1f9fd1c22b292877d79dc40b8a3d67.png)

and try to run it again:  
[can not add more screenshots - new users limit: 3 screenshots, 2 links]  
this time it finishes with no warnings / errors / any charts

please help to run your example.

Also: “this older post” mentioned in the article and available by this link:  
[http://moderndata.plot.ly/candlestick-charts-using-plotly-and-quantmod/](http://moderndata.plot.ly/candlestick-charts-using-plotly-and-quantmod/)  
also does not work. The error I get is:

> library(plotly)  
> library(quantmod)  
> Loading required package: TTR  
> Version 0.4-0 included new data defaults. See ?getSymbols.  
> plotlyCandleStick(“TSLA”)  
> Error in plot\_ly(plot.base, x = x, y = y, mode = “lines”, marker = list(color = “#9b9797”), :  
> object ‘y’ not found

this is I guess has something to do with known issue reported to plotly:  
[basic plotting naming convention (non-tilde ~) broken?

> <https://github.com/plotly/plotly.R/issues/765>
>
> From the plotly reference:
> 
> plot\_ly(economics, type = "scatter", x = date, y = u…empmed, name = "unemployment", marker = list(color="rgb(16, 32, 77)" ,marker-color))
> 
> results in this error:
> 
> Error in plot\_ly(economics, type = "scatter", x = date, y = uempmed, name = "unemployment", : 
> object 'uempmed' not found
> 
> plot\_ly(economics, type = "scatter", x = ~date, y = ~uempmed, name = "unemployment", marker = list(color="rgb(16, 32, 77)" ,marker-color))
> 
> Note the tilde in front of the x and y variable!!!
> This plots normally!!
> 
> This small difference breaks most of my plotting routines (if not all).
> 
> \--- version
> platform x86\_64-apple-darwin13.4.0  
> arch x86\_64  
> os darwin13.4.0  
> system x86\_64, darwin13.4.0  
> status  
> major 3  
> minor 3.1  
> year 2016  
> month 06  
> day 21  
> svn rev 70800  
> language R  
> version.string R version 3.3.1 (2016-06-21)
> nickname Bug in Your Hair

I tried to fix it, but then there were other errors.

Please help with running your quantmod and quantdl candlesticks charts examples - they look awesome on the screenshots!

cheers,  
Dmitry

---

<div class="post-metadata">

**Author:** ![royr2](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@royr2](https://community.plotly.com/u/royr2)\
**Post date:** [October 27, 2016, 7:07pm UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/2 "2016-10-27T19:07:44Z")

</div>

Seems to work for me. Yes the `color = "white"` argument is not needed anymore. But the chart populates fine. Which version of plotly are you using?

Ignore the older post. It has bugs.

---

<div class="post-metadata">

**Author:** ![shevkoplyas](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/shevkoplyas/32/686_2.png) [@shevkoplyas](https://community.plotly.com/u/shevkoplyas)\
**Post date:** [October 27, 2016, 10:23pm UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/3 "2016-10-27T22:23:58Z")

</div>

I’ve replied by email 2 hours ago, but don’t see my response on this thread yet, so I’ll copy-paste my email response here (via browser / forum) (are my replies moderated and I just need to be a bit more patient OR my email response was just silently dropped?)

```
thank you for quick response!
My RStudio claims (on 'Packages' tab) it uses: plotly 4.5.2
```

---

<div class="post-metadata">

**Author:** ![royr2](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@royr2](https://community.plotly.com/u/royr2)\
**Post date:** [October 28, 2016, 7:52am UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/4 "2016-10-28T07:52:36Z")

</div>

Could you try with the more recent version on github? `4.5.5`?

---

<div class="post-metadata">

**Author:** ![shevkoplyas](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/shevkoplyas/32/686_2.png) [@shevkoplyas](https://community.plotly.com/u/shevkoplyas)\
**Post date:** [October 28, 2016, 1:51pm UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/5 "2016-10-28T13:51:13Z")

</div>

**Short answer:**  
yes, your example works fine with plotly 4.5.5 installed from GitHub.  
The “installed by default” plotly v. 4.5.2 does not work.  
Thanks!  
Dmitry

* * *

**A bit longer answer:**

**# just reinstalling plotly to double check which version I would end up with (answer: still brings plotly v. 4.5.2):**

> remove.packages(“plotly”)  
> Removing package from ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’  
> (as ‘lib’ is unspecified)  
> install.packages(“plotly”)  
> trying URL ‘[https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/plotly\_4.5.2.tgz](https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/plotly_4.5.2.tgz)’  
> Content type ‘application/x-gzip’ length 806762 bytes (787 KB)  
> ==================================================  
> downloaded 787 KB

**# Installing plotly from github**

# uninstall plottly

remove.packages(“plotly”)

# install package “devtools”, so we can install latest plotly from github

install.packages(“devtools”)  
library(devtools)

# install plotly package from github

install\_github(“ropensci/plotly”)

# surprisingly installation went well, but no “plotly” package listed under “Packages” tab:

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/249ccfbeb5432110a3b4d43f67a8119d0a237dd9.jpg)

**# but RStudio seems able to load (and autocomplete works for package name plotly):**

> library(plotly)  
> Loading required package: ggplot2  
> Attaching package: ‘plotly’  
> The following object is masked from ‘package:ggplot2’:  
> last\_plot  
> The following object is masked from ‘package:stats’:  
> filter  
> The following object is masked from ‘package:graphics’:  
> layout

**# and even though not listed among “Packages” tab, we can see it is actually loaded:**

> (.packages())  
> [1] “Quandl” “xts” “zoo” “plotly” “ggplot2” “devtools”  
> [7] “stats” “graphics” “grDevices” “utils” “datasets” “methods”  
> [13] “base”

**# funny that the installation and loading the plotly from github didn’t mention the version anywhere!**

> install\_github(“ropensci/plotly”)  
> Downloading GitHub repo ropensci/plotly@master  
> from URL h\_t\_tps://api.github.com/repos/ropensci/plotly/zipball/master  
> Installing plotly  
> Downloading GitHub repo hadley/ggplot2@master  
> from URL h\_t\_tps://api.github.com/repos/hadley/ggplot2/zipball/master  
> Installing ggplot2  
> trying URL ‘h\_t\_tps://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/reshape2\_1.4.2.tgz’  
> Content type ‘application/x-gzip’ length 202343 bytes (197 KB)  
> ==================================================  
> downloaded 197 KB

Installing reshape2  
‘/Library/Frameworks/R.framework/Resources/bin/R’ --no-site-file   
–no-environ --no-save --no-restore --quiet CMD INSTALL   
‘/private/var/folders/jc/2zmsbd7j1cq70jh78dknch6m0000gs/T/RtmpbBRQ88/devtools42ab445b4dd7/reshape2’   
–library=‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’   
–install-tests

- installing _binary_ package ‘reshape2’ …

- DONE (reshape2)  
Downloading GitHub repo hadley/scales@master  
from URL h\_t\_tps://api.github.com/repos/hadley/scales/zipball/master  
Installing scales  
‘/Library/Frameworks/R.framework/Resources/bin/R’ --no-site-file   
–no-environ --no-save --no-restore --quiet CMD INSTALL   
‘/private/var/folders/jc/2zmsbd7j1cq70jh78dknch6m0000gs/T/RtmpbBRQ88/devtools42ab2194467c/hadley-scales-d58d83a’   
–library=‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’   
–install-tests

- installing _source_ package ‘scales’ …  
\*\* libs  
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include" -fPIC -Wall -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o  
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include" -fPIC -Wall -mtune=core2 -g -O2 -c colors.cpp -o colors.o  
clang++ -dynamiclib -Wl,-headerpad\_max\_install\_names -undefined dynamic\_lookup -single\_module -multiply\_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o scales.so RcppExports.o colors.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation  
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/scales/libs  
\*\* R  
\*\* tests  
\*\* preparing package for lazy loading  
\*\* help  
Loading required package: scales  
\*\*\* installing help indices  
\*\* building package indices  
\*\* testing if installed package can be loaded

- DONE (scales)  
‘/Library/Frameworks/R.framework/Resources/bin/R’ --no-site-file   
–no-environ --no-save --no-restore --quiet CMD INSTALL   
‘/private/var/folders/jc/2zmsbd7j1cq70jh78dknch6m0000gs/T/RtmpbBRQ88/devtools42ab614edf51/hadley-ggplot2-cd6a691’   
–library=‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’   
–install-tests

- installing _source_ package ‘ggplot2’ …  
\*\* R  
\*\* data  
\*\*\* moving datasets to lazyload DB  
\*\* inst  
\*\* tests  
\*\* preparing package for lazy loading  
\*\* help  
\*\*\* installing help indices  
\*\* building package indices  
\*\* installing vignettes  
\*\* testing if installed package can be loaded

- DONE (ggplot2)  
‘/Library/Frameworks/R.framework/Resources/bin/R’ --no-site-file   
–no-environ --no-save --no-restore --quiet CMD INSTALL   
‘/private/var/folders/jc/2zmsbd7j1cq70jh78dknch6m0000gs/T/RtmpbBRQ88/devtools42ab7b44c95c/ropensci-plotly-32020c2’   
–library=‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’   
–install-tests

- installing _source_ package ‘plotly’ …  
\*\* R  
\*\* data  
\*\*\* moving datasets to lazyload DB  
\*\* inst  
\*\* tests  
\*\* preparing package for lazy loading  
\*\* help  
\*\*\* installing help indices  
\*\* building package indices  
\*\* testing if installed package can be loaded

- DONE (plotly)

> library(plotly)  
> Loading required package: ggplot2

Attaching package: ‘plotly’  
The following object is masked from ‘package:ggplot2’:  
last\_plot  
The following object is masked from ‘package:stats’:  
filter  
The following object is masked from ‘package:graphics’:  
layout

> 

**# the only way (I found) to see the version of loaded plotly (which happen to be 4.5.5.9000):**

> sessionInfo()  
> attached base packages:  
> [1] stats graphics grDevices utils datasets methods base

other attached packages:  
[1] Quandl\_2.8.0 xts\_0.9-7 zoo\_1.7-13  
[4] plotly\_4.5.5.9000 ggplot2\_2.1.0.9001 devtools\_1.12.0

loaded via a namespace (and not attached):  
[1] Rcpp\_0.12.7 knitr\_1.14 magrittr\_1.5 munsell\_0.4.3  
[5] lattice\_0.20-33 viridisLite\_0.1.3 colorspace\_1.2-7 R6\_2.2.0  
[9] httr\_1.2.1 plyr\_1.8.4 dplyr\_0.5.0 tools\_3.3.1  
[13] grid\_3.3.1 gtable\_0.2.0 DBI\_0.5-1 git2r\_0.15.0  
[17] withr\_1.0.2 htmltools\_0.3.5 yaml\_2.1.13 lazyeval\_0.2.0  
[21] digest\_0.6.10 assertthat\_0.1 tibble\_1.2 tidyr\_0.6.0  
[25] purrr\_0.2.2 base64enc\_0.1-3 htmlwidgets\_0.7 curl\_2.1  
[29] memoise\_1.0.0 scales\_0.4.0.9003 jsonlite\_1.1

# trying your example [Blog](http://moderndata.plot.ly/candlestick-charts-using-quandl-and-plotly/)

# (I’ll paste code here for completeness)

> library(Quandl)  
> library(plotly)  
> df ← Quandl(“WIKI/AAPL”)  
> df ← df[,c(1, 9:12)]
> 
> names(df) ← c(“Date”, “Open”, “High”, “Low”, “Close”)  
> df$Date ← as.Date(df$Date)
> 
> df ← df[1:1000,]
> 
> hovertxt ← Map(function(x, y)paste0(x, “:”, y), names(df), df)  
> hovertxt ← Reduce(function(x, y)paste0(x, “\<br\>”, y), hovertxt)
> 
> plot\_ly(df, x = ~Date, xend = ~Date, hoverinfo = “none”,  
> color = ~Close \> Open, colors = c(“#00b386”,“#ff6666”)) %\>%
> 
> add\_segments(y = ~Low, yend = ~High, line = list(width = 1, color = “black”)) %\>%
> 
> add\_segments(y = ~Open, yend = ~Close, line = list(width = 3)) %\>%
> 
> add\_markers(y = ~(Low + High)/2, hoverinfo = “text”,  
> text = hovertxt, marker = list(color = “transparent”)) %\>%
> 
> layout(showlegend = FALSE,  
> yaxis = list(title = “Price”, domain = c(0, 0.9)),  
> annotations = list(  
> list(xref = “paper”, yref = “paper”,  
> x = 0, y = 1, showarrow = F,  
> xanchor = “left”, yanchor = “top”,  
> align = “left”,  
> text = paste0(“ **AAPL** ”)),
> 
> ```
> list(xref = "paper", yref = "paper", 
> x = 0.75, y = 1, showarrow = F, 
> xanchor = "left", yanchor = "top",
> align = "left",
> text = paste(range(df$Date), collapse = " : "),
> font = list(size = 8))),
> plot_bgcolor = "#f2f2f2")
> 
> ```

**# worked this time!**

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/d7562426aaf931d5509c5a4a66880a1e5d938116.jpg)

Thanks!

---

<div class="post-metadata">

**Author:** ![shevkoplyas](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/shevkoplyas/32/686_2.png) [@shevkoplyas](https://community.plotly.com/u/shevkoplyas)\
**Post date:** [October 27, 2016, 7:33pm UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/6 "2016-10-27T19:33:37Z")

</div>

thank you for quick response!  
My RStudio claims (on ‘Packages’ tab) it uses: plotly 4.5.2

---

<div class="post-metadata">

**Author:** ![royr2](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@royr2](https://community.plotly.com/u/royr2)\
**Post date:** [October 28, 2016, 3:46pm UTC](https://community.plotly.com/t/candlestick-charts-using-quandl-and-plotly-example-not-working-os-x-and-ubuntu/2534/7 "2016-10-28T15:46:21Z")

</div>

Great ! good to know the example worked. You can also use `packageVersion("plotly")` to check the version of a specific package.
