Skip to content

Commit

Permalink
improved resolution and automation of 3D plotly figures in pdf
Browse files Browse the repository at this point in the history
Closes #330
  • Loading branch information
ttimbers committed Oct 20, 2021
1 parent efc4fbe commit 0622fa0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build_html.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Script to generate HTML book
docker run --rm -m 5g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.15.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience; Rscript _build_html.r"
docker run --rm -m 5g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.16.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience; Rscript _build_html.r"
2 changes: 1 addition & 1 deletion build_pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cp -r data/ pdf/data
cp -r img/ pdf/img

# Build the book with bookdown
docker run --rm -m 5g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.15.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience/pdf; Rscript _build_pdf.r"
docker run --rm -m 5g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.16.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience/pdf; Rscript _build_pdf.r"

# clean files in pdf dir
rm -rf pdf/references.bib
Expand Down
6 changes: 5 additions & 1 deletion classification1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ knitr::opts_chunk$set(echo = TRUE,
options(knitr.table.format = function() {
if (knitr::is_latex_output()) 'latex' else 'pandoc'
})
reticulate::use_miniconda('r-reticulate')
```

## Overview
Expand Down Expand Up @@ -598,7 +599,7 @@ plot_3d <- scaled_cancer_3 |>
z = ~Symmetry,
color = ~Class,
opacity = 0.4,
size = 150,
size = 5,
colors = c("orange2", "steelblue2", "red"),
symbol = ~Class, symbols = c('circle','circle','diamond'))
Expand Down Expand Up @@ -637,6 +638,9 @@ plot_3d <- plot_3d %>%
if(!is_latex_output()){
plot_3d
} else {
scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
plot_3d <- plot_3d %>% layout(scene = scene)
save_image(plot_3d, "img/plot3d_knn_classification.png", scale = 10)
knitr::include_graphics("img/plot3d_knn_classification.png")
}
```
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
book-env:
image: ubcdsci/intro-to-ds:v0.12.0
image: ubcdsci/intro-to-ds:v0.16.0
ports:
- "8787:8787"
volumes:
Expand All @@ -10,5 +10,5 @@ services:
deploy:
resources:
limits:
memory: 4G
memory: 5G

4 changes: 4 additions & 0 deletions regression1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ library(knitr)
library(plotly)
knitr::opts_chunk$set(fig.align = "center")
reticulate::use_miniconda('r-reticulate')
```

## Overview
Expand Down Expand Up @@ -797,6 +798,9 @@ plot_3d <- plot_ly() |>
if(!is_latex_output()){
plot_3d
} else {
scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
plot_3d <- plot_3d %>% layout(scene = scene)
save_image(plot_3d, "img/plot3d_knn_regression.png", scale = 10)
knitr::include_graphics("img/plot3d_knn_regression.png")
}
```
Expand Down
4 changes: 4 additions & 0 deletions regression2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ library(knitr)
library(plotly)
knitr::opts_chunk$set(fig.align = "center")
reticulate::use_miniconda('r-reticulate')
```

## Overview
Expand Down Expand Up @@ -491,6 +492,9 @@ plot_3d <- plot_ly() |>
if(!is_latex_output()){
plot_3d
} else {
scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
plot_3d <- plot_3d %>% layout(scene = scene)
save_image(plot_3d, "img/plot3d_linear_regression.png", scale = 10)
knitr::include_graphics("img/plot3d_linear_regression.png")
}
```
Expand Down

0 comments on commit 0622fa0

Please sign in to comment.