阅读背景:

如何在Python的Bokeh图中扩展有限的调色板

来源:互联网 

I have the following code:

我有以下代码:

from bokeh.plotting import figure, show, output_file
from bokeh.sampledata.iris import flowers  
from bokeh.models import LinearColorMapper
from bokeh.models import ColumnDataSource 
from bokeh.models import ColorBar 
from bokeh.palettes import Reds9

p = figure(title = "Iris Morphology")
p.xaxis.axis_label = "Petal Length"
p.yaxis.axis_label = "Petal Width"

source = ColumnDataSource(flowers)


# Reverse the color and map it
Reds9.reverse()
exp_cmap = LinearColorMapper(palette=Reds9, 
                             low = min(flowers["petal_length"]), 
                             high = max(flowers["petal_length"]))

p.circle("petal_length", "petal_width", source=source, line_color=None,
        fill_color={"field":"petal_length", "transform":exp_cmap})



bar = ColorBar(color_mapper=exp_cmap, location=(0,0))
p.add_layout(bar, "left")

show(p)
from bok



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: