-
-
Save jurand71/954c58b32fef719cefe68440063bafb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file, output_notebook | |
from bokeh.plotting import figure, show | |
from bokeh.layouts import column | |
from bokeh.models import RangeTool, ColumnDataSource | |
output_file('images/bokeh_range_gzf2022.html', title='Generacja źródeł fotowoltaicznych') | |
dates = np.array(df['Data'], dtype=np.datetime64) | |
source_pv = ColumnDataSource({'date': dates, | |
'value':df['Generacja źródeł fotowoltaicznych'] | |
}) | |
img = figure(x_axis_type='datetime', | |
x_axis_location='above', | |
tools='xpan', | |
toolbar_location= None, | |
x_range=(dates[4380],dates[5100]) | |
) | |
line_pv = img.line(x='date', y ='value', source = source_pv, | |
color='green', line_width=1, legend_label='Generacja ze źródeł fotowoltaicznych') | |
img.add_tools(HoverTool(renderers=[line_pv], tooltips=[('PV',"@{value}")], mode='vline')) | |
img.yaxis.axis_label='MWh' | |
select_name = 'Przeciągnij krawędzie celem zmiany zakresu danych' | |
select = figure(title = select_name, | |
height = 150, | |
y_range = img.y_range, | |
x_axis_type = 'datetime', | |
y_axis_type = None, | |
tools = '', | |
toolbar_location = None | |
) | |
range_tool = RangeTool(x_range = img.x_range) | |
select.line(x='date', y ='value', source = source_pv, color='green', line_width=1) | |
select.ygrid.grid_line_color = None | |
select.add_tools(range_tool) | |
select.toolbar.active_multi = range_tool | |
show(column(img, select)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment