0
我正在使用熊貓 - 散景中的數據集,其中有幾個地方值爲NaN
。在製作標準散點圖時,繪圖界面只會忽略包含NaN
值的行。但是,當我將任一軸更改爲對數刻度時,根本沒有繪製任何點。什麼可能導致這個?Python /散景 - 在日誌尺度上繪製空白數據
我正在使用熊貓 - 散景中的數據集,其中有幾個地方值爲NaN
。在製作標準散點圖時,繪圖界面只會忽略包含NaN
值的行。但是,當我將任一軸更改爲對數刻度時,根本沒有繪製任何點。什麼可能導致這個?Python /散景 - 在日誌尺度上繪製空白數據
這是當前已知的問題,被列爲0.9.4版的里程碑。檢查出這個線程:https://github.com/bokeh/bokeh/issues/2162
我有一個類似的問題,所以作爲一種解決方法,我已經nan值分割我的範圍,並繪製每個集合單獨。這是基於Bokeh的log scale example和unutbu's回答於this question。
import numpy as np
from bokeh.plotting import figure, output_file, show
from bokeh.models import LogAxis, Range1d
def using_clump(a, b):
return [a[s] for s in np.ma.clump_unmasked(np.ma.masked_invalid(b))]
def main():
x = [0.1, 0.5, 1.0, 1.5, np.nan, 2.0, 2.5, 3.0]
y = [10**xx for xx in x]
output_file("log.html")
p = figure(plot_width=400, plot_height=400,
y_axis_type="log", y_range=(10**-1, 10**4))
xdata = using_clump(x, x)
ydata = using_clump(y, x)
for i in range(0, len(xdata)):
p.line(xdata[i], ydata[i], line_width=2)
p.circle(xdata[i], ydata[i], fill_color="white", size=8)
show(p)