Skip to content

Commit

Permalink
pdf vs html build 3d images
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorcampbell committed Dec 28, 2023
1 parent 73d4301 commit 744c8f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion source/classification1.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kernelspec:
:tags: [remove-cell]
from chapter_preamble import *
from IPython.display import HTML
from IPython.display import Image
from sklearn.metrics.pairwise import euclidean_distances
import numpy as np
import plotly.express as px
Expand Down Expand Up @@ -860,7 +861,11 @@ for neighbor_df in neighbor_df_list:
# tight layout
fig.update_layout(margin=dict(l=0, r=0, b=0, t=1), template="plotly_white")
glue("fig:05-more", fig)
# if HTML, use the plotly 3d image; if PDF, use static image
if "BOOK_BUILD_TYPE" in os.environ and os.environ["BOOK_BUILD_TYPE"] == "PDF":
glue("fig:05-more", Image("img/classification1/plot3d_knn_classification.png"))
else:
glue("fig:05-more", fig)
```

```{figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Expand Down
7 changes: 6 additions & 1 deletion source/regression1.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kernelspec:
from chapter_preamble import *
from IPython.display import HTML
from IPython.display import Image
import plotly.express as px
import plotly.graph_objects as go
```
Expand Down Expand Up @@ -1148,7 +1149,11 @@ fig.update_layout(
template="plotly_white",
)
glue("fig:07-knn-mult-viz", fig)
# if HTML, use the plotly 3d image; if PDF, use static image
if "BOOK_BUILD_TYPE" in os.environ and os.environ["BOOK_BUILD_TYPE"] == "PDF":
glue("fig:07-knn-mult-viz", Image("img/regression1/plot3d_knn_regression.png"))
else:
glue("fig:07-knn-mult-viz", fig)
```

```{figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Expand Down
7 changes: 6 additions & 1 deletion source/regression2.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kernelspec:
from chapter_preamble import *
from IPython.display import HTML
from IPython.display import Image
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
Expand Down Expand Up @@ -827,7 +828,11 @@ fig.update_layout(
template="plotly_white",
)
glue("fig:08-3DlinReg", fig)
# if HTML, use the plotly 3d image; if PDF, use static image
if "BOOK_BUILD_TYPE" in os.environ and os.environ["BOOK_BUILD_TYPE"] == "PDF":
glue("fig:08-3DlinReg", Image("img/regression2/plot3d_linear_regression.png"))
else:
glue("fig:08-3DlinReg", fig)
```

```{figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Expand Down

0 comments on commit 744c8f3

Please sign in to comment.