Open sarinac opened 2 years ago
Thanks! I love the ideas!
I have no idea how hover things work, but we can add custom classes to the elements when generating them and we can also load custon css and even js content to the website (being careful on the maintenance burden we are assuming when doing this). The gallery_generator
is a bit messy, but we can go through it at some point so explain what is happening at each step and how does this integrate with the website generation with sphinx process (I have no idea how familiar you are with sphinx, if you already saw this clearly while reading the script ignore the comment).
My main concern with the hover is avoiding duplicating information as much as possible. In my opinion the example gallery is first and foremost a visual reference page, not a how-to use the plots. But it would be good to have better integration with the API docs (name/text based reference page) instead of showing only a link, not really sure how though
Most charts in the example gallery should default to figsize=[8, 6]
I think this can be part of the style used (in matplotlib, would have to look for options with bokeh whose plots generally overflow the screen). I think it would also be perfectly ok to have a specific examples style with things like this we might not want to add to the general packaged style.
Grouping charts by use case- are some sections I can think of but definitely open to other ideas.
I would use different groupings. Still not completely clear, but here are some ideas. Warning, I think it is perfectly fine to have some calls to the same arviz function in different groups, examples below.
plot_trace
and plot_forest
(when plotting the rhat and ess).Extra idea: How about adding extra pages to the example gallery that don't necessarily use an ArviZ plotting function directly? It might be interesting. For example we could add something like https://github.com/arviz-devs/arviz/discussions/2075 to the regression/timeseries section to showcase it.
Hey @OriolAbril - thanks for the feedback! I have some additional comments:
CSS in example gallery (for hover text) - I can make changes to CSS, and my preference would be to move it to an external CSS file.
gallery_generator
is creating this CSS internally in the HTML of the example gallery page. ArviZ already has a custom.css file (linked in conf.py(sphinx doc)) that we can add to. I would probably add a "example-gallery-" prefix to all the CSS classes (so they only affect the example gallery objects) and update the class names in the gallery_generator here.Resize images to fit in the thumbnail - I think I can accomplish this with CSS, and it'll remove some complexity from the gallery generator. I looked at matplotlib's example gallery, and they do not crop their images to be a square. I can do this at the same time after item 1 (move css externally) because it involves editing the HTML/CSS. That might mean we don't need the create_thumbnail
function inside the gallery_generator
because it scans through the matplotlib example py files and crops them. We can also remove the _thumb: .6, .5
-like settings inside the py files too.
From a developer standpoint, do you think it's better to have examples in mutually exclusive groupings or tags that can overlap? Both can reference the same ArviZ function multiple times. I'll also elaborate on these 2 options in case if I am describing this badly:
examples/model_checking/matplotlib/plot_trace.py
, examples/model_checking/bokek/plot_trace.py
, examples/mixed/matplotlib/plot_trace.py
, and examples/mixed/bokeh/plot_trace.py
if you want to show plot_trace
for some mixed
or model_checking
category. This does kind of duplicated unless the plot is customized (e.g. having different arguments or data).
sphinxext.gallery_order
) to organize/order the example gallery. plot_trace
will have "model checking" and "mixed" tags in a single example py file. I think this can be implemented in the docstring (lowest effort) because the gallery_generator
runs some regex to extract these values. The downside is that it's hard to catch typos if the tag is misspelled and gets omitted/looks bad.Moving the css to our custom.css
would be great, thanks.
It might also be possible to simplify it using grids and/or cards via sphinx directives.
I have a vague idea about how css works, no idea whatsoever about JS, so this is great news :)
Agreed that the current hover text is not useful. And the images don't have alt text either. It might be a good idea to start with a dry and concise description of the generated graph to then use as hover and/or alt text. That would also be something that is specific to the example and not to the function/type of plot, and even if we manage to restructure everything better, should still be available as alt text at least once we enter the example page to make the docs more accessible.
The border efect sounds good, the card elements I mentioned above already have those, so if we got rid of the span html element I think using a card or grid-item-card would achieve the same visual and include the link effect with minimal work on our side.
Showing the full plot instead of a cropped thumbnail would be much better conceptually and if we can get rid of the thumbnail generation code even better.
I think that depends on the subsections we decide to use.
From the discussion above theres a lot going on so here's my suggested split of tasks
Also this is the first time ive ever heard that @OriolAbril is not good at something! From everything ive seen Oriol is great at everything 😱
For CSS and example gallery (points 1 and 2 above), moving CSS to external file was pretty straightforward. Then I tried a combination of Sphinx's grids/cards and ended up deleting all the original custom CSS because Sphinx has its own CSS classes and elements.
The code and gallery look cleaner (no more thumbnails, got rid of hover text), but the generated HTML/CSS for Sphinx grid-item-card is pretty limited and hard to modify (i.e. lack of <div>
s to space things correctly, can't insert own classes while creating elements, using flex instead of grid, etc.). Even if I tweak the page with the chrome developer, I don't actually know if I can implement the HTML I want with Sphinx. I'm overwriting a lot of their classes in the custom CSS file to make sure they're sized and spaced right. In the current gallery_generator
, it's really easy to customize both the HTML/CSS although it's not fun to look at in a .py file (would still prefer sphinx).
Another thing I could try is sphinx-gallery which looks more customizable, but I'm not sure yet how much change that involves. I do like how their template is structured (better example here). I would probably figure this template out first before splitting into categories based on Oriol's recommendation (also like the idea of a separate workflow page).
...
but the generated HTML/CSS for Sphinx grid-item-card is pretty limited and hard to modify (i.e. lack of
s to space things correctly, can't insert own classes while creating elements, using flex instead of grid, etc.).It is not possible to change the name or the number/hierarchy of the generated html elements (cards and grids are generated all from
div
elements) but is is possible to add extra classes in addition to the ones the extension provides by defining them as arguments of the grid/grid-item/card directives.For example, the page: https://www.arviz.org/en/latest/our_team.html (whose core contributor grid is generated from https://raw.githubusercontent.com/arviz-devs/arviz-project/main/core_contributors.md) uses the
p-2
class so unlike the default, their edges are a bit rounded. If you want you can try opening a PR with the changes you have done so far and I can try reviewing to see if I can help. Or try to have a quick call to discuss this
Externalizing the gallery so everything depends on sphinx-gallery instead of a custom extension would be great, but I don't think it is possible to combine multiple python scripts into the same example using tabs.
I am also not sure what you mean by the sphinx gallery template. Do you mean so code and explanations can be combined in the same page? If so we can look at multiple alternatives, I don't really like the sphinx-gallery approach, I find it's too standalone (either you use everything from sphinx-gallery or you use nothing) and not well integrated with the rest of sphinx or jupyter ecosystem. It looks like now it is possible to use the sphinx-gallery css alone though, which is something.
Hey @OriolAbril and @canyon289 - I'm going to start suggesting layouts for categories.
In the mockup below, I'm suggesting the following:
Oriol mentioned that there can be overlap between categories, so the mockup shows Forest Plot appearing in "Mixed" and "Distributions" as an example. They should link to the same page, but Forest Plot will just show up twice in the Table of Contents + gallery card. Is that okay?
Duplicates are fine for now. I wonder if itll make things too cluttered but lets try it out
On hover, plot title turns blue + chart gets a blue overlay with the function name in white text.
Sounds good
I changed the gray background to white for the charts so it looks "cleaner"/minimal.
Also good
If you're okay with me adding a custom style to ArviZ then I can play around with chart aesthetics (e.g. change blue to arviz blue)
I would be thrilled if proposed changes to the styles. Youre really good at this
We can put descriptions under each category that can say which plot(s) is most commonly used. I think that will be a good entry point for new users when they are exploring the gallery. The python graph gallery is a rough example of what I'm describing (header, description, image tiles, repeat).
I think this will be tougher for ArviZ because some plots require so much context on both modeling and how samplers work. Lets open another issue ticket to discuss how we may meet this intent.
We can add documentation on "best practices" in the styles section? I'm not too sure what it'll include yet, but if this is the right place for it then I can add some ideas on it to the next mockup.
Lets open another issue for this as well at least to track we want to have a discussion
Thank you for this thought and discussion. We have some concrete actions and also some new threads to think about. Appreciate all the knowledge and improvements youre adding here
will try to add more comments soon, some quick ideas for now
Duplicates are fine for now. I wonder if itll make things too cluttered but lets try it out
My idea was to have arviz funcions appear in multiple sections but to aim for no duplicated images/examples. plot_forest will appear in multiple places, but in one it will have the rhat and ess dots, in another show only the intervals for each variable, yet another plotting mutiple models... so the images would be mixed, ditribution, comparing distributions, but the functtion is always plot_forest. We can probably also have overlap between categories using the same image but that might be confusing to visitors, we'd have to check somehow.
I changed the gray background to white for the charts so it looks "cleaner"/minimal.
is that updating the use of arviz-darkgrid
style to arviz-white
or arviz-whitegrid
? or something else? I think the long term goal here is to have an arviz-doc
style we use throughout the documentation and that is also available as the other arviz themes.
If you're okay with me adding a custom style to ArviZ then I can play around with chart aesthetics (e.g. change blue to arviz blue)
That would be ok but you will probably need to create a whole new colorscheme from 0. The current one is colorblind friendly, so if you only change one color chances are it will become similar to another of the existing ones for some colorblindness type.
Tell us about it
Current State: The ArviZ example gallery currently lists plots in alphabetical order (based on API name), but there are a few critiques:
az.plot_dist_comparison
) from the API Reference might be missing from the example gallery?Recommendation:
doc/sphinxext/gallery_generator.py
file). Most charts in the example gallery should default tofigsize=[8, 6]
wherever makes sense (e.g. not "Separation Plot" because it makes more sense as a thin bar).Thoughts on implementation
Distributions
- density, dist, dot plot, trace plots2D Distributions
- 2D KDE plotsCorrelation
- autocorrelation, plot HDIInference
- bpv, posterior plotsStyle Sheets
(at the end)