[英]How to hide colorbar/legend in altair?
Is there a way to hide the color bar on Altair?有没有办法隐藏 Altair 上的颜色条?
Specifically, I want to get rid of the amount_spent
one, without deleting the gradiente on the mark_bar
.具体来说,我想摆脱amount_spent
一个,而不删除mark_bar
上的 gradiente。 Is this possible?这可能吗?
Here's the code:这是代码:
alt.Chart(df_1).mark_bar().encode(
x = alt.X('amount_spent:Q', title = "Monto gastado en MXN"),
y = alt.Y('page_name:N', sort='-x', title = " "),
color='amount_spent',
).transform_window(
rank='rank(amout_spent))',
sort=[alt.SortField('amount_spent', order='descending')]
).transform_filter(
alt.datum.rank <= 20
).properties(
width = 800,
height= 500,
title = "Monto gastado en MXN por página de FB"
)
Output: Output:
Yes, you can do this by setting the legend
property of the color
encoding to None
;是的,您可以通过将color
编码的legend
属性设置为None
来做到这一点; that is, replace this:也就是说,替换这个:
color='amount_spent'
with this:有了这个:
color=alt.Color('amount_spent', legend=None)
See Adjusting the Legend in the Altair documentation for more information.有关详细信息,请参阅 Altair 文档中的调整图例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.