Skip to content

Conversation

@huong-li-nguyen
Copy link
Contributor

@huong-li-nguyen huong-li-nguyen commented Nov 11, 2025

Description

Closes https://github.com/McK-Internal/vizro-internal/issues/2330

  • Make themes, colors, and palettes public
  • Provide how-to-guide and API reference with visual reference
  • Create script to create the visual reference via hatch command hatch run generate-color-images

Usage

from vizro.themes import colors, palettes

# Individual colors
print(colors.cyan_500)

# Palettes
print(palettes.qualitative)
print(palettes.sequential_cyan)
print(palettes.diverging_red_cyan)

Screenshot

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 11, 2025

View the example dashboards of the current commit live on PyCafe ☕ 🚀

Updated on: 2026-01-14 11:05:53 UTC
Commit: d61c539

Compare the examples using the commit's wheel file vs the latest released version:

vizro-core/examples/scratch_dev

View with commit's wheel vs View with latest release

vizro-core/examples/dev/

View with commit's wheel vs View with latest release

vizro-core/examples/visual-vocabulary/

View with commit's wheel vs View with latest release

vizro-core/examples/tutorial/

View with commit's wheel vs View with latest release

@huong-li-nguyen huong-li-nguyen self-assigned this Nov 11, 2025
@huong-li-nguyen
Copy link
Contributor Author

@antonymilne - now that I've written everything anyway, I am wondering whether we should just make it public even though the color palettes might change in the future 🤔

Copy link
Contributor

@stichbury stichbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Just a few comments. Would love to see some graphics in the themes.md to illustrate the different types of qualitative/sequential/diverging palettes etc, so it's easy to see what is on offer.

@antonymilne
Copy link
Contributor

FYI I plan to review this after we've reviewed and merged https://github.com/McK-Internal/vizro-internal/pull/2347 🙂 We can make any similar required changes on your PR here once we're happy with that internal PR.

antonymilne and others added 6 commits November 25, 2025 10:42
…ardize naming

- Rename colors.py, palettes.py, templates.py, static_template_generator.py to use underscore prefix (_colors.py, etc.)
- Move create_template_common() from _templates.py to _static_template_generator.py where it's used
- Update all imports to use private module names
- Change grey to gray (American spelling) for consistency with vizro_mck
- Update hatch.toml paths to reflect new module locations
- Move PYTHONPATH configuration from hatch.toml to pyproject.toml
- Add tools directory to pytest pythonpath for cleaner test imports
- Remove sys.path manipulation from test_generate_templates.py
- Update test imports to use direct import from generate_templates
- Add comment explaining PYTHONPATH needed for gunicorn (pytest pythonpath only affects pytest)
- Restore PYTHONPATH in hatch.toml for e2e test gunicorn processes
- Keep pytest pythonpath in pyproject.toml for test discovery
@antonymilne antonymilne marked this pull request as draft November 26, 2025 10:00
@antonymilne
Copy link
Contributor

antonymilne commented Nov 26, 2025

Generally looks great 💯 I did a small bit of tidying but didn't change anything major. The most important changes to be aware of are:

  • renamed modules inside vizro/themes to have initial _. This is important so that there's only one correct import path. Previously you could have done from vizro.themes import colors or from vizro.themes.colors import colors. This tends to confuse IDEs (and people). Now there's only one way to import: from vizro.themes import colors. The other route is clearly wrong because it would be from vizro.themes._colors import colors which goes through a private module.
  • moved the template json generation script and its associate helper function to tools so that it's not shipped with Vizro source. It always should have been there, just I couldn't quite figure out how to do it before.

I've put this back into draft and the ticket as blocked by https://github.com/McK-Internal/vizro-internal/issues/2293. When that's done, here's what remains for @antonymilne and @huong-li-nguyen:

  • update colors/palettes here. There could potentially be more substructure inside palettes if it's useful to do so
  • make sure we have a default for palettes.qualitative, sequential, diverging and maybe sequential_minus that is just called simply that (so not diverging_red_blue or similar)
  • update docs with the new colors/palettes. For the continuous ones let's change to use the same continuous spectrum that I introduced in vizro_mck. Maybe it's also possible to put these in as interactive plotly charts in docs rather than static png though if that's hard to do it doesn't matter

I thought about whether we should release this as a separate Python package and version separately and decided not to - let's release as part of Vizro, as done here.

@huong-li-nguyen
Copy link
Contributor Author

Sounds great and I agree with everything! 🚀

Just this point I am less sure about:

  • update docs with the new colors/palettes. For the continuous ones let's change to use the same continuous spectrum that I introduced in vizro_mck. Maybe it's also possible to put these in as interactive plotly charts in docs rather than static png though if that's hard to do it doesn't matter

I don't know if you saw my comment in the other repo, but I kind of like the current visual for the sequential palettes as well (optimally, they should have the name of the colors inside the squares too). This way our users could easily do subsets of the sequential sequences without having to refer to the source code (@lingyielia use case, where she wanted more contrast and just took X out of the 16 colors inside the sequential palette). But I do think that the spectrum visual is correct for continuous scales, maybe let's ask @stephkaiser for the final visuals in the end 👍

@antonymilne
Copy link
Contributor

Yes I saw your comment and replied with this:

I actually agree and kind of preferred the pictures before too 😅 It made it a bit easier to see what all the colors are. But indeed, I think the way we do it now is "better".

For example, if someone now wants to use only a subset of that (Lingyis use-case), it's a bit harder to know which colors are in that diverging / sequential sequence and which ones to go for, as they all blur into each other now.

Something like https://plotly.com/python-api-reference/generated/plotly.express.colors.html#plotly.express.colors.sample_colorscale will actually do this nicely still, without the need to refer to individual colors. Instead of the colorscale being composed of a discrete set of colors, it's on a scale from 0 to 1, and you can just take a subset of that scale if you like.

So unless @stephkaiser disagrees I think we should go for the continuous spectrum visuals for the continuous palettes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants