Altair 图表:在网格中显示较少的线
Altair chart: Show less lines in the grid
我正在使用 Altair 绘制图表,我正在尝试找出如何减少背景网格中的线条。那个背景网格有术语吗?
这是一张看起来像我的图表,是我从 the tutorial:
中截取的
假设我想在 X 轴上有一半的网格线。我该怎么做?
网格线绘制在刻度位置,所以要调整网格线可以调整刻度。例如:
import altair as alt
import numpy as np
import pandas as pd
x = np.arange(100)
source = pd.DataFrame({
'x': x,
'f(x)': np.sin(x / 5)
})
alt.Chart(source).mark_line().encode(
x=alt.X('x', axis=alt.Axis(tickCount=4)),
y='f(x)'
)
您可以在 alt.Axis
的文档中查看其他与报价相关的属性。
我正在使用 Altair 绘制图表,我正在尝试找出如何减少背景网格中的线条。那个背景网格有术语吗?
这是一张看起来像我的图表,是我从 the tutorial:
中截取的假设我想在 X 轴上有一半的网格线。我该怎么做?
网格线绘制在刻度位置,所以要调整网格线可以调整刻度。例如:
import altair as alt
import numpy as np
import pandas as pd
x = np.arange(100)
source = pd.DataFrame({
'x': x,
'f(x)': np.sin(x / 5)
})
alt.Chart(source).mark_line().encode(
x=alt.X('x', axis=alt.Axis(tickCount=4)),
y='f(x)'
)
您可以在 alt.Axis
的文档中查看其他与报价相关的属性。