簡體   English   中英

python散景中的反向軸

[英]Reverse axis in python bokeh

我試圖在散景散點圖中反轉 y 軸並設置 x 和 y 的范圍。 我正在使用:

BokehPlot.bokeh_scatter(data=df, x_range=(min_utc, max_utc), y_range=(min_val, max_val))

我收到一個錯誤:

TypeError: bokeh_scatter() got an unexpected keyword argument 'x_range'

任何想法如何在散景散點圖中使用熊貓數據框輸入反轉軸

如果你沒有在你的軸上設置明確的邊界,它的范圍將是一個DataRange1d ,邊界會根據你繪制的任何內容自動計算。 在這種情況下,設置范圍的flipped屬性將翻轉它,而無需您設置顯式邊界:

from bokeh.plotting import figure, show
fig = figure()
# Do some plotting calls with fig...
fig.y_range.flipped = True
show(fig)

如果您想設置明確的界限,請參閱另一個問題的答案 正如 Don Smythe 的回答所提到的,您可以以相反的順序設置邊界以反轉任何軸類型。

下面將翻轉散點圖的 y 軸。

p = figure()

xmin = data[xval].min()
xmax = data[xval].max()
ymin = data[yval].min()
ymax = data[yval].max()

# Note that ymin and ymax are in reverse order in y_range.
p.scatter(xval, yval, x_range=(xmin, xmax), y_range=(ymax, ymin))
show(p) 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM