[英]How to hide the colorbar and legend in plotly express bar graph?
[英]How to hide colorbar/legend in altair?
有沒有辦法隱藏 Altair 上的顏色條?
具體來說,我想擺脫amount_spent
一個,而不刪除mark_bar
上的 gradiente。 這可能嗎?
這是代碼:
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:
是的,您可以通過將color
編碼的legend
屬性設置為None
來做到這一點; 也就是說,替換這個:
color='amount_spent'
有了這個:
color=alt.Color('amount_spent', legend=None)
有關詳細信息,請參閱 Altair 文檔中的調整圖例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.