简体   繁体   中英

python bokeh horizon setting y-scale

Note from maintainers: This question concerns the obsolete bokeh.charts API that was removed several years ago. For information about about plotting with modern Bokeh (including stacked areas), see:

https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html



Hi I am doing a data visualization project which need to use bokeh Horizon to plot a graph of the price of stocks and I am new to this library. Can some show how to change scale of the y-axis to prevent the overlapping of graph. So here is my code to plot this graph

from bokeh.charts import Horizon, show, output_file
import pandas as pd

#stock data

NVDA=pd.read_csv('http://ichart.yahoo.com/table.csv?s=NVDA&a=0&b=1&c=2010&d=0&e=1&f=2018', parse_dates=['Date'])
AAPL=pd.read_csv('http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2010&d=0&e=1&f=2018', parse_dates=['Date'])

data={'NVDA':NVDA['Adj Close'],'Date':NVDA['Date'],'AAPL':AAPL['Adj Close']}

plot=Horizon(data, x='Date', title='Nvidia & Apple stock prices in recent 7 years', plot_width=800, plot_height=500)

output_file('bokeh.html')

show(plot)

The result shows like this

股票价格

As you can see when the price go beyond the limit it will just overlap the original graph with a deeper color. I tried to change the plot_height parameter but it only stretch the graph in the vertical direction.

尝试将 num_folds=1 作为附加参数传递给 Horizo​​n()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM