散景中带对数轴的四边形
Quad with log axis in bokeh
是否可以在图形有y_axis_type='log'
的情况下使用figure.quad()
?我能够绘制对数变换的四边形。我还可以在对数轴上绘制一条具有相同值的线。但是当我尝试在对数轴上绘制四边形时,我得到一个空白图。我正在使用散景 0.12.9
。下面是一些具有预期输出的测试代码 ...
from bokeh.io import export_png
from bokeh.layouts import gridplot
from bokeh.plotting import figure
import numpy as np
N = 50
left = np.arange(N)
right = np.arange(1, N+1)
bottom = np.zeros(N)
top = 100 * np.sin(np.pi*left/N)**2 + 1
fig_args = dict(width=400, height=400, tools="")
f1 = figure(**fig_args, title='Quad')
f1.quad(left=left, right=right, top=top, bottom=bottom, line_color='black')
f2 = figure(**fig_args, title='Quad of Logs')
f2.quad(left=left, right=right, top=np.log10(top), bottom=bottom, line_color='black')
f3 = figure(**fig_args, y_axis_type='log', title='Line w/Log Axis')
f3.line(left, top)
f4 = figure(**fig_args, y_axis_type='log', title='Quad w/Log Axis')
f4.quad(left=left, right=right, top=top, bottom=bottom, line_color='black')
lout = gridplot([f1, f2, f3, f4], ncols=2)
export_png(lout, 'test.png')
确定如何最好地让 Bokeh 处理对数刻度中的零点仍然存在悬而未决的问题。从纯数学的角度来看,它们没有多大意义。有一些可能的实用方法可供采用,但其中 none 已被实施。但是,如果您提供明确的方向,则可以获得您需要的情节。您可以通过使用 0 以外的其他值作为 bottom
值来看到这一点, 和 显式设置 y_range
:
f4 = figure(**fig_args, y_axis_type='log', title='Quad w/Log Axis', y_range=(1, 200))
f4.quad(left=left, right=right, top=top, bottom=0.000000001, line_color='black')
生成这张图片:
是否可以在图形有y_axis_type='log'
的情况下使用figure.quad()
?我能够绘制对数变换的四边形。我还可以在对数轴上绘制一条具有相同值的线。但是当我尝试在对数轴上绘制四边形时,我得到一个空白图。我正在使用散景 0.12.9
。下面是一些具有预期输出的测试代码 ...
from bokeh.io import export_png
from bokeh.layouts import gridplot
from bokeh.plotting import figure
import numpy as np
N = 50
left = np.arange(N)
right = np.arange(1, N+1)
bottom = np.zeros(N)
top = 100 * np.sin(np.pi*left/N)**2 + 1
fig_args = dict(width=400, height=400, tools="")
f1 = figure(**fig_args, title='Quad')
f1.quad(left=left, right=right, top=top, bottom=bottom, line_color='black')
f2 = figure(**fig_args, title='Quad of Logs')
f2.quad(left=left, right=right, top=np.log10(top), bottom=bottom, line_color='black')
f3 = figure(**fig_args, y_axis_type='log', title='Line w/Log Axis')
f3.line(left, top)
f4 = figure(**fig_args, y_axis_type='log', title='Quad w/Log Axis')
f4.quad(left=left, right=right, top=top, bottom=bottom, line_color='black')
lout = gridplot([f1, f2, f3, f4], ncols=2)
export_png(lout, 'test.png')
确定如何最好地让 Bokeh 处理对数刻度中的零点仍然存在悬而未决的问题。从纯数学的角度来看,它们没有多大意义。有一些可能的实用方法可供采用,但其中 none 已被实施。但是,如果您提供明确的方向,则可以获得您需要的情节。您可以通过使用 0 以外的其他值作为 bottom
值来看到这一点, 和 显式设置 y_range
:
f4 = figure(**fig_args, y_axis_type='log', title='Quad w/Log Axis', y_range=(1, 200))
f4.quad(left=left, right=right, top=top, bottom=0.000000001, line_color='black')
生成这张图片: