def histogram_plot(states, height, width, data_top, data_source, n_ticks, n_minor_ticks=0, fill_color=None): '''Create a bokeh histogram using quad shapes''' from bokeh.plotting import Figure # Create histogram object hist_obj = Figure(plot_height=height, plot_width=width, title="", toolbar_location=None) # Data top is string of var name from data_source fill_color = '#f0f5f5' if fill_color == None else fill_color hist_obj.quad(top=data_top, bottom=0, source=data_source, left="left", right="right", fill_color=fill_color, line_color='black') # set number of major and minor ticks hist_obj.xaxis[0].ticker.desired_num_ticks = n_ticks hist_obj.xaxis[0].ticker.num_minor_ticks = n_minor_ticks hist_obj.y_range = Range1d(0, 1) hist_obj.x_range = Range1d(states[0] - 0.5, states[-1] + 0.5) return hist_obj
def render_global_percent_resource_usage( figure: Figure, source: ColumnDataSource, report: ClusterReport, hostnames: List[str], ): node_count = len(hostnames) figure.y_range = Range1d(0, node_count + 1) figure.yaxis.axis_label = "Usage (%)" # Draw resource usage colors = select_colors(hostnames) figure.vbar_stack( hostnames, x="x_start", width=1000.0, color=colors, line_color="black", legend_label=[get_node_description(report, hostname) for hostname in hostnames], source=source, ) # Draw ceiling figure.line( source.data["x"], [node_count] * len(source.data["x"]), color="red", line_width=2, )
def render_bytes_sent_received( figure: Figure, df: pd.DataFrame, label: str, read_col: str, write_col: str ): time = df[DATETIME_KEY] def accumulate(column): values = df[column] values = values - values.min() return resample(values, time) read = accumulate(read_col) write = accumulate(write_col) data = ColumnDataSource( dict(rx=read, rx_kb=read / 1024, tx=write, tx_kb=write / 1024, x=read.index) ) tooltips = [("RX", "@rx_kb KiB"), ("TX", "@tx_kb KiB")] figure.add_tools(HoverTool(tooltips=tooltips)) figure.yaxis[0].formatter = NumeralTickFormatter(format="0.0b") y_max = max(max(data.data["rx"]), max(data.data["tx"])) figure.y_range = Range1d(0, y_max + 0.01) figure.line( x="x", y="rx", color="blue", legend_label="{} RX".format(label), source=data ) figure.line( x="x", y="tx", color="red", legend_label="{} TX".format(label), source=data )
def make_precipitation_plot(source): plot = Figure(x_axis_type="datetime", plot_width=1000, plot_height=125, min_border_left=50, min_border_right=50, min_border_top=0, min_border_bottom=0, toolbar_location=None) plot.title = None plot.quad(top='actual_precipitation', bottom=0, left='left', right='right', color=Greens4[1], source=source) # fixed attributes plot.border_fill_color = "whitesmoke" plot.yaxis.axis_label = "Precipitation (in)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.y_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def render_node_network_connections(figure: Figure, df: pd.DataFrame): connections_series = df[NETWORK_CONNECTIONS_KEY] connections = resample(connections_series, df[DATETIME_KEY]) figure.y_range = Range1d(0, connections_series.max() + 10) figure.add_tools(HoverTool(tooltips=[("Connection count", "@count")])) data = ColumnDataSource(dict(count=connections, x=connections.index)) figure.line(x="x", y="count", legend_label="Network connections", source=data)
def render_node_mem_pct_utilization(figure: Figure, df: pd.DataFrame): mem = resample(df[MEM_KEY], df[DATETIME_KEY]) figure.yaxis[0].formatter = NumeralTickFormatter(format="0 %") figure.y_range = Range1d(0, 1) figure.add_tools(HoverTool(tooltips=[("Memory", "@mem")])) data = ColumnDataSource(dict(mem=mem / 100.0, x=mem.index)) figure.line(x="x", y="mem", color="red", legend_label="Memory", source=data)
def createPlots(): ######################################## BS Pressure Plot ######################################## sourceBuySell, sourceVolume = requestHoseData() pBuySell = Figure(plot_width=PLOT_WIDTH, plot_height=BUYSELL_PLOT_HEIGHT, name="pltBuySell") pBuySell.xaxis.ticker = [8.75, 9, 9.5, 10, 10.5, 11, 11.5, 13, 13.5, 14, 14.5, 14.75] pBuySell.xaxis.major_label_overrides = { 8.5: "8:30", 8.75: "8:45", 9: "9:00", 9.5: "9:30", 10: "10:00", 10.5: "10:30", 11: "11:00", 11.5: "11:30", 13: "13:00", 13.5: "13:30", 14: "14:00", 14.5: "14:30", 14.75: "14:45"} pBuySell.line(x='index', y='buyPressure', source=sourceBuySell, color='green', legend_label="Tổng đặt mua", name="glyphSellPressure") pBuySell.line(x='index', y='sellPressure', source=sourceBuySell, color='red', legend_label="Tổng đặt bán", name="glyphBuyPressure") wz = WheelZoomTool(dimensions="width"); pBuySell.add_tools(wz); pBuySell.toolbar.active_scroll = wz pBuySell.toolbar.logo = None pBuySell.axis[0].visible = False pBuySell.legend.location = "top_left" pBuySell.legend.click_policy = "hide" pBuySell.legend.background_fill_alpha = 0.0 ######################################## Volume Plot ######################################## pVolume = Figure(width=PLOT_WIDTH, height=VOLUME_PLOT_HEIGHT, tools="pan, reset", name="pltVolume") pVolume.toolbar.logo = None wz = WheelZoomTool(dimensions="height"); pVolume.add_tools(wz); pVolume.toolbar.active_scroll = wz pVolume.vbar(x='index', top='totalValue', width=1 /60, color='blue', source=sourceVolume, fill_alpha=LIQUIDITY_ALPHA, line_alpha=LIQUIDITY_ALPHA, name="glyphTotalValue", legend_label="Thanh khoản toàn tt") pVolume.vbar(x='index', top='nnBuy', width=1/1.2/60, color='green', source=sourceVolume ,name="glyphNNBuy", legend_label="NN mua",) pVolume.vbar(x='index', top='nnSell', width=1/1.2/60, color='red', source=sourceVolume ,name="glyphNNSell", legend_label="NN bán",) pVolume.x_range = pBuySell.x_range pVolume.y_range=Range1d(-10, 45) pVolume.legend.location = "top_left" pVolume.legend.click_policy = "hide" pVolume.legend.background_fill_alpha = 0.0 ######################################### OHLC plot ######################################### orders, source, pressure = requestPSData() plotOhlc = createOhlcPlot(source) pCandle, divCandle = hookupFigure(plotOhlc) # "divCustomJS" "pltOHLC" "glyphOHLCSegment" pDebug = Paragraph(text=f"""["num_ps_orders": "{len(orders['index'])}"]\n""" """""", width=DIV_TEXT_WIDTH, height=100, name="pDebug") ################################# Putting all plots together ################################ def activation_function(): pBuySell._document.add_periodic_callback(lambda: updateDoc(pBuySell._document), 500) print("Document activated !") return pCandle, pBuySell, pVolume, divCandle , activation_function, sourceBuySell, sourceVolume, pDebug
def make_plot(): plot = Figure( plot_height=400, plot_width=800, responsive=True, tools="xpan,xwheel_zoom,xbox_zoom,reset", x_axis_type='datetime' ) plot.x_range.follow = "end" plot.x_range.follow_interval = 120 * 24 * 60 * 60 * 1000 plot.x_range.range_padding = 0 plot.y_range = Range1d(0, 12) return plot
def render_node_per_cpu_pct_utilization(figure: Figure, df: pd.DataFrame): time = df[DATETIME_KEY] cpu_series = df[CPU_KEY] cpu_count = len(cpu_series.iloc[0]) cpus = [ resample(cpu_series.apply(lambda res: res[i]), time) for i in range(cpu_count) ] cpu_mean = resample(cpu_series.apply(lambda res: average(res)), time) figure.yaxis[0].formatter = NumeralTickFormatter(format="0 %") figure.y_range = Range1d(0, 1) data = {} tooltips = [] for (i, cpu) in enumerate(cpus): key = f"cpu_{i}" data[key] = cpu / 100.0 data[f"{key}_x"] = cpu.index tooltips.append((f"CPU #{i}", f"@{key}")) data["cpu_mean"] = cpu_mean / 100.0 data["cpu_mean_x"] = cpu_mean.index tooltips.append(("CPU avg.", "@cpu_mean")) figure.add_tools(HoverTool(tooltips=tooltips)) data = ColumnDataSource(data) colors = select_colors(cpus) for (i, color) in enumerate(colors): figure.line( x=f"cpu_{i}_x", y=f"cpu_{i}", color=color, legend_label=f"CPU #{i}", source=data, ) figure.line( x="cpu_mean_x", y="cpu_mean", color="red", legend_label="Average CPU", line_dash="dashed", line_width=5, source=data, )
def utilization_bar(max_y): plot = Figure( plot_width= 150, # this is more for the ratio, because we have auto-width scaling plot_height=150, tools=[], # no tools needed for this one title='Utilization') plot.toolbar.logo = None # hides logo plot.x_range = Range1d(0, 1) plot.y_range = Range1d( 0, max_y) # sometimes you want it to be way less than 1, to see it move plot.xaxis.visible = False # hide x axis # Add input buffer manager = Manager() plot._input_buffer = manager.dict() return plot
def histogram_plot(states, height, width, data_top, data_source, n_ticks, n_minor_ticks=0, fill_color=None): '''Create a bokeh histogram using quad shapes''' from bokeh.plotting import Figure # Create histogram object hist_obj = Figure(plot_height=height, plot_width=width, title="", toolbar_location=None) # Data top is string of var name from data_source fill_color = '#f0f5f5' if fill_color==None else fill_color hist_obj.quad(top=data_top, bottom=0, source=data_source, left="left", right="right", fill_color=fill_color, line_color='black') # set number of major and minor ticks hist_obj.xaxis[0].ticker.desired_num_ticks = n_ticks hist_obj.xaxis[0].ticker.num_minor_ticks = n_minor_ticks hist_obj.y_range = Range1d(0, 1) hist_obj.x_range = Range1d(states[0]-0.5, states[-1]+0.5) return hist_obj
def make_plot(): plot = Figure( plot_height=400, plot_width=800, responsive=True, tools="xpan,xwheel_zoom,xbox_zoom,reset", x_axis_type='datetime', min_border_top=10, min_border_right=0, min_border_bottom=0, min_border_left=30, outline_line_color=None, ) plot.x_range.follow = "end" plot.x_range.follow_interval = 120 * 24 * 60 * 60 * 1000 plot.x_range.range_padding = 0 plot.y_range = Range1d(0, 12) plot.xgrid.grid_line_color = None plot.ygrid.grid_line_color = None plot.yaxis.bounds = (0, 9) plot.yaxis.minor_tick_line_color = None plot.yaxis.ticker = FixedTicker(ticks=[0, 3, 6, 9]) return plot
grate5=ColumnDataSource(dict(x=londf.values[:,0]-kgx,y=londf.values[:,2])) grate6=ColumnDataSource(dict(x=londf.values[:,0]+kgx,y=londf.values[:,2])) grate7=ColumnDataSource(dict(x=londf.values[:,0],y=londf.values[:,2]+kgy)) grate8=ColumnDataSource(dict(x=londf.values[:,0],y=londf.values[:,2]-kgy)) p.line(x='x',y='y',source=grate1, color="red",line_width=5) p.line(x='x',y='y',source=grate2, color="red",line_width=5) p.line(x='x',y='y',source=grate3, color="red",line_width=5) p.line(x='x',y='y',source=grate4, color="red",line_width=5) p.line(x='x',y='y',source=grate5, color="red",line_width=5) p.line(x='x',y='y',source=grate6, color="red",line_width=5) p.line(x='x',y='y',source=grate7, color="red",line_width=5) p.line(x='x',y='y',source=grate8, color="red",line_width=5) p.x_range=Range1d(-1 , 1) p.y_range=Range1d(-1 , 1) def update(): tilt=float(tiltin.value)*np.pi/180 wl=2.997e4/float(freqin.value) wlout.text='Wavelength = '+str(wl)+' cm' kgy=wl/float(dyin.value) if lattice.value=='Triangular': kgx=2*wl/float(dxin.value) kmult=0.5 else: kgx=wl/float(dxin.value) kmult=1 kgxout.text='kgx = '+str(kgx) kgyout.text='kgy = '+str(kgy)
line_width=0) p1.patch([0.003, 0.04, 0.04, 0.003, 0.003], [100, 100, 30000., 30000., 10000.], alpha=0.6, fill_color='lightblue', line_width=0) p1.patch([3, 3000, 3000, 30, 3], [300, 300, 30000., 30000., 300.], alpha=0.6, fill_color='purple', line_width=0) p1.yaxis.axis_label = 'Planet Mass / Earth' p1.xaxis.axis_label = 'Semi-major Axis / Snow Line' p1.xaxis.axis_label_text_font_style = 'bold' p1.yaxis.axis_label_text_font_style = 'bold' p1.xaxis[0].formatter = NumeralTickFormatter(format="0.00") p1.x_range = Range1d(0.003, 3000, bounds=(0.003, 3000)) p1.y_range = Range1d(0.01, 30000, bounds=(0.01, 30000)) techniques = [ 'RV', 'Space Transits', 'Ground Transits', 'Microlensing', 'Direct Imaging' ] checkbox_button_group = CheckboxGroup( labels=["RV", "Transits", "Microlensing", "Direct Imaging"], active=[0, 1, 2, 3]) # transits - ground tground = Table.read( '/Users/tumlinson/Dropbox/LUVOIR_STDT/luvoir_simtools/planetspace/transit_ground.dat', format='ascii', names=['name', 'msini', 'semi', 'mstar']) a_rad = 2.7 * tground['mstar']
orig_ztf_r = ColumnDataSource(data=dict(x=ztf_rmjd, y=ztf_rmag, lower=ztf_rlow, upper=ztf_rupp)) orig_lco_g = ColumnDataSource(data=dict(x=lco_gmjd, y=lco_gmag, lower=lco_glow, upper=lco_gupp)) orig_lco_r = ColumnDataSource(data=dict(x=lco_rmjd, y=lco_rmag, lower=lco_rlow, upper=lco_rupp)) # Initialize Light Curve Plot fig_lc = Figure(plot_height=320, plot_width=750,sizing_mode='scale_both', tools="pan,wheel_zoom,box_zoom,tap,reset", toolbar_location="above", border_fill_color="whitesmoke") fig_lc.toolbar.logo = None fig_lc.yaxis.axis_label = 'Mag' fig_lc.xaxis.axis_label = 'MJD' fig_lc.y_range = Range1d(start=yupp, end=ylow) # Choose plotting colors c_ztfg = "cornflowerblue" c_ztfr = "firebrick" c_lcog = "forestgreen" c_lcor = "darkorange" # Choose plotting alphas a_ztfg = 1.0 a_ztfr = 1.0 a_lcog = 1.0 a_lcor = 1.0
return results ######################################################################## # Construct basic plot architecture results = DataFrame({'day': 1, 'S': 0, 'N': 0, 'O': 0, 'V': 1e9, 'Z': 5.}, dtype=float, index=get_timestep_index()) source = ColumnDataSource(results) # Create a new plot and add a renderer top = Figure(tools=tools, title=None, x_range=day_range, **figure_style_kws) top.line('day', 'S', source=source, line_color=colors[0], line_width=3, line_cap='round') top.y_range = Range1d(0., 40.) top.yaxis.axis_label = "Salinity (g/kg)" top.xaxis.axis_label_text_font_size = label_fontsize top.yaxis.axis_label_text_font_size = label_fontsize # overlay volume level chart to salinity tc = "MediumBlue" # tide color tide_range = Range1d(start=0, end=15) tide_axis = LinearAxis(y_range_name="Z") tide_axis.axis_label = "Tidal Height (m)" tide_axis.axis_label_text_color = tc tide_axis.axis_label_text_font_size = label_fontsize tide_axis.major_tick_line_color = tc tide_axis.major_label_text_color = tc tide_axis.minor_tick_line_alpha = 0.
box_select = BoxSelectTool() plot1 = Figure(plot_height=500, plot_width=770, x_axis_type=None, y_axis_type=None, tools=["pan,reset,tap,wheel_zoom,save", box_select], x_range=[-75, 75], y_range=[-50, 50], toolbar_location='left') plot1.image_url(url=["http://luvoir.stsci.edu/M83.jpeg"], x=[-75], y=[50], w=150, h=100) plot1.x_range = Range1d(-75, 75, bounds=(-75, 75)) plot1.y_range = Range1d(-50, 50, bounds=(-50, 50)) shutters = plot1.square('x', 'y', source=shutter_positions, fill_color='yellow', fill_alpha=0.2, line_color=None, size=20, name="my_shutters") shutters.selection_glyph = Square(fill_alpha=0.5, fill_color="green", line_color='green', line_width=3) shutters.nonselection_glyph = Square(fill_alpha=0.2, fill_color="yellow", line_color=None)
# initialize the plot data update_source_data(True) # make the plot responsive to slider changes standard_deviation_slider.on_change( 'value', lambda attr, old_value, new_value: update_source_data(True)) cutoff_slider.on_change( 'value', lambda attr, old_value, new_value: update_source_data(False)) # create the figure p = Figure(title='Normal Distribution') p.scatter(source=source, x='x', y='y', color='green', alpha='alpha', radius=0.1) p.x_range = Range1d(start=-8, end=8) p.y_range = Range1d(start=-8, end=8) content = column(standard_deviation_slider, cutoff_slider, p) # register the figure curdoc().add_root(content) curdoc().title = 'Normal Distribution'
alpha_p0=alpha_P0, alpha_p1=alpha_P1, alpha_p2=alpha_P2, beta_p0=beta_P0, beta_p1=beta_P1, beta_p2=beta_P2, sarah_p0=sarah_P0, sarah_p1=sarah_P1, sarah_p2=sarah_P2)) p = Figure(tools='', toolbar_location=None, height=800, width=850) p.grid.grid_line_color = None p.axis.visible = False p.grid.grid_line_color = None p.axis.visible = False p.y_range = Range1d(-.25, 1.35) p.x_range = Range1d(-.15, 1.55) # plot simplex left_corner = [0.0, 0.0] right_corner = [np.sqrt(2), 0.0] top_corner = [np.sqrt(2) / 2.0, np.sqrt(6) / 2.0] p.line([left_corner[0], top_corner[0]], [left_corner[1], top_corner[1]], color='black', line_width=2) p.line([right_corner[0], top_corner[0]], [right_corner[1], top_corner[1]], color='black', line_width=2) p.line([left_corner[0], right_corner[0]], [left_corner[1], right_corner[1]], color='black',
def construct_total_pnl_figure(self, x, y, t): str_total_pnl = "Total Pnl " + POUND_SYMBOL # workaround to format date in the hover tool at the moment bokeh does not supported in the tool tips time = [e.strftime('%d %b %Y') for e in x] source_total_pnl = ColumnDataSource(data=dict(x=x, y=y, time=time)) tooltips_total_pnl = [ ("Date", "@time"), ("Total Pnl", "@y{0.00}"), ] tooltips_capital = [ ("Date", "@time"), ("Capital", "@y{0.00}"), ] # create a new pnl plot p2 = Figure(x_axis_type="datetime", title="Total Pnl/Capital Allocated " + POUND_SYMBOL, toolbar_location="above", tools=['box_zoom, box_select, crosshair, resize, reset, save, wheel_zoom']) # add renderers r1 = p2.circle(x, y, size=8, color='black', alpha=0.2, legend=str_total_pnl, source=source_total_pnl) r11 = p2.line(x, y, color='navy', legend=str_total_pnl, source=source_total_pnl) # add renderers to the HoverTool instead of to the figure so we can have different tooltips for each glyph p2.add_tools(HoverTool(renderers=[r1, r11], tooltips=tooltips_total_pnl)) max_total_pnl = max(y) min_total_pnl = min(y) # offset to adjust the plot so the max and min ranges are visible offset = (max(abs(max_total_pnl), abs(min_total_pnl))) * 0.10 p2.y_range = Range1d(min_total_pnl - offset, max_total_pnl + offset) # NEW: customize by setting attributes # p2.title = "Total Pnl/Capital Allocated " + POUND_SYMBOL p2.legend.location = "top_left" p2.grid.grid_line_alpha = 0 p2.xaxis.axis_label = 'Date' p2.yaxis.axis_label = str_total_pnl p2.ygrid.band_fill_color = "olive" p2.ygrid.band_fill_alpha = 0.1 p2.xaxis.formatter = DatetimeTickFormatter(formats={'days': ['%d %b'], 'months': ['%b %Y']}) # formatter without exponential notation p2.yaxis.formatter = PrintfTickFormatter(format="%.0f") # secondary axis max_capital = max(t) min_capital = min(t) # offset to adjust the plot so the max and min ranges are visible offset = (max(abs(max_capital), abs(min_capital))) * 0.10 p2.extra_y_ranges = {"capital": Range1d(start=min_capital - offset, end=max_capital + offset)} # formatter without exponential notation formatter = PrintfTickFormatter() formatter.format = "%.0f" # formatter=NumeralTickFormatter(format="0,0")) p2.add_layout(LinearAxis(y_range_name="capital", axis_label="Capital allocated " + POUND_SYMBOL, formatter=formatter), 'right') # create plot for capital series source_capital = ColumnDataSource(data=dict(x=x, t=t, time=time)) r2 = p2.square(x, t, size=8, color='green', alpha=0.2, legend="Capital " + POUND_SYMBOL, y_range_name="capital", source=source_capital) r22 = p2.line(x, t, color='green', legend="Capital " + POUND_SYMBOL, y_range_name="capital", source=source_capital) # add renderers to the HoverTool instead of to the figure so we can have different tooltips for each glyph p2.add_tools(HoverTool(renderers=[r2, r22], tooltips=tooltips_capital)) return p2
signal_to_noise = simulate_exposure(luvoir, lumos, spec_dict[template_to_start_with].wave, spec_dict[template_to_start_with].flux, 1.0) flux_cut = spec_dict[template_to_start_with].flux flux_cut[spec_dict[template_to_start_with].wave < lumos.lambda_range[0]] = -999. flux_cut[spec_dict[template_to_start_with].wave > lumos.lambda_range[0]] = -999. spectrum_template = ColumnDataSource(data=dict(w=spec_dict[template_to_start_with].wave, f=spec_dict[template_to_start_with].flux, \ w0=spec_dict[template_to_start_with].wave, f0=spec_dict[template_to_start_with].flux, \ flux_cut=flux_cut, sn=signal_to_noise)) # set up the flux plot flux_plot = Figure(plot_height=400, plot_width=800, tools="crosshair,hover,pan,reset,resize,save,box_zoom,wheel_zoom", outline_line_color='black', x_range=[900, 2000], y_range=[0, 4e-16], toolbar_location='right') flux_plot.x_range=Range1d(900,2000,bounds=(900,2000)) flux_plot.y_range=Range1d(0,4e-16,bounds=(0,None)) flux_plot.background_fill_color = "beige" flux_plot.background_fill_alpha = 0.5 flux_plot.yaxis.axis_label = 'Flux' flux_plot.xaxis.axis_label = 'Wavelength' flux_plot.line('w', 'f', source=spectrum_template, line_width=3, line_color='firebrick', line_alpha=0.7, legend='Source Flux') flux_plot.line(lumos.wave, lumos.bef, line_width=3, line_color='darksalmon', line_alpha=0.7, legend='Background') # set up the flux plot sn_plot = Figure(plot_height=400, plot_width=800, tools="crosshair,hover,pan,reset,resize,save,box_zoom,wheel_zoom", outline_line_color='black', x_range=[900, 2000], y_range=[0, 40], toolbar_location='right') sn_plot.x_range=Range1d(900,2000,bounds=(900,2000))
# Calculate 1-sigma errors sig= Cratio/SNR # Add gaussian noise to flux ratio spec = Cratio + np.random.randn(len(Cratio))*sig planet = ColumnDataSource(data=dict(lam=lam, cratio=Cratio*1e9, spec=spec*1e9, downerr=(spec-sig)*1e9, uperr=(spec+sig)*1e9)) ################################ # BOKEH PLOTTING ################################ snr_plot = Figure(plot_height=400, plot_width=750, tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[0.3, 2.7], y_range=[0, 1], toolbar_location='right') snr_plot.x_range = Range1d(0.3, 2.7, bounds=(0.3, 2.7)) snr_plot.y_range = Range1d(0.0, 1.2, bounds=(0.3, 5.0)) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label='F_p/F_s (x10^9)' snr_plot.xaxis.axis_label='Wavelength [micron]' snr_plot.line('lam','cratio',source=planet,line_width=2.0, color="green", alpha=0.7) snr_plot.circle('lam', 'spec', source=planet, fill_color='red', line_color='black', size=8) snr_plot.segment('lam', 'downerr', 'lam', 'uperr', source=planet, line_width=1, line_color='grey', line_alpha=0.5) def change_filename(attrname, old, new): format_button_group.active = None instruction0 = Div(text="""Choose a file rootname here (no special characters):""", width=300, height=15)
# tags [debut, fin, pas, timer (en microseconde), type = "add, mul"] anim=[1, 40, 1, 300, "add", 1] # dessin p = Figure(x_range = especes, title="Evolution", plot_width=800, plot_height=500,toolbar_location = None) p.title.text_font_size = "25px" p.xaxis[0].axis_label = 'Espèces' if data['unite'] == 1: p.yaxis[0].axis_label = 'Quantités (mol)' else: p.yaxis[0].axis_label = 'Masses (g)' # Calcul longueur axe max = max(max(quantites), max(reste))*1.2 p.y_range = Range1d(start=0, end=max) # définition de la source source = [ColumnDataSource(data=dict(x=data_x[i], top=data_top[i], grow = data_grow[i])) for i in range(len(especes))] for i in range(len(especes)): p.vbar(x='x', top='top', width = width, bottom = bottom, color = color[i], source = source[i], legend_label = labels[i]) p.legend.orientation = "horizontal" p.legend.location = "top_center" p.legend.click_policy = "hide" p.legend.glyph_width = 60 # création du bouton bt = Button(label = "Lance", id = '1', button_type = "success")
# définition de la source source = ColumnDataSource( data=dict(x=data_x, top=data_top, color=color, grow=data_grow)) # dessin p = Figure(title="graph bar", x_range=data_x, y_range=(0, 100), plot_height=400, toolbar_location=None) p.title.text_font_size = "25px" p.yaxis[0].axis_label = 'Quantité' p.xaxis[0].axis_label = 'Espèces' p.y_range = Range1d(start=0, end=100) p.vbar(x='x', top='top', width=width, bottom=bottom, color='color', source=source, legend_field='x') p.legend.orientation = "horizontal" p.legend.location = "top_center" # création du bouton bt = Button(label="Lance", button_type="success") # fonction de callback
spec=spec * 1e9, downerr=(spec - sig) * 1e9, uperr=(spec + sig) * 1e9)) ################################ # BOKEH PLOTTING ################################ snr_plot = Figure(plot_height=400, plot_width=750, tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[0.3, 2.7], y_range=[0, 1], toolbar_location='right') snr_plot.x_range = Range1d(0.3, 2.7, bounds=(0.3, 2.7)) snr_plot.y_range = Range1d(0.0, 1.2, bounds=(0.3, 5.0)) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label = 'F_p/F_s (x10^9)' snr_plot.xaxis.axis_label = 'Wavelength [micron]' snr_plot.line('lam', 'cratio', source=planet, line_width=2.0, color="green", alpha=0.7) snr_plot.circle('lam', 'spec', source=planet, fill_color='red',