【发布时间】:2020-07-22 07:40:47
【问题描述】:
我正在尝试将许多统计数据的条形图可视化,并想将 y 轴设置为整数(我的数据集中没有浮点类型数据)
这是其中一张图表,我想改变它的轴。
这是我用来可视化这个图表的python源代码
def plot_3(data,x,y,width):
selector = alt.selection_single(encodings=['x', 'color'])
bars = alt.Chart(data).mark_bar(opacity=0.8).encode(
alt.X('Tahun:O', title=''),
alt.Y('N:Q', title=x, axis=alt.Axis(format='.0f')), # this format axis has no effect
alt.Column('Keterangan:N', title=y),color=alt.condition(selector, 'Tahun:O', alt.value('lightgray')),
tooltip = ['Tahun','Keterangan','N','Satuan']
).add_selection(selector
).interactive(
).resolve_scale(x='independent')
return bars.properties(width=width
)
等待解决方案,谢谢:)
【问题讨论】: