I am trying to display anything other than straight zeros on my secondary Y-axis using plotly
with the data given in the R Markdown code below:
---
title: "Test Stack Overflow Trending"
author: ""
date: ""
output:
html_document:
self_contained: no
---
```{r plot1, results='asis', tidy=FALSE, echo=FALSE, fig.retina=NULL, message=FALSE, out.width = "92%", out.height="450px"}
require(plotly)
require(data.table)
mydt <- data.table(NAME = "Overall", Val = c(391234, 518834, 489567),perc = c(0.24,0.25,0.24), mytdate=c("2015-09-01","2015-10-01","2015-11-01"))
mydt$mydate <- as.Date(mydt$mytdate,"%Y-%m-%d")
p1 <- mydt %>%
plot_ly(x = mydate, y = Val,type = "scatter", mode = "markers") %>%
add_trace(x = mydate, y = perc, yaxis = "y2", mode="lines+markers") %>%
layout(showlegend = F, xaxis=list(title=""),yaxis=list(title=""),yaxis2 = list(side="right",overlay="y", ticks="inside",tickformat = ":04,2f"))
p1
```
I am using R 3.1.3 64-bit on a Windows 7 64-bit operating system. I am using the plotly package version: 2.0.16 (downloaded from Github in mid December of 2015).
Here is the image I am getting using Google Chrome, version: 47.0.2526.111 attached below. Notice that my right hand axis shows constant zeros. I want it to display something like 0.21, 0.22, 0.23, 0.24. I know there has to be a way to change this with the tickformat option, but I still have yet to figure it out. Output seen in Google Chrome