Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

python - Trying plotting vbar 3 source with high range value in Bokeh

im still new at bokeh so, im using stock market dataset, which contain columns like : Company names, date, and volume. Im trying to plot all of that into one graph with vbar, with Date on X axis, Volume in Y axis. each companies has its own datasets, so i make 3 source. Now im finished on plotting all of these, but the problem is:

The value of 'Volume' in one from three companies is very low comparing to others. These makes my plot for this low-value company is looking 'Flat'. maybe it is easier if i show you my plot and my code:

Code:

output_notebook()
from math import pi
t_v = [("Date", "@Date{%d-%m-%Y}"),
            ("Name", "@{Name}"),
            ("Volume", "@{Volume}")]

f_v = {"@Date": "datetime",
       "@{Adj Close}": "printf"
        }

w = datetime.timedelta(days=1) # day in ms

plot2 = figure(x_axis_type="datetime", height=900,title="Visualisasi Data Interaktif Fluktuasi Harga Saham",sizing_mode="stretch_width")
plot2.xaxis.axis_label = 'Date'
plot2.yaxis.axis_label = 'Volume'
plot2.xaxis.major_label_orientation = pi/4 #Kemiringan label x
plot2.grid.grid_line_alpha=0.3 #transparansi grid
#plot2.legend.click_policy="hide"




p1v=plot2.vbar(x=dodge('Date',-0.25), width=w, top='Volume', bottom=0,color="blue", legend_label='NASDAQ',alpha=0.1,source=nasdaq_source)
plot2.add_tools(HoverTool(renderers=[p1v],
                         tooltips=t_v,
                         formatters = f_v,
                         point_policy="follow_mouse"))

p2v=plot2.vbar(x=dodge('Date',0.0), width=w, top='Volume', bottom=0,color="green", legend_label='NIKKEI',alpha=1,source=nikkei_source)
plot2.add_tools(HoverTool(renderers=[p2v],
                         tooltips=t_v,
                         formatters = f_v,
                         point_policy="follow_mouse"))

p3v=plot2.vbar(x=dodge('Date',0.25), width=w, top='Volume', bottom=0,color="red", legend_label='HANG SENG',alpha=0.1,source=hs_source)
plot2.add_tools(HoverTool(renderers=[p3v],
                         tooltips=t_v,
                         formatters = f_v,
                         point_policy="follow_mouse"))

plot2.legend.click_policy="hide"
tab2 = Panel(child=plot2, title ="Volume")
show(Tabs(tabs=[tab1,tab2]))

Output: All Companies

enter image description here

Nikkei, The Company with lowest value of 'Volume'

enter image description here

Comparison value of 'Volume' between two company

enter image description here

question from:https://stackoverflow.com/questions/65649994/trying-plotting-vbar-3-source-with-high-range-value-in-bokeh

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...