def get_weather_plot(time_int=None, t_min=None, t_max=None): plot_height = cs.plot_height plot_width = cs.plot_width border_left = cs.border_left column_names = cs.column_names_weewx column_time = cs.time_column_name_weewx if t_max == None or t_min == None: t_max, t_min = get_first_time_interval() t_span = t_max - t_min if time_int == None: time_int = cs.time_int data_seconds = sql_con.get_data_ws(time_int=time_int, t_min=t_min, t_max=t_max) data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000 plot = Plot( x_range=DataRange1d(start=(t_min - t_span * .1) * 1000, end=(t_max + t_span * .1) * 1000), y_range=DataRange1d(), plot_width=plot_width, plot_height=plot_height, # x_axis_type="datetime", min_border_left=border_left, toolbar_location="right") add_glyphs_to_plot(column_names, column_time, data_seconds, plot, 'source_weather') plot.add_layout(DatetimeAxis(name="date_time_axis"), 'below') plot.add_tools( PanTool(), WheelZoomTool(), # ResizeTool(), CrosshairTool(), PreviewSaveTool()) Grid(plot=plot, dimension=0, ticker=plot.select('date_time_axis')[0].ticker) Grid(plot=plot, dimension=1, ticker=plot.select(type=LinearAxis, name=column_names[0])[0].ticker) set_legends(plot) plot.title = cs.plot_title_weewx + ' averaged to {} seconds'.format( time_int) return plot
def get_weather_plot(time_int=None,t_min=None,t_max=None): plot_height = cs.plot_height plot_width = cs.plot_width border_left = cs.border_left column_names = cs.column_names_weewx column_time = cs.time_column_name_weewx if t_max == None or t_min == None: t_max, t_min = get_first_time_interval() t_span = t_max - t_min if time_int == None: time_int = cs.time_int data_seconds = sql_con.get_data_ws(time_int=time_int, t_min=t_min, t_max=t_max) data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000 plot = Plot(x_range=DataRange1d(start=(t_min-t_span*.1)*1000, end=(t_max+t_span*.1)*1000), y_range=DataRange1d(), plot_width=plot_width, plot_height=plot_height, # x_axis_type="datetime", min_border_left=border_left, toolbar_location="right") add_glyphs_to_plot(column_names, column_time, data_seconds, plot,'source_weather') plot.add_layout(DatetimeAxis(name="date_time_axis"), 'below') plot.add_tools(PanTool(), WheelZoomTool(), # ResizeTool(), CrosshairTool(), PreviewSaveTool() ) Grid(plot=plot,dimension=0,ticker=plot.select('date_time_axis')[0].ticker) Grid(plot=plot, dimension=1, ticker=plot.select(type=LinearAxis,name=column_names[0])[0].ticker ) set_legends(plot) plot.title = cs.plot_title_weewx + ' averaged to {} seconds'.format(time_int) return plot
def save_graph(fol_path): df = folderstats.folderstats(fol_path, ignore_hidden=True) df.loc[list(np.where(df["folder"] == True)[0]), "name"] = df[df["folder"] == True]["path"].apply(ret_name).values # df["name"] = df["name"]+"."+df["extension"] df_sorted = df.sort_values(by='id') G = nx.Graph() for i, row in df_sorted.iterrows(): if row.parent: G.add_edge(row.id, row.parent) plot = Plot(plot_width=1000, plot_height=1000, x_range=Range1d(-1.1, 1.1), y_range=Range1d(-1.1, 1.1)) plot.title.text = "File System" plot.add_tools(TapTool(), BoxSelectTool(), BoxZoomTool(), ResetTool(), WheelZoomTool(), PanTool()) graph_renderer = from_networkx(G, nx.spring_layout, scale=2, center=(0, 0)) graph_renderer.node_renderer.data_source.data["id"] = df_sorted[ "id"].astype('str').values graph_renderer.node_renderer.data_source.data["name"] = df_sorted["name"] graph_renderer.node_renderer.data_source.data["links"] = df_sorted["path"] graph_renderer.node_renderer.data_source.add(Spectral8, 'color') graph_renderer.node_renderer.glyph = Circle(size=20, fill_color="color") graph_renderer.node_renderer.selection_glyph = Circle(size=20, fill_color="color") graph_renderer.node_renderer.hover_glyph = Circle(size=20, fill_color="color") graph_renderer.edge_renderer.glyph = MultiLine(line_color="#CCCCCC", line_alpha=0.8, line_width=5) graph_renderer.edge_renderer.selection_glyph = MultiLine( line_color=Spectral4[2], line_width=5) graph_renderer.edge_renderer.hover_glyph = MultiLine( line_color=Spectral4[1], line_width=5) graph_renderer.selection_policy = NodesAndLinkedEdges() graph_renderer.inspection_policy = EdgesAndLinkedNodes() pos = graph_renderer.layout_provider.graph_layout x, y = zip(*pos.values()) url = "@links" code = """ console.log(source.data) var data = source.data.file; var ind= cb_data.source.selected.indices; console.log(data[ind]) window.open(data[ind]) //window.location.href = data[ind] """ source = ColumnDataSource({ 'x': x, 'y': y, 'field': df_sorted["name"].values, 'file': df_sorted["path"].values }) labels = LabelSet(x='x', y='y', text='field', source=source) taptool = plot.select(type=TapTool) taptool.callback = CustomJS(args=dict(source=source), code=code) plot.renderers.append(graph_renderer) plot.renderers.append(labels) output_file("interactive_graphs.html") show(plot)