Travel Tips
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
其他交互工具设置 ① 筛选数据 - 显示/隐藏 ② 交互小工具
① 筛选数据 - 显示/隐藏
② 交互小工具,
参考文档:http://bokeh.pydata.org/en/latest/docs/user_guide/interaction/widgets.html#pretext
import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import warnings warnings.filterwarnings('ignore') # 不发出警告 from bokeh.io import output_notebook output_notebook() # 导入notebook绘图模块 from bokeh.plotting import figure,show from bokeh.models import ColumnDataSource # 导入图表绘制、图标展示模块 # 导入ColumnDataSource模块
# legend.click_policy
from bokeh.palettes import Spectral4 # 导入颜色模块 df = pd.DataFrame({'A':np.random.randn(500).cumsum(), 'B':np.random.randn(500).cumsum(), 'C':np.random.randn(500).cumsum(), 'D':np.random.randn(500).cumsum()}, index = pd.date_range('20180101',freq = 'D',periods=500)) # 创建数据 p = figure(plot_width=800, plot_height=400, x_axis_type="datetime") p.title.text = '点击图例来隐藏数据' for col,color in zip(df.columns.tolist(),Spectral4): p.line(df.index,df[col],line_width=2, color=color, alpha=0.8,legend_label = col) p.legend.location = "top_left" p.legend.click_policy="hide" # 设置图例,点击隐藏 show(p)
# legend.click_policy
from bokeh.palettes import Spectral4 # 导入颜色模块 df = pd.DataFrame({'A':np.random.randn(500).cumsum(), 'B':np.random.randn(500).cumsum(), 'C':np.random.randn(500).cumsum(), 'D':np.random.randn(500).cumsum()}, index = pd.date_range('20180101',freq = 'D',periods=500)) # 创建数据 p = figure(plot_width=800, plot_height=400, x_axis_type="datetime") p.title.text = '点击图例来隐藏数据' for col,color in zip(df.columns.tolist(),Spectral4): p.line(df.index,df[col],line_width=2, color=color, alpha=0.8,legend_label = col, muted_color=color, muted_alpha=0.2) # 设置消隐后的显示颜色、透明度 p.legend.location = "top_left" p.legend.click_policy="mute" # 设置图例,点击隐藏 show(p)
# 图表分页
from bokeh.models.widgets import Panel, Tabs # 导入panel,tabs模块 p1 = figure(plot_width=500, plot_height=300) p1.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5) tab1 = Panel(child=p1, title="circle") # child → 页码 # title → 分页名称 p2 = figure(plot_width=500, plot_height=300) p2.line([1, 2, 3, 4, 5], [4, 2, 3, 8, 6], line_width=3, color="navy", alpha=0.5) tab2 = Panel(child=p2, title="line") tabs = Tabs(tabs=[ tab1, tab2 ]) # 设置分页图表 show(tabs)
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Donec in ullamcorper quam. Aenean vel nibh eu magna gravida fermentum. Praesent eget nisi pulvinar, sollicitudin eros vitae, tristique odio.
December 4, 2020 at 3:12 pm
我是 s enim interduante quis metus. Duis porta ornare nulla ut bibendum
Rosie
6 minutes ago