小编Nic*_*rey的帖子

如何在高空绘图中以盒子形状添加图层?

我正在尝试使用一个带有坐标的熊猫数据框添加一个用作罢工区的框,并将其传递给altair。

box = pd.DataFrame()
box.loc[:,"x"] = [-0.5, 0.5, 0.5, -0.5]
box.loc[:,'y'] = [1.25, 1.25, 0.5, 0.5]
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法:

g = alt.Chart(box.loc[0:1,:]).mark_line().encode(
x = 'x',
y = 'y')

d = alt.Chart(box.loc[1:2,:]).mark_line().encode(
x = 'x',
y = 'y')

e = alt.Chart(box.loc[2:3,:]).mark_line().encode(
x = 'x',
y = 'y')

f = alt.Chart(box.loc[3:4,:]).mark_line().encode(
x = 'x',
y = 'y')

g + d + e + f
Run Code Online (Sandbox Code Playgroud)

我也想知道如何调整x和y轴,以便在盒子周围留一点余量?

python-3.x altair

6
推荐指数
1
解决办法
103
查看次数

标签 统计

altair ×1

python-3.x ×1