[英]changing the palette in a bar plot in bokeh
我正在查看散景教程,但無法更改條形圖中的調色板。 特別是,我正在嘗試使用以下代碼完成本筆記本中的最后一個練習:
from bokeh.palettes import brewer
from bokeh.palettes import Blues5,YlGnBu9, YlOrBr9, YlOrRd9
bar = Bar(medals,label="name",values="count",stack="medal",agg="sum",color="medal",palette=Blues5)
show(bar)
無論我從第二行嘗試什么調色板,結果都是一樣的。 我錯過了什么嗎? 我正在使用散景 0.10。
干杯。
這就是我如何使用它:
color = color(columns = 'Week of', palette = palettes.Set1_9)
在這里,我說要使用什么調色板,同時說要用什么列着色
這是我發現有效的方法,它將根據對象的“成本”為圖表的每個條形着色。
from bokeh.models import ColorBar, LinearColorMapper
from bokeh.palettes import Viridis256
mapper = LinearColorMapper(palette=Viridis256, low=0, high=150)
color_bar = ColorBar(color_mapper=mapper, location=(0,0))
plot = df.plot_bokeh.bar(
x='Date',
y='Cost',
title='Expenses'
color= {'field': 'Cost', 'transform': mapper})
show(plot)
你可以在這里看到結果:[1]: https : //i.stack.imgur.com/6oVLr.png
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.