8000 Plotlyjs1 54 docs update by jdamiba · Pull Request #51 · plotly/plotly.r-docs · GitHub
[go: up one dir, main page]

Skip to content

Plotlyjs1 54 docs update #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor rangebreaks example
  • Loading branch information
Joseph Damiba committed May 26, 2020
commit ec5a8ce1f6be0ef9860f2ba1938474d0bd174691
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: install application-level dependencies
command: |
sudo apt-get install -y pandoc libudunits2-dev libgdal-dev libxt-dev libglu1-mesa-dev libfftw3-dev
sudo R -e 'install.packages(c("plotly", "curl", "devtools", "mvtnorm")); devtools::install_github("hypertidy/anglr"); devtools::install_github("johannesbjork/LaCroixColoR"); install.packages("BiocManager"); BiocManager::install("EBImage"); devtools::install_deps(dependencies = TRUE) '
sudo R -e 'install.packages(c("curl", "devtools", "mvtnorm")); devtools::install_github("hypertidy/anglr"); devtools::install_github("ropensci/plotly"); devtools::install_github("johannesbjork/LaCroixColoR"); install.packages("BiocManager"); BiocManager::install("EBImage"); devtools::install_deps(dependencies = TRUE) '
- save_cache:
key: cache4
paths:
Expand Down
55 changes: 42 additions & 13 deletions r/2015-07-30-time-series.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,52 @@ fig
```

### Hiding Weekends and Holidays
The `rangebreaks` attribute available on x- and y-axes of type date can be used to hide certain time-periods. In the example below, we create a plot of the last ten days, excluding Saturdays, Sundays, yesterday, and the day before yesterday. Check out the reference for more options: https://plotly.com/r/reference/#layout-xaxis-rangebreaks
The `rangebreaks` attribute available on x- and y-axes of type date can be used to hide certain time-periods. In the example below, we show two plots: one in default mode to show gaps in the data, and one where we hide weekends and holidays to show an uninterrupted trading history. Note the smaller gaps between the grid lines for December 21 and January 4, where holidays were removed. Check out the reference for more options: https://plotly.com/r/reference/#layout-xaxis-rangebreaks


```{r}
library(plotly)
today <- Sys.Date()
yesterday = today - 1
day_before_yesterday = yesterday - 1
tm <- seq(0, 10, by = 1)
x <- today - tm
y <- rnorm(length(x))
fig <- plot_ly(x = ~x, y = ~y, mode = 'markers', text = paste(tm, "days from today"))
fig <- fig %>% layout(
xaxis = list(rangebreaks = list(
list(bounds=c("sat", "sun")),
list(values=c(yesterday,day_before_yesterday))
))
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig <- plot_ly(
type = "scatter",
x = as.Date(df$Date, format= "%Y-%m-%d"),
y = df$AAPL.High,
name = 'AAPL High',
mode = "markers",
)
fig <- fig %>%
layout(
title = "Time Series with Custom Date-Time Format",
xaxis = list(
type = "date",
range=c('2015-12-01', '2016-01-15')
)
)
fig
```

```{r}
library(plotly)
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig <- plot_ly(
type = "scatter",
x = as.Date(df$Date, format= "%Y-%m-%d"),
y = df$AAPL.High,
name = 'AAPL High',
mode = "markers",
)
fig <- fig %>%
layout(
title = "Time Series with Custom Date-Time Format",
xaxis = list(
type = "date",
range=c('2015-12-01', '2016-01-15'),
rangebreaks = list(
list(bounds=c("sat", "mon")),
list(values=c("2015-12-25", "2016-01-01"))
)
)
)
fig
```
### POSIXlt date time class with timezone
Expand Down
0