-
MWEimport altair as alt
import numpy as np
import pandas as pd
# Compute x^2 + y^2 across a 2D grid
x, y = np.meshgrid(range(-5, 5), range(-5, 5))
z = x ** 2 + y ** 2
# Convert this grid to columnar data expected by Altair
source = pd.DataFrame({'x': x.ravel(),
'y': y.ravel(),
'z': z.ravel()})
alt.Chart(source).mark_rect().encode(
x='x:O',
y='y:O',
color='z:Q'
) QuestionWhat is the simplest way to change the color of this heatmap? Is there, for example, a way to tell it I want the max color to be RelatedThe answer provided here is pretty involved. |
Beta Was this translation helpful? Give feedback.
Answered by
mattijn
Dec 29, 2022
Replies: 1 comment 1 reply
-
See the Altair docs here: https://altair-viz.github.io/user_guide/customization.html#customizing-colors |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mcp292
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the Altair docs here: https://altair-viz.github.io/user_guide/customization.html#customizing-colors
For the available color scales, see here: https://vega.github.io/vega/docs/schemes/