![](/img/trans.png)
[英]hvplot / holoviews (bokeh) timedelta axis with negative values formatter
[英]Python: Hvplot negative values coloring
您可以為此使用合成 HoloView plot。
plot1 = df[df['Results']>0].hvplot.bar(y='Results')
plot2 = df[df['Results']<0].hvplot.bar(y='Results')
plot1*plot2
注意:抱歉,我還不能直接發布圖片,因為這是我在 stackoverflow 上的第一個條目,但此鏈接會向您顯示 plot 結果https://i.stack.imgur.com/bnoFg.png
這是下面的完整代碼,您可以將其調整為您的 dataframe:
# create a dataframe with column 'Name' as index
dict = {'Name':["Rick", "Sam", "Kelly", "Al"],
'Results':[-90, +40, +80, -28]}
df = pd.DataFrame(dict)
df.index=df['Name']
# create 2 hvplots: 1 for positive results, and 1 for negative results
plot1 = df[df['Results']>0].hvplot.bar(y='Results')
plot2 = df[df['Results']<0].hvplot.bar(y='Results')
# layout plot1 and plot2 content on the same frame using a compositional plot
plot1*plot2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.