def draw_constant_salary_bump(s: figure, constant_list: list, pay_norm: int): """ Draw lines for constant salary increase """ constant_list0 = [c / pay_norm for c in constant_list] if CURRENCY_NORM and pay_norm == 1: constant_list0 = [a / 1e3 for a in constant_list] x_max = 2500. if pay_norm > 1: x_max = 1200. for c, constant in enumerate(constant_list0): x = np.arange(max([s.x_range.start, constant + 1]), x_max, 5) y = 100 * constant / (x - constant) if pay_norm == 1: text = f'${constant}k' else: text = f'${constant_list[c]/1e3}k (${constant:.2f}/hr)' source = ColumnDataSource(data=dict(x=x, y=y, name=[text] * len(x))) s.line('x', 'y', line_dash='dashed', line_color='black', source=source) y_label = constant_list[c] / 1e3 x_label = constant + 100 * constant / y_label label = Label(x=x_label, y=y_label, text=text) s.add_layout(label) return s
def setup_timeline_backend_parts(plot: figure, desc_label_source: ColumnDataSource) -> None: """ :param plot: :param desc_label_source: :return: """ start_date, end_date = plot.x_range.start, plot.x_range.end arrow_x = start_date + datetime.timedelta(days=180) # 補助線を引く plot.line([start_date, end_date], [1, 1], line_width=3, line_color='pink') plot.line([start_date, end_date], [0.5, 0.5], line_width=3, line_dash='dotted', line_color='pink') plot.line([start_date, end_date], [1.5, 1.5], line_width=3, line_dash='dotted', line_color='pink') # 矢印を表示する plot.add_layout( Arrow(end=VeeHead(size=15), line_color='black', x_start=arrow_x, y_start=1.4, x_end=arrow_x, y_end=1.1)) plot.add_layout( Arrow(end=VeeHead(size=15), line_color='black', x_start=arrow_x, y_start=0.9, x_end=arrow_x, y_end=0.6)) plot.text(source=desc_label_source, x='x', y='y', text='text', text_font_size='size', text_alpha=0.8)
def bokeh_scatter(x, y, name: pd.Series = None, x_err=None, pay_norm: int = 1, x_label: str = '', y_label: str = '', x_range: list = tuple([0, 500]), title: str = '', size: Union[int, float] = 4, bc: str = "#f0f0f0", bfc: str = "#fafafa", fc="#f8b739", ec="#f8b739", alpha=0.5, label: Optional[str] = None, s: figure = None): if s is None: s = bokeh_scatter_init(pay_norm, x_label, y_label, title=title, x_range=x_range, bc=bc, bfc=bfc, plot_constants=True) if x_err is not None: bin_range = ColumnDataSource( data=dict(base=y, lower=x_err[0], upper=x_err[1])) w = Whisker(source=bin_range, base='base', lower='lower', upper='upper', dimension='width', line_color=fc) w.upper_head.line_color = fc w.lower_head.line_color = fc s.add_layout(w) if name is not None: source = ColumnDataSource(data=dict(x=x, y=y, name=name)) s.scatter('x', 'y', marker='circle', fill_color=fc, source=source, line_color=ec, alpha=alpha, size=size, legend_label=label) else: s.scatter('x', 'y', marker='circle', fill_color=fc, line_color=ec, alpha=alpha, size=size, legend_label=label) return s