import 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(stroke='black', strokeWidth=2).encode(
x='x:O',
y='y:O',
color='z:Q'
)
是的,您可以使用
rect
标记的stroke
属性来执行此操作。改编Altair文档中的heatmap example:相关问题 更多 >
编程相关推荐