def interactive_plot(c4, c46, c6, c9, ts): from bokeh.layouts import gridplot from bokeh.plotting import figure, show, output_file from bokeh.models import Range1d, LinearAxis, LogAxis x = np.linspace(0, 4 * np.pi, 100) y = np.sin(x) TOOLS = "pan,wheel_zoom,box_zoom,reset,save,box_select" p1 = figure(title="Legend Example", tools=TOOLS, plot_width=1200, plot_height=400, y_axis_type="log", x_axis_type='datetime' ) p2 = figure(title="Legend Example", tools=TOOLS, plot_width=1200, plot_height=400, y_axis_type="linear", x_axis_type='datetime', x_range=p1.x_range ) # Setting the second y axis range name and range p1.extra_y_ranges = {"foo": Range1d(*ts[c9].quantile([.01, .99]))} # Adding the second axis to the plot. p1.add_layout(LogAxis(y_range_name="foo"), 'right') p1.line('time_utc', c4, legend_label=c4, source=ts, color='black') p1.line('time_utc', c6, legend_label=c6, source=ts, color='blue') p1.line('time_utc', c9, legend_label=c9, source=ts, color='red', y_range_name="foo" ) p2.line('time_utc', c46, legend_label=c4, source=ts, color='black' ) # p1.circle(x, 2 * y, legend_label="2*sin(x)", color="orange") # p1.circle(x, 3 * y, legend_label="3*sin(x)", color="green") # # p1.legend.title = 'Example Title' # # p2 = figure(title="Another Legend Example", tools=TOOLS) # # p2.circle(x, y, legend_label="sin(x)") # p2.line(x, y, legend_label="sin(x)") # # p2.line(x, 2 * y, legend_label="2*sin(x)", line_dash=(4, 4), # line_color="orange", line_width=2) # # p2.square(x, 3 * y, legend_label="3*sin(x)", fill_color=None, # line_color="green") # p2.line(x, 3 * y, legend_label="3*sin(x)", line_color="green") output_file("legend.html", title="legend.py example") show(gridplot([p1, p2], ncols=1, ))
def large_plot(): source = ColumnDataSource(data=dict(x=[0, 1], y=[0, 1])) xdr = Range1d(start=0, end=1) xdr.tags.append("foo") xdr.tags.append("bar") ydr = Range1d(start=10, end=20) ydr.tags.append("foo") ydr.tags.append(11) plot = Plot(x_range=xdr, y_range=ydr) ydr2 = Range1d(start=0, end=100) plot.extra_y_ranges = {"liny": ydr2} circle = Circle(x="x", y="y", fill_color="red", size=5, line_color="black") plot.add_glyph(source, circle, name="mycircle") line = Line(x="x", y="y") plot.add_glyph(source, line, name="myline") rect = Rect(x="x", y="y", width=1, height=1, fill_color="green") plot.add_glyph(source, rect, name="myrect") plot.add_layout(DatetimeAxis(), 'below') plot.add_layout(LogAxis(), 'left') plot.add_layout(LinearAxis(y_range_name="liny"), 'left') plot.add_layout(Grid(dimension=0), 'left') plot.add_layout(Grid(dimension=1), 'left') plot.add_tools( BoxZoomTool(), PanTool(), SaveTool(), ResetTool(), ResizeTool(), WheelZoomTool(), ) return plot
def test_rect_rendering_with_log_axis(output_file_url, selenium, screenshot): plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 30), y_range=Range1d(1, 100), y_axis_type="log") x = [10, 20] y = [10, 20] source = ColumnDataSource(data=dict(x=[(x[0] + x[1]) / 2], y=[(y[0] + y[1]) / 2], width=[x[1] - x[0]], height=[y[1] - y[0]])) plot.add_glyph(source, Rect(x='x', y='y', width='width', height='height')) plot.add_layout(LogAxis(), "left") # Save the plot and start the test save(plot) selenium.get(output_file_url) assert has_no_console_errors(selenium) screenshot.assert_is_valid()
def create_bk_fig(x=None, xlab=None, x_min=None, x_max=None, ylab=None, fh=None, fw=None, title=None, pw=None, ph=None, x_axis_type="linear", y_axis_type="linear", x_name=None, y_name=None, **kwargs): """ Generates a bokeh figure Parameters ---------- x :obj:`DataArray` Contains x-axis data xlab : :obj:`str` X-axis label x_min : :obj:`float` Min x value x_max : :obj:`float` Max x value ylab : :obj:`str` Y-axis label fh: :obj:`int` True height of figure without legends, axes titles etc fw: :obj:`int` True width of figure without legends, axes etc title: :obj:`str` Title of plot pw: :obj:`int` Plot width including legends, axes etc ph: :obj:`int` Plot height including legends, axes etc x_axis_type: :obj:`str` Type of x-axis can be linear, log, or datetime y_axis_type: :obj:`str` Can be linear, log or datetime x_name: :obj:`str` Name of the column used for the x-axis. Mostly used to form tooltips y_name: :obj:`str` Name of the column used for the y-axis. Also used for tooltips add_grid: :obj:`bool` Whether or not to add grid add_title: :obj:`bool` Whether or not to add title to plot add_xaxis: :obj:`bool` Whether or not to add x-axis and tick marks add_yaxis: :obj:`bool` Add y-axis or not fix_plotsize: :obj:`bool` Enforce certain dimensions on plot. This is useful for ensuring a plot is not obscure by axes and other things. If activated, plot's dimensions will not be responsive. It utilises fw and fh. Returns ------- p : :obj:`Plot` A bokeh Plot object """ add_grid = kwargs.pop("add_grid", False) add_title = kwargs.pop("add_title", True) add_xaxis = kwargs.pop("add_xaxis", False) add_yaxis = kwargs.pop("add_yaxis", False) fix_plotsize = kwargs.pop("fix_plotsize", True) # addition plot specs pl_specs = kwargs.pop("pl_specs", {}) # additional axis specs ax_specs = kwargs.pop("ax_specs", {}) # ticker specs ti_specs = kwargs.pop("ti_specs", {}) plot_specs = dict(background="white", border_fill_alpha=0.1, border_fill_color="white", min_border=3, name="plot", outline_line_dash="solid", outline_line_width=2, outline_line_color="#017afe", outline_line_alpha=0.4, output_backend="canvas", sizing_mode="stretch_width", title_location="above", toolbar_location="above") plot_specs.update(pl_specs) axis_specs = dict(minor_tick_line_alpha=0, axis_label_text_align="center", axis_label_text_font="monospace", axis_label_text_font_size="10px", axis_label_text_font_style="normal", major_label_orientation="horizontal") axis_specs.update(ax_specs) tick_specs = dict(desired_num_ticks=5) tick_specs.update(ti_specs) # Define frame width and height # This is the actual size of the plot without the titles et al if fix_plotsize and not(fh or fw): fw = int(0.98 * pw) fh = int(0.93 * ph) # define the axes ranges x_range = DataRange1d(name="p_x_range", only_visible=True) y_range = DataRange1d(name="p_y_range", only_visible=True) if x_min is not None and x_max is not None and x_name.lower() in ["channel", "frequency"]: x_range = Range1d(name="p_x_range", start=x_min, end=x_max) y_range.only_visible = False # define items to add on the plot p_htool = HoverTool(tooltips=[(x_name, "$x"), (y_name, "$y")], name="p_htool", point_policy="snap_to_data") if x_name.lower() == "time": p_htool.tooltips[0] = (x_name, "$x{%d-%m-%Y %H:%M}") p_htool.formatters = {"$x": "datetime"} p_toolbar = Toolbar(name="p_toolbar", tools=[p_htool, BoxSelectTool(), BoxZoomTool(), # EditTool(), # BoxEditTool(), # RangeTool(), LassoSelectTool(), PanTool(), ResetTool(), SaveTool(), UndoTool(), WheelZoomTool()]) p_ticker = BasicTicker(name="p_ticker", **tick_specs) # select the axis scales for x and y if x_axis_type == "linear": x_scale = LinearScale(name="p_x_scale") # define the axes and tickers p_x_axis = LinearAxis(axis_label=xlab, name="p_x_axis", ticker=p_ticker, **axis_specs) elif x_axis_type == "datetime": x_scale = LinearScale(name="p_x_scale") # define the axes and tickers p_x_axis = DatetimeAxis(axis_label=xlab, name="p_x_axis", ticker=p_ticker, **axis_specs) elif x_axis_type == "log": x_scale = LogScale(name="p_x_scale") p_x_axis = LogAxis(axis_label=xlab, name="p_x_axis", ticker=p_ticker, **axis_specs) if y_axis_type == "linear": y_scale = LinearScale(name="p_y_scale") # define the axes and tickers p_y_axis = LinearAxis(axis_label=ylab, name="p_y_axis", ticker=p_ticker, **axis_specs) elif x_axis_type == "datetime": y_scale = LinearScale(name="p_y_scale") # define the axes and tickers p_y_axis = DatetimeAxis(axis_label=xlab, name="p_y_axis", ticker=p_ticker, **axis_specs) elif y_axis_type == "log": y_scale = LogScale(name="p_y_scale") # define the axes and tickers p_y_axis = LogAxis(axis_label=ylab, name="p_y_axis", ticker=p_ticker, **axis_specs) # Create the plot object p = Plot(plot_width=pw, plot_height=ph, frame_height=fh, frame_width=fw, toolbar=p_toolbar, x_range=x_range, x_scale=x_scale, y_range=y_range, y_scale=y_scale, **plot_specs) if add_title: p_title = Title(align="center", name="p_title", text=title, text_font_size="24px", text_font="monospace", text_font_style="bold",) p.add_layout(p_title, "above") if add_xaxis: p.add_layout(p_x_axis, "below") if add_yaxis: p.add_layout(p_y_axis, "left") if add_grid: p_x_grid = Grid(dimension=0, ticker=p_ticker) p_y_grid = Grid(dimension=1, ticker=p_ticker) p.add_layout(p_x_grid) p.add_layout(p_y_grid) return p
rb_patches_list.append(rb_patches) # Hide yaxis if i_ppr != 0: temp_plot.yaxis.visible = False temp_plot2.yaxis.visible = False temp_plot3.yaxis.visible = False # Hide xaxis if i_pfd != 2: temp_plot.xaxis.visible = False temp_plot2.xaxis.visible = False temp_plot3.xaxis.visible = False # Add Row labels on right if i_ppr == 2: temp_plot.add_layout( LogAxis(axis_label=pfd_type, axis_label_text_font_style='bold', ticker=raw_ticker), 'right') temp_plot2.add_layout( LogAxis(axis_label=pfd_type, axis_label_text_font_style='bold', ticker=rel_ticker), 'right') temp_plot3.add_layout( LogAxis(axis_label=pfd_type, axis_label_text_font_style='bold', ticker=rel_ticker), 'right') # Add Col labels on top if i_pfd == 0: temp_plot.title.text = ppr_type temp_plot.title.align = 'center' temp_plot2.title.text = ppr_type temp_plot2.title.align = 'center'
from bokeh.io import save from bokeh.models import ColumnDataSource, LogAxis, Plot, Range1d, Rect plot = Plot(height=400, width=400, x_range=Range1d(0, 30), y_range=Range1d(1, 100)) [x0, x1] = [10, 20] [y0, y1] = [10, 20] source = ColumnDataSource(data=dict( x=[(x0 + x1) / 2], y=[(y0 + y1) / 2], width=[x1 - x0], height=[y1 - y0])) plot.add_glyph(source, Rect(x='x', y='y', width='width', height='height')) plot.add_layout(LogAxis(), "left") save(plot)
def create_plots(state, oil_prod, unemp, lab_force): target_state = (state) state_dict = {'tx': 'Texas', 'nd': 'North Dakota', 'wy': 'Wyoming'} min_date = max(min(unemp.index), min(oil_prod.index)) max_date = min(max(unemp.index), max(oil_prod.index)) cur_sp500 = sp500.loc[min_date:max_date] source_sp500 = ColumnDataSource(cur_sp500) cur_oil_price = oil_price.loc[min_date:max_date] source_oil_price = ColumnDataSource(cur_oil_price) oil_prod = oil_prod.loc[min_date:max_date] unemp = unemp.loc[min_date:max_date] lab_force = lab_force.loc[min_date:max_date] county_xs = [ counties[code]["lons"] for code in counties if counties[code]["state"] in target_state ] county_ys = [ counties[code]["lats"] for code in counties if counties[code]["state"] in target_state ] county_names = unemp.columns county_rates = unemp.loc[cur_date].values[0] county_prods = oil_prod.loc[cur_date].values[0] TOOLS = "pan,wheel_zoom,box_zoom,reset,hover,save,tap" source_maps = ColumnDataSource(data=dict(x=county_xs, y=county_ys, name=county_names, rate=county_rates, prod=county_prods)) unemp_color_mapper = LogColorMapper(palette="Viridis256", low=max(min(county_rates), 0.1), high=max(county_rates)) fig_unemp = figure(title='%s unemployment rate for %s, %d' % (state_dict[state], month_dict[cur_month], cur_year), toolbar_location="left", tools=TOOLS, plot_width=500, plot_height=450) pyglyph = fig_unemp.patches( 'x', 'y', source=source_maps, fill_color={ 'field': 'rate', 'transform': unemp_color_mapper }, fill_alpha=0.7, line_color="white", line_width=0.5, # set visual properties for selected glyphs selection_color="firebrick", # set visual properties for non-selected glyphs nonselection_fill_alpha=0.2, nonselection_fill_color="blue", nonselection_line_color="firebrick", nonselection_line_alpha=1.0) hover_unemp = fig_unemp.select(HoverTool) hover_unemp.point_policy = "follow_mouse" hover_unemp.tooltips = [ ("Name", "@name"), ("Unemployment rate", "@rate%"), ("(Long, Lat)", "($x, $y)"), ] unemp_color_bar = ColorBar(color_mapper=unemp_color_mapper, ticker=LogTicker(), border_line_color=None, location=(0, 0)) fig_unemp.add_layout(unemp_color_bar, 'right') prod_color_mapper = LogColorMapper(palette="BuGn7", low=max(min(county_prods), 0.1), high=max(county_prods)) fig_prods = figure(title='%s production data for %s, %d' % (state_dict[state], month_dict[cur_month], cur_year), toolbar_location="left", tools=TOOLS, plot_width=500, plot_height=450) pyglyph_prod = fig_prods.patches( 'x', 'y', source=source_maps, fill_color={ 'field': 'prod', 'transform': prod_color_mapper }, fill_alpha=0.7, line_color="grey", line_width=0.5, # set visual properties for selected glyphs selection_color="firebrick", # set visual properties for non-selected glyphs nonselection_fill_alpha=0.2, nonselection_fill_color="blue", nonselection_line_color="firebrick", nonselection_line_alpha=1.0) hover_prod = fig_prods.select(HoverTool) hover_prod.point_policy = "follow_mouse" hover_prod.tooltips = [ ("Name", "@name"), ("Production", "@prod bbls"), ("(Long, Lat)", "($x, $y)"), ] prod_color_bar = ColorBar(color_mapper=prod_color_mapper, ticker=LogTicker(), label_standoff=12, border_line_color=None, location=(0, 0)) fig_prods.add_layout(prod_color_bar, 'right') cur_county = county_names[0] source_oil = ColumnDataSource( data=dict(date=oil_prod.index, oil_prod=oil_prod[cur_county])) fig1 = figure(title='Employment vs Oil prices for ' + cur_county, x_axis_type='datetime', plot_width=700, plot_height=400, toolbar_location='left', tools=TOOLS) source_figures = ColumnDataSource( dict(date=unemp.index, unemp=unemp[cur_county], lab_force=lab_force[cur_county])) fig1.circle('Date', 'WTI', source=source_oil_price, legend="Oil Price, $", selection_color='red', nonselection_fill_color='grey', nonselection_fill_alpha=0.2) fig1.line('Date', 'WTI', source=source_oil_price, legend="Oil Price, $") fig1.xaxis.axis_label = 'Date' fig1.yaxis.axis_label = 'Oil Price, $ (month avg.)' fig1.y_range = Range1d(start=0, end=150) # Adding second y axis for unemployment fig1.extra_y_ranges['unemp'] = Range1d(start=0, end=50) fig1.add_layout( LinearAxis(y_range_name="unemp", axis_label='Unemployment Rate (%)'), 'right') # Adding third y axis for labor force fig1.extra_y_ranges['labforce'] = Range1d( start=max(100, min(lab_force[cur_county]) - 1000), end=max(lab_force[cur_county]) + 1000) fig1.add_layout( LogAxis(y_range_name="labforce", axis_label='Labor Force (log)'), 'right') fig1.circle('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig1.line('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig1.circle('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig1.line('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig1.legend.location = 'top_left' fig1.legend.label_text_font_size = '8pt' fig2 = figure(title='Employment vs Oil production for ' + cur_county, x_axis_type='datetime', plot_width=700, plot_height=400, toolbar_location='left', tools=TOOLS) fig2.circle('date', 'oil_prod', source=source_oil, legend='Oil production (bbls)', hover_color='red', selection_color='red', nonselection_fill_color='grey', nonselection_fill_alpha=0.2) fig2.xaxis.axis_label = 'Date' fig2.yaxis.axis_label = 'Oil Production (bbls)' fig2.y_range = Range1d(start=max(0, min(oil_prod[cur_county]) - 1000), end=max(oil_prod[cur_county]) + 1000) # Adding second y axis for unemployment fig2.extra_y_ranges['unemp'] = Range1d(start=0, end=50) fig2.add_layout( LinearAxis(y_range_name="unemp", axis_label='Unemployment Rate (%)'), 'right') # Adding third y axis for labor force fig2.extra_y_ranges['labforce'] = Range1d( start=max(100, min(lab_force[cur_county]) - 1000), end=max(lab_force[cur_county] + 1000)) fig2.add_layout( LogAxis(y_range_name="labforce", axis_label='Labor Force (log)'), 'right') fig2.circle('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig2.line('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig2.circle('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig2.line('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig2.legend.location = 'top_left' fig2.legend.label_text_font_size = '8pt' fig3 = figure(title='Employment vs S&P 500 for ' + cur_county, x_axis_type='datetime', plot_width=700, plot_height=400, toolbar_location='left', tools=TOOLS) fig3.circle('Date', 'SP500', source=source_sp500, legend='S&P 500 index', hover_color='red', selection_color='red', nonselection_fill_color='grey', nonselection_fill_alpha=0.2) fig3.xaxis.axis_label = 'Date' fig3.yaxis.axis_label = 'S&P 500 index' fig3.y_range = Range1d(start=0, end=max(sp500['SP500'])) # Adding second y axis for unemployment fig3.extra_y_ranges['unemp'] = Range1d(start=0, end=50) fig3.add_layout( LinearAxis(y_range_name="unemp", axis_label='Unemployment Rate (%)'), 'right') # Adding third y axis for labor force fig3.extra_y_ranges['labforce'] = Range1d( start=max(100, min(lab_force[cur_county]) - 1000), end=max(lab_force[cur_county] + 1000)) fig3.add_layout( LogAxis(y_range_name="labforce", axis_label='Labor Force (log)'), 'right') fig3.circle('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig3.line('date', 'unemp', source=source_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig3.circle('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig3.line('date', 'lab_force', source=source_figures, y_range_name="labforce", legend="Labor Force (log)", color='green') fig3.legend.location = 'top_left' fig3.legend.label_text_font_size = '8pt' def fig_callback_tap(attr, old, new): try: # The index of the selected glyph is : new['1d']['indices'][0] selections = new['1d']['indices'] patch_name = source_maps.data['name'][selections[0]] source_figures.data = dict(date=unemp.index, unemp=unemp[patch_name], lab_force=lab_force[patch_name]) source_oil.data = dict(date=oil_prod.index, oil_prod=oil_prod[patch_name]) except: selections = old['1d']['indices'] patch_name = source_maps.data['name'][selections[0]] source_figures.data = dict(date=unemp.index, unemp=unemp[patch_name], lab_force=lab_force[patch_name]) source_oil.data = dict(date=oil_prod.index, oil_prod=oil_prod[patch_name]) fig1.title.text = 'Employment vs Oil prices for ' + patch_name fig2.title.text = 'Employment vs Oil production for ' + patch_name fig3.title.text = 'Employment vs S&P 500 for ' + patch_name fig2.y_range.start = max(0, min(oil_prod[patch_name]) - 1000) fig2.y_range.end = max(oil_prod[patch_name]) + 1000 fig1.extra_y_ranges['labforce'].start = max( 100, min(lab_force[patch_name]) - 1000) fig1.extra_y_ranges['labforce'].end = max(lab_force[patch_name] + 1000) fig2.extra_y_ranges['labforce'].start = max( 100, min(lab_force[patch_name]) - 1000) fig2.extra_y_ranges['labforce'].end = max(lab_force[patch_name] + 1000) fig3.extra_y_ranges['labforce'].start = max( 100, min(lab_force[patch_name]) - 1000) fig3.extra_y_ranges['labforce'].end = max(lab_force[patch_name] + 1000) pyglyph.data_source.on_change('selected', fig_callback_tap) pyglyph_prod.data_source.on_change('selected', fig_callback_tap) def update_plot_yr(attr, old, new): # Assign the value of the slider: new_year new_year = slider_yr.value new_month = slider_month.value new_date = pd.to_datetime({ 'year': [new_year], 'month': [new_month], 'day': [1] }) new_rates = unemp.loc[new_date].values[0] new_prods = oil_prod.loc[new_date].values[0] # Set new_data new_data = dict(x=county_xs, y=county_ys, name=county_names, rate=new_rates, prod=new_prods) # Assign new_data to: source.data source_maps.data = new_data # Add title to figure: plot.title.text fig_unemp.title.text = '%s unemployment rate for %s, %d' % ( state_dict[state], month_dict[new_month], new_year) # Add title to figure: plot.title.text fig_prods.title.text = '%s production data for %s, %d' % ( state_dict[state], month_dict[new_month], new_year) # Make a slider object: slider slider_yr = Slider(title='Year', start=1990, end=2016, step=1, value=cur_year) # Attach the callback to the 'value' property of slider slider_yr.on_change('value', update_plot_yr) # Make a slider object: slider slider_month = Slider(title='Month', start=1, end=12, step=1, value=cur_month) # Attach the callback to the 'value' property of slider slider_month.on_change('value', update_plot_yr) return fig_unemp, fig_prods, fig1, fig2, fig3, slider_yr, slider_month
taptool = fig.select(TapTool) taptool.callback = OpenURL(url=url) # figure out what the default axis limits are ydiff = np.log10(ymax) - np.log10(ymin) ystart = 10.**(np.log10(ymin) - 0.05 * ydiff) yend = 10.**(np.log10(ymax) + 0.05 * ydiff) # jupiter/earth mass ratio massratio = 317.8 # set up the second axis with the proper scaling fig.extra_y_ranges = { "jup": Range1d(start=ystart / massratio, end=yend / massratio) } fig.add_layout(LogAxis(y_range_name="jup"), 'right') # add the first y-axis's label and use our custom log formatting for both axes fig.yaxis.axis_label = 'Mass (Earth Masses)' fig.yaxis.formatter = FuncTickFormatter(code=log_axis_labels()) # add the x-axis's label and use our custom log formatting fig.xaxis.axis_label = 'Period (days)' fig.xaxis.formatter = FuncTickFormatter(code=log_axis_labels()) # add the second y-axis's label fig.right[0].axis_label = 'Mass (Jupiter Masses)' # set up all the legend objects items = [ LegendItem(label=ii + f' ({counts[methods.index(ii)]})', renderers=[jj])
def plotting(self): if self.debug: self.debug_file = open("debug_output.txt", "w") self.debug_file.write("Initialized plotting subroutine \n") TOOLS="pan,wheel_zoom,box_zoom,reset,hover,previewsave" tab_plots = [] self.all_elements = [] self.elements_comparison = [] for filename in self.filenames: if "ITO" in filename: tab_plots.append(self.mass_plotting(filename)) continue data_dict = self.data_generation(filename) self.data_test(data_dict) name_check = data_dict["gen_info"]["DATA FILES"] attr_id = name_check[1][4][:-3] + "_" + name_check[2][2] self.attribute_ids.append(attr_id) attr_extra_y_ranges = False attr_extra_x_ranges = False local_source_line = [] """ create plots for each datafile and put them in a tab. """ y_axis_units = [x["y_unit"] for x in data_dict["data"]] x_axis_units = [x["x_unit"] for x in data_dict["data"]] figure_obj = figure(plot_width = 1000, plot_height = 800, y_axis_type = "log", title = attr_id, tools = TOOLS) #figure_obj.axes.major_label_text_font_size("12pt") #figure_obj.major_label_text_font_size("12pt") hover = figure_obj.select(dict(type = HoverTool)) hover.tooltips = [ ("Element:", "@element"), ("(x, y):", "($x, $y)")] self.figure_data.append((figure_obj, data_dict)) figure_obj.yaxis.axis_label = y_axis_units[0] figure_obj.xaxis.axis_label = x_axis_units[0] if not all(x == y_axis_units[0] for x in y_axis_units): for unit, dataset in zip(y_axis_units, data_dict["data"]): if not unit == y_axis_units[0]: extra_y_ranges_exists = attr_extra_y_ranges extra_y_ranges_exists = True if self.debug: self.debug_file.write("Added extra y-axis for file_id: %s, element: %s | New length %g \n" %(attr_id, dataset["sample_element"], len(figure_obj.yaxis))) figure_obj.extra_y_ranges = {"foo": Range1d(start = np.amin(dataset["y"]), end = np.amax(dataset["y"]))} figure_obj.add_layout(LogAxis(y_range_name = "foo", axis_label = unit), "right") break if not all(x == x_axis_units[0] for x in x_axis_units): for unit, dataset in zip(x_axis_units, data_dict["data"]): if not unit == x_axis_units[0]: extra_x_ranges_exists = attr_extra_x_ranges extra_x_ranges_exists = True if self.debug: self.debug_file.write("Added extra x-axis for file_id: %s, element: %s. | New length %g \n" %(attr_id, dataset["sample_element"], len(figure_obj.yaxis))) figure_obj.extra_x_ranges = {"bar": Range1d(start = np.amin(dataset["x"]), end = np.amax(dataset["x"]))} figure_obj.add_layout(LinearAxis(x_range_name = "bar", axis_label = unit), "above") break figure_obj.xaxis.axis_label = x_axis_units[0] colour_list = Spectral11 + RdPu9 + Oranges9 colour_indices = [0, 2, 8, 10, 12, 14, 20, 22, 1, 3, 9, 11, 13, 15] list_of_elements = [] source_list = [] line_list = [] for dataset, color_index in zip(data_dict["data"], colour_indices): self.all_elements.append(dataset["sample_element"]) #strip isotope number color = colour_list[color_index] source = ColumnDataSource(data = dataset) #Datastructure for source of plotting self.source_test(source) list_of_elements.append(dataset["sample_element"]) line_glyph = figure_obj.line("x", "y", source = source, line_width = 2, line_color = color, legend = dataset["sample_element"]) if self.debug: self.debug_file.write("Create line object on figure %s at %s \n" %(id(figure_obj), id(line_glyph))) line_list.append(line_glyph) source_list.append(source) local_source_line.append([[source, line] for source, line in zip(source_list, line_list)]) self.source_line.append(local_source_line) #Calculations on the dataset text_input_rsf = TextInput(value = "default", title = "RSF or SF (at/cm^3): ") do_integral_button = Button(label = "Calibration integral") smoothing_button = Button(label = "smth selct elem") matplot_button = Button(label = "Create matplotlib fig") text_input_sputter = TextInput(value = "default", title = "Sputter speed: number unit") text_input_crater_depth = TextInput(value = "default", title = "Depth of crater in: number unit") radio_group = RadioGroup(labels = list_of_elements, active=0) text_input_xval_integral = TextInput(value = "0", title = "x-delimiter ") text_input_dose = TextInput(value = "0", title = "Dose[cm^-2] ") #Save files for later use save_flexDPE_button = Button(label = "Save element for FlexPDE") save_all_flexDPE_button = Button(label = "Save all elements for FlexPDE") save_textfile_button = Button(label = "Sava Data in textfile") #Pointers to methods on click / change handlers radio_group.on_change("active", lambda attr, old, new: None) matplot_button.on_click(lambda source_list = source_list: self.matplotlib_export(source_list)) do_integral_button.on_click(lambda source_list = source_list, line_list = line_list, source_line = self.source_line, figure_data = self.figure_data, data_dict = data_dict, radio = radio_group, x_box = text_input_xval_integral, dose = text_input_dose, extra_y_ranges = attr_extra_y_ranges: self.integrate(data_dict, source_list, line_list, source_line, figure_data, radio, x_box, dose, extra_y_ranges)) smoothing_button.on_click(lambda source_list = source_list, radio = radio_group, data_dict = data_dict, x_box = text_input_xval_integral: self.smoothing(source_list, data_dict, radio, x_box) ) save_flexDPE_button.on_click(lambda source_list = source_list, attrname = attr_id, radio = radio_group: self.write_to_flexPDE(source_list, attrname, radio)) save_all_flexDPE_button.on_click(lambda source_list = source_list, attrname = attr_id: self.write_all_to_flexPDE(source_list, attrname)) save_textfile_button.on_click(lambda data_dict = data_dict, source_list = source_list, attrname = attr_id, radio = radio_group: self.write_new_datafile(data_dict, source_list, attrname,radio)) text_input_rsf.on_change("value", lambda attr, old, new, radio = radio_group, data_dict = data_dict, figure = figure_obj, source_list = source_list, text_input = text_input_rsf, line_list = line_list, which = "rsf": self.update_data(line_list, data_dict, source_list, figure, radio, text_input, new, which)) text_input_sputter.on_change("value", lambda attr, old, new, radio = radio_group, data_dict = data_dict, figure = figure_obj, source_list = source_list, text_input = text_input_sputter, which = "sputter": self.update_data(data_dict, source_list, figure, radio, text_input, new, which)) text_input_crater_depth.on_change("value", lambda attr, old, new, radio = radio_group, data_dict = data_dict, source_list = source_list, figure = figure_obj, text_input = text_input_crater_depth, which = "crater_depth": self.update_data(data_dict, source_list, figure, radio, text_input, new, which)) #Initialization of actual plotting. tab_plots.append(Panel(child = hplot(figure_obj, vform( vform(radio_group, save_flexDPE_button, save_all_flexDPE_button, save_textfile_button, matplot_button), vform(text_input_rsf, smoothing_button, text_input_sputter, text_input_crater_depth) ), vform(text_input_xval_integral, text_input_dose, do_integral_button)), title = attr_id)) """ Check to see if one or more element exists in the samples and creat a comparison plot for each of those elements. """ for element in self.all_elements: checkers = list(self.all_elements) checkers.remove(element) if element in checkers and not element in self.elements_comparison: self.elements_comparison.append(element) """create plots for each element that is to be compared """ for comparison_element in self.elements_comparison: figure_obj = figure(plot_width = 1000, plot_height = 800, y_axis_type = "log", title = comparison_element, tools = TOOLS) #figure_obj.xaxis.major_label_text_font_size("12pt") #figure_obj.yaxis.major_label_text_font_size("12pt") y_axis_units = [] x_axis_units = [] comparison_datasets = [] for data_dict_iter in self.column(self.figure_data, 1): for dataset in data_dict_iter["data"]: if dataset["sample_element"] == comparison_element: comparison_datasets.append(dataset) y_axis_units.append(dataset["y_unit"]) x_axis_units.append(dataset["x_unit"]) figure_obj.xaxis.axis_label = comparison_datasets[-1]["x_unit"] figure_obj.yaxis.axis_label = comparison_datasets[-1]["y_unit"] if not all(x == y_axis_units[-1] for x in y_axis_units): for unit, data in zip(y_axis_units, comparison_datasets): if not unit == y_axis_units[-1]: figure_obj.extra_y_ranges = {"foo": Range1d(start = np.amin(data["y"]), end = np.amax(data["y"]))} figure_obj.add_layout(LogAxis(y_range_name = "foo", axis_label = unit), "right") break if not all(x == x_axis_units[-1] for x in x_axis_units): for unit, data in zip(x_axis_units, comparison_datasets): if not unit == x_axis_units[-1]: figure_obj.extra_x_ranges = {"bar": Range1d(start = np.amin(data["x"]), end = np.amax(data["x"]))} figure_obj.add_layout(LinearAxis(x_range_name = "bar", axis_label = unit), "above") break active_sources = [] for data_dict, source_line_nested, attr_id, color_index in zip(self.column(self.figure_data, 1), self.source_line, self.attribute_ids, colour_indices): for dataset, source_lis_coup, in zip(data_dict["data"], source_line_nested[0]): source_local = source_lis_coup[0] active_sources.append(source_local) self.source_test(source_local) self.source_dataset_test(source_local, dataset) if dataset["sample_element"] == comparison_element: color = colour_list[color_index] """ Logic that ensures that plots get put with correspoinding axes. """ if dataset["x_unit"] != x_axis_units[-1] or dataset["y_unit"] != y_axis_units[-1]: if dataset["x_unit"] != x_axis_units[-1] and dataset["y_unit"] != y_axis_units[-1]: name_check = data_dict["gen_info"]["DATA FILES"] attr_id = name_check[1][4][:-3] + "_" + name_check[2][2] figure_obj.line("x", "y", source = source_local, line_width = 2, line_color = color, legend = attr_id, x_range_name = "bar", y_range_name = "foo") elif dataset["x_unit"] != x_axis_units[-1]: figure_obj.line("x", "y", source = source_local, line_width = 2, line_color = color, legend = attr_id, x_range_name = "bar") else: figure_obj.line("x", "y", source = source_local, line_width = 2, line_color = color, legend = attr_id, y_range_name = "foo") else: figure_obj.line("x", "y", source = source_local, line_width = 2, line_color = color, legend = attr_id) matplot_button = Button(label = "Create matplotlib fig") save_all_flexDPE_button = Button(label = "Save all elements for FlexPDE") matplot_button.on_click(lambda source_list = active_sources: self.matplotlib_export(source_list)) save_all_flexDPE_button.on_click(lambda source_list = active_sources, attrname = comparison_element: self.write_all_to_flexPDE(source_list, attrname)) tab_plots.append(Panel(child = hplot(figure_obj, vform(save_all_flexDPE_button, matplot_button)), title = comparison_element)) tabs = Tabs(tabs = tab_plots) #curdoc().add_root(tabs) session = push_session(curdoc()) session.show() session.loop_until_closed()
fig1_tx.yaxis.axis_label = 'Oil Price, $ (month avg.)' fig1_tx.y_range = Range1d(start=0, end=150) # Adding second y axis for unemployment fig1_tx.extra_y_ranges['unemp'] = Range1d(start=0, end=50) fig1_tx.add_layout( LinearAxis(y_range_name="unemp", axis_label='Unemployment Rate (%)'), 'right') # Adding third y axis for labor force fig1_tx.extra_y_ranges['labforce'] = Range1d( start=max(100, min(tx_lab_force[cur_tx_county]) - 1000), end=max(tx_lab_force[cur_tx_county]) + 1000) fig1_tx.add_layout( LogAxis(y_range_name="labforce", axis_label='Labor Force (log)'), 'right') fig1_tx.circle('date', 'unemp', source=source_tx_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig1_tx.line('date', 'unemp', source=source_tx_figures, y_range_name="unemp", legend="Unemployment rate (%)", color='orange') fig1_tx.circle('date',
plot.outline_line_color = c_gray plot.line(x=[0,L], y=[0,0], line_color = c_gray, line_dash ="4 4") # beam initial position plot.add_glyph(support_left_source,ImageURL(url="src", x='x', y='y', w= 'w', h= 'h', anchor= "top_center")) # beam supports plot.add_glyph(support_right_source,ImageURL(url="src", x='x', y='y', w= 'w', h= 'h', anchor= "top_center")) # beam supports plot.line(x = 'x', y = 'y', source = beam_coordinates_source, color = c_black) plot.line(x = 'x', y = 'y', source = lfa_coordinates_source, color = c_green, line_dash = "dashed") arrow_load = Arrow(start=NormalHead(line_color=c_orange, fill_color = c_orange, fill_alpha = 0.5), end=NormalHead(line_alpha = 0, fill_alpha = 0), x_start='xs', y_start='ye', x_end='xe', y_end='ys', line_alpha = 0, source=load_arrow_source,line_color=c_white) plot.add_layout(arrow_load) # amplitude for every excitation frequency ratio disp_freq = figure(x_range = [0.04, max_r], y_axis_type="log", y_range = [0.00001,100], height = 335, width = 280,toolbar_location = None, tools = "") disp_freq.yaxis.visible = False disp_freq.add_layout(LogAxis(axis_label='Normalized Deflection W(x)⋅E⋅I/(F⋅L³)'), 'right') disp_freq.xaxis.axis_label = "Excitation Frequency Ratio" disp_freq.outline_line_color = c_gray disp_freq.line(x = 'x', y = 'y', source = amp_coordinates_source) disp_freq.line(x = 'x', y = 'y', source = freq_coordinates_source, line_dash = "dashed") # phase angle for every excitation frequency ratio disp_phase = figure(x_range = [0.04, max_r], y_range = [-pi-0.1, pi+0.1], height = 335, width = 280,toolbar_location = None, tools = "") disp_phase.yaxis.axis_label = "Phase Angle [rad]" disp_phase.yaxis.visible = False disp_phase.add_layout(LinearAxis(axis_label='Phase Angle [rad]'), 'right') disp_phase.xaxis.axis_label = "Excitation Frequency Ratio" disp_phase.outline_line_color = c_gray disp_phase.line(x = 'x', y = 'y', source = phase_coordinates_source) disp_phase.line(x = 'x', y = 'y', source = freq2_coordinates_source, line_dash = "dashed")
def plotting(self): #Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()] TOOLS = "crosshair,pan,wheel_zoom,box_zoom,reset,hover,previewsave" tab_plots = [] #output_file("test.html") self.all_elements = [] self.elements_comparison = [] for attr_id, i in zip(self.attribute_ids, range(len(self.attribute_ids))): """ create plots for each datafile and put them in a tab. """ list_of_datasets = getattr(self, attr_id) y_axis_units = [x["y_unit"] for x in list_of_datasets] x_axis_units = [x["x_unit"] for x in list_of_datasets] figure_obj = figure(plot_width=1000, plot_height=800, y_axis_type="log", title=attr_id, tools=TOOLS) #figure_obj.axes.major_label_text_font_size("12pt") #figure_obj.major_label_text_font_size("12pt") setattr(self, attr_id + "_" + "figure_obj", figure_obj) figure_obj.yaxis.axis_label = y_axis_units[0] figure_obj.xaxis.axis_label = x_axis_units[0] if not all(x == y_axis_units[0] for x in y_axis_units): for unit, data in zip(y_axis_units, list_of_datasets): if not unit == y_axis_units[0]: figure_obj.extra_y_ranges = { "foo": Range1d(start=np.amin(data["data"]["y"]), end=np.amax(data["data"]["y"])) } figure_obj.add_layout( LogAxis(y_range_name="foo", axis_label=unit), "right") break if not all(x == x_axis_units[0] for x in x_axis_units): for unit, data in zip(x_axis_units, list_of_datasets): if not unit == x_axis_units[0]: figure_obj.extra_x_ranges = { "bar": Range1d(start=np.amin(data["data"]["x"]), end=np.amax(data["data"]["x"])) } figure_obj.add_layout( LinearAxis(x_range_name="bar", axis_label=unit), "above") break figure_obj.xaxis.axis_label = list_of_datasets[0]["x_unit"] colour_list = Spectral11 + RdPu9 + Oranges9 colour_indices = [0, 2, 8, 10, 12, 14, 20, 22, 1, 3, 9, 11, 13, 15] list_of_elements = [] for dataset, color_index in zip(list_of_datasets, colour_indices): self.all_elements.append( dataset["sample element"]) #strip isotope number color = colour_list[color_index] source = ColumnDataSource( data=dataset["data"] ) #Datastructure for source of plotting setattr(self, attr_id + "_" + dataset["sample element"] + "_source", source) #Source element generalized for all plotting list_of_elements.append(dataset["sample element"]) figure_obj.line( "x", "y", source=getattr( self, attr_id + "_" + dataset["sample element"] + "_source"), line_width=2, line_color=color, legend=dataset["sample element"], name=dataset["sample element"], ) hover = figure_obj.select_one(HoverTool).tooltips = [ ("element", "@element"), ("(x,y)", "($x, $y)") ] radio_group = RadioGroup(labels=list_of_elements, active=0) """ Need to fetch default variables from input file and replace DEFAULT Block of code produces the layout of buttons and callbacks """ #Calculations on the dataset text_input_rsf = TextInput(value="default", title="RSF (at/cm^3): ") do_integral_button = Button(label="Calibration Integral") smoothing_button = Button(label="Smoothing on selected curve") text_input_sputter = TextInput(value="default", title="Sputter speed: float unit") text_input_crater_depth = TextInput( value="default", title="Depth of crater in: float") radio_group.on_change("active", lambda attr, old, new: None) text_input_xval_integral = TextInput( value="0", title="x-value for calibration integral ") text_input_yval_integral = TextInput( value="0", title="y-value for calibration integral ") #Save files for later use save_flexDPE_button = Button(label="Save element for FlexPDE") save_all_flexDPE_button = Button( label="Save all elements for FlexPDE") #Pointers to methods on click / change handlers do_integral_button.on_click( lambda identity=self.attribute_ids[i], radio=radio_group, x_box =text_input_xval_integral, y_box=text_input_yval_integral: self .integrate(identity, radio, x_box, y_box)) smoothing_button.on_click(lambda identity=self.attribute_ids[ i], radio=radio_group: self.smoothing(identity, radio)) save_flexDPE_button.on_click(lambda identity=self.attribute_ids[ i], radio=radio_group: self.write_to_flexPDE(identity, radio)) save_all_flexDPE_button.on_click( lambda identity=self.attribute_ids[i], radio=radio_group: self. write_all_to_flexPDE(identity, radio)) text_input_rsf.on_change( "value", lambda attr, old, new, radio=radio_group, identity=self. attribute_ids[i], text_input=text_input_rsf, which="rsf": self. update_data(identity, radio, text_input, new, which)) text_input_sputter.on_change( "value", lambda attr, old, new, radio=radio_group, identity=self. attribute_ids[i], text_input= text_input_sputter, which="sputter": self.update_data( identity, radio, text_input, new, which)) text_input_crater_depth.on_change( "value", lambda attr, old, new, radio=radio_group, identity=self. attribute_ids[i], text_input=text_input_crater_depth, which= "crater_depth": self.update_data(identity, radio, text_input, new, which)) #Initialization of actual plotting. tab_plots.append( Panel(child=hplot( figure_obj, vform(radio_group, save_flexDPE_button, save_all_flexDPE_button), vform(text_input_rsf, smoothing_button, text_input_sputter, text_input_crater_depth), vform(text_input_xval_integral, text_input_yval_integral, do_integral_button)), title=attr_id)) """ Check to see if one or more element exists in the samples and creat a comparison plot for each of those elements. """ for element in self.all_elements: checkers = list(self.all_elements) checkers.remove(element) if element in checkers and not element in self.elements_comparison: self.elements_comparison.append(element) """create plots for each element that is to be compared """ for comparison_element in self.elements_comparison: colour_list = Spectral11 + RdPu9 + Oranges9 colour_indices = [0, 2, 8, 10, 12, 14, 20, 22, 1, 3, 9, 11, 13, 15] figure_obj = figure(plot_width=1000, plot_height=800, y_axis_type="log", title=comparison_element, tools=TOOLS) #figure_obj.xaxis.major_label_text_font_size("12pt") #figure_obj.yaxis.major_label_text_font_size("12pt") y_axis_units = [] x_axis_units = [] comparison_datasets = [] for attr_id, color_index in zip(self.attribute_ids, colour_indices): list_of_datasets = getattr(self, attr_id) for dataset in list_of_datasets: if dataset["sample element"] == comparison_element: comparison_datasets.append(dataset) y_axis_units.append(dataset["y_unit"]) x_axis_units.append(dataset["x_unit"]) figure_obj.xaxis.axis_label = comparison_datasets[-1]["x_unit"] figure_obj.yaxis.axis_label = comparison_datasets[-1]["y_unit"] if not all(x == y_axis_units[-1] for x in y_axis_units): for unit, data in zip(y_axis_units, comparison_datasets): if not unit == y_axis_units[-1]: figure_obj.extra_y_ranges = { "foo": Range1d(start=np.amin(data["data"]["y"]), end=np.amax(data["data"]["y"])) } figure_obj.add_layout( LogAxis(y_range_name="foo", axis_label=unit), "right") break if not all(x == x_axis_units[-1] for x in x_axis_units): for unit, data in zip(x_axis_units, comparison_datasets): if not unit == x_axis_units[-1]: figure_obj.extra_x_ranges = { "bar": Range1d(start=np.amin(data["data"]["x"]), end=np.amax(data["data"]["x"])) } figure_obj.add_layout( LinearAxis(x_range_name="bar", axis_label=unit), "above") break for attr_id, color_index in zip(self.attribute_ids, colour_indices): list_of_datasets = getattr(self, attr_id) for dataset in list_of_datasets: if dataset["sample element"] == comparison_element: color = colour_list[color_index] """ Logic that ensures that plots get put with correspoinding axes. """ if dataset["x_unit"] != x_axis_units[-1] or dataset[ "y_unit"] != y_axis_units[-1]: if dataset["x_unit"] != x_axis_units[ -1] and dataset["y_unit"] != y_axis_units[ -1]: figure_obj.line( "x", "y", source=getattr( self, attr_id + "_" + dataset["sample element"] + "_source"), line_width=2, line_color=color, legend=attr_id, x_range_name="bar", y_range_name="foo") elif dataset["x_unit"] != x_axis_units[-1]: figure_obj.line( "x", "y", source=getattr( self, attr_id + "_" + dataset["sample element"] + "_source"), line_width=2, line_color=color, legend=attr_id, x_range_name="bar") else: figure_obj.line( "x", "y", source=getattr( self, attr_id + "_" + dataset["sample element"] + "_source"), line_width=2, line_color=color, legend=attr_id, y_range_name="foo") else: figure_obj.line( "x", "y", source=getattr( self, attr_id + "_" + dataset["sample element"] + "_source"), line_width=2, line_color=color, legend=attr_id) tab_plots.append(Panel(child=figure_obj, title=comparison_element)) tabs = Tabs(tabs=tab_plots) session = push_session(curdoc()) session.show() session.loop_until_closed()
def make_plot(self): self.p = figure( x_axis_label="Date", x_axis_type="datetime", y_axis_label="Total Cases and Deaths", width=900, ) self.p.extra_y_ranges = {"ratio_axis": Range1d()} axis = LinearAxis(y_range_name="ratio_axis") axis.formatter = NumeralTickFormatter(format="0 %") self.p.add_layout(axis, "right") colors = Category20_3 self.p.line( source=self.src, x="date", y="cases", line_width=2, color=colors[0], legend_label="Cases", ) self.p.line( source=self.src, x="date", y="deaths", line_width=2, color=colors[1], legend_label="Deaths", ) self.p.line( source=self.src, x="date", y="ratio", line_width=2, y_range_name="ratio_axis", color=colors[2], legend_label="Deaths/Cases", ) self.p.legend.location = "top_left" self.logp = figure( x_axis_label="Date", x_axis_type="datetime", y_axis_label="Total Cases and Deaths", y_axis_type="log", width=900, ) self.logp.extra_y_ranges = {"ratio_axis": Range1d()} logaxis = LogAxis(y_range_name="ratio_axis") logaxis.formatter = NumeralTickFormatter(format="0 %") self.logp.add_layout(logaxis, "right") self.logp.line( source=self.src, x="date", y="cases", line_width=2, color=colors[0], legend_label="Cases", ) self.logp.line( source=self.src, x="date", y="deaths", line_width=2, color=colors[1], legend_label="Deaths", ) self.logp.line( source=self.src, x="date", y="ratio", line_width=2, y_range_name="ratio_axis", color=colors[2], legend_label="Deaths/Cases", ) self.p.legend.location = "top_left"
def update_scale(attr, old, new): ticker = LinearAxis() if new == "Log scale": ticker = LogAxis() pairplots['dimdem'].yaxis[0] = ticker