条形图的散景对数刻度 [英] Bokeh logarithmic scale for Bar chart
问题描述
我知道我可以使用绘图API对背景虚化刻度:
p = figure(
tools="pan,box_zoom,reset,previewsave",
y_axis_type="log", y_range=[0.001, 10**22], title="log axis example",
x_axis_label='sections', y_axis_label='particles'
)
但是,我无法弄清楚如何将其应用于诸如Bokeh.charts.Bar.
之类的高级图表.通常,我很难理解Chart
和
本周,我将特别更新描述不同Bokeh API的文档,但现在,这三个Bokeh API的级别"升序排列:/p>
- 模型接口:最低级别的API,基本序列化层,必须手动将所有内容放在一起
- 字形界面(bokeh.plotting):中级API,可以轻松创建以视觉字形为中心的图/图,其属性与数据相关联
- 图表界面(bokeh.charts):用于罐装/示意图统计图表的高级API,例如"BoxPlot"和直方图".
figure
与各种图表函数之间没有特殊关系,只是它们都生成Plot
的子类作为输出.
我不确定当前是否可以在图表"界面中向对数图添加对数轴(这是添加的合理功能).但是,使用中间的字形"界面(使用rect
或quad
字形)手动"制作箱形图将很简单.这是一个简单的示例:
from bokeh.plotting import figure, output_file, show
output_file("bars.html")
p = figure(title="log bar example", y_axis_type="log")
p.quad(
bottom=0, top=[10**5, 10**8, 10**3],
left=[0, 2, 4], right=[1,3,5]
)
show(p)
I know that I can do logarithmic scales with bokeh using the plotting API:
p = figure(
tools="pan,box_zoom,reset,previewsave",
y_axis_type="log", y_range=[0.001, 10**22], title="log axis example",
x_axis_label='sections', y_axis_label='particles'
)
However, I can't figure out how to get this to apply to high level charts such as Bokeh.charts.Bar.
In general I'm having a lot of trouble grokking what to relationship is between a Chart
and a figure
. Can anyone point me to some documentation on this or explain how to modify things which are only exposed through figure and have them affect my Chart.
I am specifically going to update the documentation describing the different Bokeh APIs this week, but for now, the three Bokeh APIs in increasing order of "level":
- models interface: lowest level API, base serialization layer, must put everything together everything manually
- glyphs interface (bokeh.plotting): mid-level API, easily create plots/figures centered around visual glyphs with attributes tied to data
- charts interface (bokeh.charts): high level API for canned/schematic statistical charts, e.g. "BoxPlot" and "Histogram".
There is no particular relation between figure
and the various chart functions, except that they both produces subclasses of Plot
as output.
I am not sure it is currently possible to add a log axis to the Bar plot in "charts" interface (that would be a reasonable feature to add). However it would be simple to make a boxplot "by hand" using the middle "glyphs" interface using rect
or quad
glyphs. Here is a quick example:
from bokeh.plotting import figure, output_file, show
output_file("bars.html")
p = figure(title="log bar example", y_axis_type="log")
p.quad(
bottom=0, top=[10**5, 10**8, 10**3],
left=[0, 2, 4], right=[1,3,5]
)
show(p)
这篇关于条形图的散景对数刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!