在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。
我想在 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。