alan-turing-institute / rds-course

Materials for Turing's Research Data Science course
https://alan-turing-institute.github.io/rds-course/
31 stars 13 forks source link

Graphviz figures in 4.1 not loading correctly #109

Closed callummole closed 1 year ago

callummole commented 2 years ago

In 4.1 we have two figures produced by graphviz. In the online jupyterbook the figures render oversized and cropped:

e.g.

Figure 1

Screenshot 2021-11-24 at 07 51 30

Figure 2

Screenshot 2021-11-24 at 07 51 39

Locally, they build like:

Screenshot 2021-11-24 at 07 54 09 Screenshot 2021-11-24 at 07 54 18

The issue persists in the following cases:

1) the figures as the cell output, with a size attribute being applied through graphviz 2) the figures as saved files, and loaded into the notebook using the image or figure directives. It seems that resizing doesn't change the ultimate output. e.g.

```{figure} ../../figures/4.1_1.svg
---
height: 150px
name: dataprocess
---


Ideas to try:
- [ ] different file formats (though graphviz doesn't save to certain outputs with a high resolution, e.g. `png`). 
- [ ] raw html instead of myst directives (though this means the nice formatting isn't preserved when the window width changes).

the difficulty with problem solving this issue is that it only crops up on the online version so I've been committing and pushing develop to get the book to build hoping for a quick fix. If we are going to need to delve deeper we might want to temporarily change the book build to a different branch specific for this issue.

It's not a deal breaker for afternoon's teaching (24/11/21), because the instructors can present with their local copies of the book.
AoifeHughes commented 1 year ago

Jupyter seems to render this fine for me if you end blocks with a call to the graphviz object rather than asking graphviz to render. (another alternative might be to call ipy Image to display).

Example of working: here