[英]Altair Scatter Plot tickMinStep
I have this DataFrame:我有这个 DataFrame:
x y term s
0 0.000000 0.132653 matlab 0.893072
1 0.000000 0.142857 matrix 0.905120
2 0.012346 0.153061 laboratory 0.902610
3 0.987654 0.989796 be 0.857932
4 0.938272 0.959184 a 0.861948
And have generated this chart:并生成了这张图表:
Using this code:使用此代码:
chart = alt.Chart(scatterdata_df).mark_circle().encode(
x = alt.X('x:Q', axis = alt.Axis(title = "⏪ less physical | more physical ⏩", tickMinStep = 0.05)),
y = alt.Y('y:Q', axis = alt.Axis(title = "⏪ less data | more data ⏩", tickMinStep = 0.05)),
color = alt.Color('s:Q', scale=alt.Scale(scheme='redblue')),
tooltip = ['term']
).properties(
width = 500,
height = 500
)
Having set tickMinStep = 0.05
for both the x and y axes, I'm not sure why the graph doesn't reflect this parameter.为 x 和 y 轴设置tickMinStep = 0.05
,我不确定为什么图表没有反映这个参数。
Thank you.谢谢你。
tickMinStep
specifies the minimum tick spacing for the automatically determined ticks; tickMinStep
指定自动确定的刻度的最小刻度间距; actual tick spacing may be larger than this.实际刻度间距可能大于此。 It sounds like you want more ticks than the default heuristic gives, so you should instead adjust tickCount
directly:听起来您想要比默认启发式提供的更多滴答声,因此您应该直接调整tickCount
:
import altair as alt
import pandas as pd
import numpy as np
rng = np.random.default_rng(0)
data = pd.DataFrame({
'x': rng.random(size=100),
'y': rng.random(size=100)
})
alt.Chart(data).mark_point().encode(
x=alt.X('x:Q', axis=alt.Axis(tickCount=20)),
y=alt.Y('y:Q', axis=alt.Axis(tickCount=20)),
)
If you want even finer control over tick values, you can pass a list of values directly to Axis.values
.如果您想更好地控制刻度值,您可以将值列表直接传递给Axis.values
。 For more information, see the alt.Axis
documentation.有关详细信息,请参阅alt.Axis
文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.