|
| 1 | +--- |
| 2 | +title: "Bugged plotly figure: phantom subfigure" |
| 3 | +_quarto: |
| 4 | + tests: |
| 5 | + html: |
| 6 | + ensureHtmlElements: |
| 7 | + - |
| 8 | + - 'figure.quarto-float-fig div#fig-gapminder-1 figure.quarto-subfloat-fig div.plotly-graph-div' |
| 9 | + - 'figure.quarto-float-fig div#fig-gapminder-2 figure.quarto-subfloat-fig div.plotly-graph-div' |
| 10 | + ensureHtmlElementContents: |
| 11 | + selectors: |
| 12 | + - 'div#fig-gapminder-1 figcaption.quarto-subfloat-caption' |
| 13 | + - 'div#fig-gapminder-2 figcaption.quarto-subfloat-caption' |
| 14 | + matches: ['\((a|b)\) Gapminder: (1957|2007)'] |
| 15 | + ensureHtmlElementCount: |
| 16 | + selectors: ['figure.quarto-float-fig figure.quarto-subfloat-fig'] |
| 17 | + counts: [2] |
| 18 | + dashboard: |
| 19 | + ensureHtmlElements: |
| 20 | + - |
| 21 | + - 'figure.quarto-float-fig div#fig-gapminder-1 figure.quarto-subfloat-fig div.plotly-graph-div' |
| 22 | + - 'figure.quarto-float-fig div#fig-gapminder-2 figure.quarto-subfloat-fig div.plotly-graph-div' |
| 23 | + ensureHtmlElementContents: |
| 24 | + selectors: |
| 25 | + - 'div#fig-gapminder-1 figcaption.quarto-subfloat-caption' |
| 26 | + - 'div#fig-gapminder-2 figcaption.quarto-subfloat-caption' |
| 27 | + matches: ['\((a|b)\) Gapminder: (1957|2007)'] |
| 28 | + ensureHtmlElementCount: |
| 29 | + selectors: ['figure.quarto-float-fig figure.quarto-subfloat-fig'] |
| 30 | + counts: [2] |
| 31 | +--- |
| 32 | + |
| 33 | +```{python} |
| 34 | +#| label: fig-gapminder |
| 35 | +#| fig-cap: "Life Expectancy and GDP" |
| 36 | +#| fig-subcap: |
| 37 | +#| - "Gapminder: 1957" |
| 38 | +#| - "Gapminder: 2007" |
| 39 | +#| layout-ncol: 2 |
| 40 | +#| column: page |
| 41 | +
|
| 42 | +import plotly.express as px |
| 43 | +import plotly.io as pio |
| 44 | +gapminder = px.data.gapminder() |
| 45 | +def gapminder_plot(year): |
| 46 | + gapminderYear = gapminder.query("year == " + |
| 47 | + str(year)) |
| 48 | + fig = px.scatter(gapminderYear, |
| 49 | + x="gdpPercap", y="lifeExp", |
| 50 | + size="pop", size_max=60, |
| 51 | + hover_name="country") |
| 52 | + fig.show() |
| 53 | + |
| 54 | +gapminder_plot(1957) |
| 55 | +gapminder_plot(2007) |
| 56 | +``` |
0 commit comments