def _get_palette_class(cls, chart, palette_type='categorical', palette=None, accent_values=None): if palette_type == 'categorical': if palette is None: palette_name = options.get_option( 'style.color_palette_categorical') palette = colors.color_palettes[palette_name] return CategoricalPalette(chart, palette) elif palette_type == 'sequential': if palette is None: palette_name = options.get_option( 'style.color_palette_sequential') palette = colors.color_palettes[palette_name] return OrdinalPalette(chart, palette) elif palette_type == 'diverging': if palette is None: palette_name = options.get_option( 'style.color_palette_diverging') palette = colors.color_palettes[palette_name] return OrdinalPalette(chart, palette) elif palette_type == 'accent': if palette is None: palette_name = options.get_option('style.color_palette_accent') palette = colors.color_palettes[palette_name] return AccentPalette(chart, palette, accent_values) else: raise ValueError( """Type must be one of: ('categorical', 'sequential', 'diverging', 'accent').""")
def __init__(self, chart): self._chart = chart self._logo_image = None self._path = options.get_option('config.logos_path') self._logo_file_mapping = {} self._logo_file_mapping = OrderedDict( sorted(list(self._logo_file_mapping.items()), key=lambda t: t[0]))
def __init__(self): self._palettes = OrderedDict() config_filename = options.get_option('config.color_palettes') try: self._from_yaml(config_filename) except FileNotFoundError: pass
def __init__(self): config_filename = options.get_option('config.colors') try: self.colors = self.from_yaml(config_filename) except FileNotFoundError: self.colors = { (232, 232, 232): 'Light Grey', (83, 88, 95): 'Dark Grey', }
def __init__(self, blank_labels=options.get_option('chart.blank_labels'), layout='slide_50%'): """Create a Radar Chart instance. Note: Radar charts plot each vertex in counter-clockwise order starting from the top. Args: blank_labels (bool): When true removes the title, subtitle, axes, and source labels from the chart. Default False. layout (str): Change size & aspect ratio of the chart for fitting into slides. - 'slide_100%' - 'slide_75%' - 'slide_50%' (Suggested for Radar Charts) - 'slide_25%' """ # Validate axis type input valid_axis_types = ['linear', 'log'] self._axis_type = 'linear' self._x_axis_type, self._y_axis_type = self._axis_type, self._axis_type if self._axis_type not in valid_axis_types: raise ValueError('axis_type must be one of {options}'.format( options=valid_axis_types)) self._blank_labels = options._get_value(blank_labels) self.style = Style(self, layout) self.figure = self._initialize_figure(self._axis_type, self._axis_type) self.style._apply_settings('chart') self.callout = Callout(self) self.axes = BaseAxes._get_axis_class(self._axis_type, self._axis_type)(self) self.plot = PlotRadar(self) self._source = self._add_source_to_figure() self._subtitle_glyph = self._add_subtitle_to_figure() self.figure.toolbar.logo = None # Remove bokeh logo from toolbar. # Reverse the order of vertical legends. Used with stacked plot types # to ensure that the stack order is consistent with the legend order. self._reverse_vertical_legend = False # Logos disabled for now. # self.logo = Logo(self) # Set default for title title = """ch.set_title('Takeaway')""" if self._blank_labels: title = "" self.set_title(title)
def __init__(self, blank_labels=options.get_option('chart.blank_labels'), layout='slide_100%', x_axis_type='linear', y_axis_type='linear', second_y_axis=False): """Create a chart instance. Args: blank_labels (bool): When true removes the title, subtitle, axes, and source labels from the chart. Default False. layout (str): Change size & aspect ratio of the chart for fitting into slides. - 'slide_100%' - 'slide_75%' - 'slide_50%' - 'slide_25%' x_axis_type (enum, str): Type of data plotted on the X-axis. - 'linear': - 'log': - 'datetime': Use for datetime formatted data. - 'categorical': - 'density' y_axis_type (enum, str): Type of data plotted on the Y-axis. - 'linear': - 'log': - 'categorical': - 'density' Note: Combination of x_axis_type and y_axis_type will determine the plotting methods available. """ # Validate axis type input valid_x_axis_types = [ 'linear', 'log', 'datetime', 'categorical', 'density' ] valid_y_axis_types = ['linear', 'log', 'categorical', 'density'] valid_second_y_axis_types = ['linear', 'log'] if x_axis_type not in valid_x_axis_types: raise ValueError('x_axis_type must be one of {options}'.format( options=valid_x_axis_types)) if y_axis_type not in valid_y_axis_types: raise ValueError('y_axis_type must be one of {options}'.format( options=valid_y_axis_types)) self._second_y_axis_type = None if second_y_axis: self._second_y_axis_type = y_axis_type if self._second_y_axis_type not in valid_second_y_axis_types: raise ValueError('second_y_axis can only be used when \ y_axis_type is one of {options}'.format( options=valid_second_y_axis_types)) self._x_axis_type, self._y_axis_type = x_axis_type, y_axis_type self._blank_labels = options._get_value(blank_labels) self.style = Style(self, layout) self.figure = self._initialize_figure(self._x_axis_type, self._y_axis_type) self.style._apply_settings('chart') self.plot = BasePlot._get_plot_class(self._x_axis_type, self._y_axis_type)(self) self.callout = Callout(self) self.axes = BaseAxes._get_axis_class(self._x_axis_type, self._y_axis_type)(self) if self._second_y_axis_type in valid_second_y_axis_types: self.second_axis = SecondAxis() self.second_axis.axes = SecondYNumericalAxis(self) self.second_axis.plot = BasePlot._get_plot_class( self._x_axis_type, self._second_y_axis_type)(self, self.second_axis.axes._y_range_name) self._source = self._add_source_to_figure() self._subtitle_glyph = self._add_subtitle_to_figure() self.figure.toolbar.logo = None # Remove bokeh logo from toolbar. # Reverse the order of vertical legends. Used with stacked plot types # to ensure that the stack order is consistent with the legend order. self._reverse_vertical_legend = False # Logos disabled for now. # self.logo = Logo(self) # Set default for title title = """ch.set_title('Takeaway')""" if self._blank_labels: title = "" self.set_title(title)
def __init__(self, chart, layout): self._chart = chart self.color_palette = BasePalette._get_palette_class(self._chart) self._layout = layout self._set_width_and_height(layout) self.settings = { 'legend': { 'figure.legend.orientation': 'horizontal', 'figure.legend.location': 'top_left', 'figure.legend.label_text_font': 'helvetica' }, 'chart': { 'figure.background_fill_color': "white", 'figure.xgrid.grid_line_color': None, 'figure.ygrid.grid_line_color': None, 'figure.border_fill_color': "white", 'figure.min_border_left': 60, 'figure.min_border_right': 60, 'figure.min_border_top': 40, 'figure.min_border_bottom': 60, 'figure.xaxis.axis_line_width': 1, 'figure.yaxis.axis_line_width': 1, 'figure.yaxis.axis_line_color': "#C0C0C0", 'figure.xaxis.axis_line_color': "#C0C0C0", 'figure.yaxis.axis_label_text_color': "#666666", 'figure.xaxis.axis_label_text_color': "#666666", 'figure.xaxis.major_tick_line_color': "#C0C0C0", 'figure.xaxis.minor_tick_line_color': "#C0C0C0", 'figure.yaxis.major_tick_line_color': "#C0C0C0", 'figure.yaxis.minor_tick_line_color': "#C0C0C0", 'figure.xaxis.major_label_text_color': '#898989', 'figure.yaxis.major_label_text_color': '#898989', 'figure.outline_line_alpha': 1, 'figure.outline_line_color': 'white', 'figure.xaxis.axis_label_text_font': 'helvetica', 'figure.yaxis.axis_label_text_font': 'helvetica', 'figure.yaxis.major_label_text_font': 'helvetica', 'figure.xaxis.major_label_text_font': 'helvetica', 'figure.yaxis.axis_label_text_font_style': 'bold', 'figure.xaxis.axis_label_text_font_style': 'bold', 'figure.yaxis.axis_label_text_font_size': "11pt", 'figure.xaxis.axis_label_text_font_size': "11pt", 'figure.yaxis.major_label_text_font_size': "10pt", 'figure.xaxis.major_label_text_font_size': "10pt", 'figure.title.text_font': 'helvetica', 'figure.title.text_color': '#333333', 'figure.title.text_font_size': "18pt", 'figure.xaxis.minor_tick_out': 1, 'figure.yaxis.minor_tick_out': 1, 'figure.xaxis.major_tick_line_width': 1, 'figure.yaxis.major_tick_line_width': 1, 'figure.xaxis.major_tick_out': 4, 'figure.yaxis.major_tick_out': 4, 'figure.xaxis.major_tick_in': 0, 'figure.yaxis.major_tick_in': 0, }, 'categorical_xaxis': { # Used for grouped categorical axes 'figure.xaxis.separator_line_alpha': 0, 'figure.xaxis.subgroup_text_font': 'helvetica', 'figure.xaxis.group_text_font': 'helvetica', 'figure.xaxis.subgroup_text_font_size': "11pt", 'figure.xaxis.group_text_font_size': "11pt", 'figure.x_range.factor_padding': .25 }, 'categorical_yaxis': { # Used for grouped categorical axes 'figure.yaxis.separator_line_alpha': 0, 'figure.yaxis.subgroup_text_font': 'helvetica', 'figure.yaxis.group_text_font': 'helvetica', 'figure.y_range.factor_padding': .25, 'figure.yaxis.subgroup_text_font_size': "11pt", 'figure.yaxis.group_text_font_size': "11pt", }, 'categorical_xyaxis': { # Used for grouped categorical axes 'figure.yaxis.separator_line_alpha': 0, 'figure.yaxis.subgroup_text_font': 'helvetica', 'figure.yaxis.group_text_font': 'helvetica', 'figure.yaxis.subgroup_text_font_size': "11pt", 'figure.yaxis.group_text_font_size': "11pt", # Used for grouped categorical axes 'figure.xaxis.separator_line_alpha': 0, 'figure.xaxis.subgroup_text_font': 'helvetica', 'figure.xaxis.group_text_font': 'helvetica', 'figure.xaxis.subgroup_text_font_size': "11pt", 'figure.xaxis.group_text_font_size': "11pt", }, 'subtitle': { 'subtitle_align': 'left', 'subtitle_text_color': '#666666', 'subtitle_location': 'above', 'subtitle_text_size': '12pt', 'subtitle_text_font': 'helvetica' }, 'text_callout_and_plot': { 'font': 'helvetica', }, 'interval_plot': { 'space_between_bars': .25, 'margin': .05, 'bar_width': .9, 'space_between_categories': 1.15, # Note each stem is drawn twice 'interval_end_stem_size': .1 / 2, 'interval_midpoint_stem_size': .03 / 2 }, 'line_plot': { 'line_cap': 'round', 'line_join': 'round', 'line_width': 4, 'line_dash': 'solid' }, 'second_y_axis': { 'figure.yaxis[1].axis_label_text_color': "#666666", 'figure.yaxis[1].axis_line_color': "#C0C0C0", 'figure.yaxis[1].axis_line_width': 1, 'figure.yaxis[1].major_tick_line_color': "#C0C0C0", 'figure.yaxis[1].minor_tick_line_color': "#C0C0C0", 'figure.yaxis[1].major_label_text_color': '#898989', 'figure.yaxis[1].axis_label_text_font': 'helvetica', 'figure.yaxis[1].major_label_text_font': 'helvetica', 'figure.yaxis[1].axis_label_text_font_style': 'bold', 'figure.yaxis[1].axis_label_text_font_size': "11pt", 'figure.yaxis[1].major_label_text_font_size': "10pt", 'figure.yaxis[1].minor_tick_out': 1, 'figure.yaxis[1].major_tick_line_width': 1, 'figure.yaxis[1].major_tick_out': 4, 'figure.yaxis[1].major_tick_in': 0, } } config_filename = options.get_option('config.style_settings') try: self._settings_from_yaml( config_filename, apply_chart_settings=False) except FileNotFoundError: pass
def __init__(self, chart, palette, accent_values=None): super(AccentPalette, self).__init__(chart, palette) self._accent_color_map = None self.set_accent_values(accent_values) self.set_default_color( options.get_option('style.color_palette_accent_default_color'))