繁体   English   中英

在Altair中,如何设置折线图中连接点的大小?

[英]In Altair, how to set the size of the connected points in a line chart?

我想在 Altair 中绘制折线图(带有连接的点标记)。 我知道如何更改线宽(通过设置strokeWidth),但我不知道如何更改这些点标记的大小。 下面是我的代码:

altair.Chart(ys.reset_index()).mark_line(point=True, strokeWidth=5).encode(
        x="Time:T",
        y="HL:Q",
        color=altair.Color(
            "Time Series Component",
            scale=altair.Scale(scheme="dark2")
        ),
        tooltip=["Time Series Component", "Time", "HL"]
    ).interactive().properties(
        width=1000,
        height=500
    ).configure_axis(
        labelFontSize=20,
        titleFontSize=20
    ).configure_legend(
        orient="right"
    )

一种方法是使用configure_point(size=SIZE) 例如:

import altair as alt
import pandas as pd
import numpy as np

np.random.seed(0)

ys = pd.DataFrame({
    'Time': pd.date_range('2019-01-01', freq='D', periods=30),
    'HL': np.random.randn(30).cumsum(),
    'Time Series Component': np.random.choice(list('ABC'), 30),
})

alt.Chart(ys.reset_index()).mark_line(point=True, strokeWidth=5).encode(
    x="Time:T",
    y="HL:Q",
    color=alt.Color(
        "Time Series Component",
        scale=alt.Scale(scheme="dark2")
    ),
    tooltip=["Time Series Component", "Time", "HL"]
).interactive().properties(
    width=1000,
    height=500
).configure_axis(
    labelFontSize=20,
    titleFontSize=20
).configure_legend(
    orient="right"
).configure_point(
    size=200
)

在此处输入图片说明

有关自定义 altair 可视化的更多信息,请参阅https://altair-viz.github.io/user_guide/customization.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM