question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation for choosing specific colors

See original GitHub issue

I didn’t see a way to do this in the spec. I’d be happy to write some documentation if someone could explain how to do this.

For example, how can I ensure that black is used for time_of_day == 'night' and gold for time_of_day == 'morning'?

Chart(data).mark_area().encode(
    color='time_of_day:N',
    x='frame:Q',
    y='movement:Q',
)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
jakevdpcommented, Nov 17, 2016

You can do this by specifying the Scale for the color encoding. There’s an example near the end of the Seattle Weather Tutorial.

For your chart, it might look something like this:

from altair import Chart, Color, Scale

Chart(data).mark_area().encode(
    Color('time_of_day:N',
          scale=Scale(domain=['night', 'morning'],
                      range=['black', 'gold'])),
    x='frame:Q',
    y='movement:Q',
)

If you would like to add a section on this in the config documentation, that would be a nice contribution!

3reactions
getup8commented, Feb 14, 2019

Just wanted to document an almost identical way, but aligned with what’s in the docs.

tableau10 can be any of these: https://vega.github.io/vega/docs/schemes/#categorical

# Define your custom theme.
def my_theme():
    return {
        'config': {
            'range': {'category': {'scheme': 'tableau10'}}
        }
    }

# Register and enable.
alt.themes.register('my_theme', my_theme)
alt.themes.enable('my_theme')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Color Theory 101: A Complete Guide to Color Wheels & Color ...
Visualizing colors in this way helps you choose color schemes by showing you how each color relates to the color that comes next...
Read more >
Design System Documentation — Color - Prototypr
Any system designer responsible for color must be familiar with WCAG 2.0 rules and incorporate the practice into color selection.
Read more >
How to choose your brand colors - Canva
STEP 1: Understand how different colors impact mood and perception · STEP 2: Learn color-related terminology · STEP 3: Research your competitor brand...
Read more >
A quick guide to choosing a color palette - InVision
A quick guide to choosing a color palette · Start with greyscale. · Use the 60-30-10 rule. · The best color combinations come...
Read more >
Choosing color palettes — seaborn 0.12.1 documentation
Because of the way our eyes work, a particular color can be defined using three components. We usually program colors in a computer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found