def plot(self, table, axes): colors = Qualitative() legend_lines = [] x_column = table.columns[self._x_column_name] if not isinstance(x_column.data_type, agate.Number) and \ not isinstance(x_column.data_type, agate.Date) and \ not isinstance(x_column.data_type, agate.DateTime): raise ValueError('Only Number, Date and DateTime data are supported for line chart X-axis.') for y_column_name in self._y_column_names: y_column = table.columns[y_column_name] if not isinstance(y_column.data_type, agate.Number): raise ValueError('Only Number data is supported for line chart Y-axis.') plot_lines = axes.plot( x_column, y_column, linewidth=2, color=colors.next(), label=y_column_name ) legend_lines.append(plot_lines[0]) axes.set_xlabel(self._x_column_name) if len(self._y_column_names) == 1: axes.set_ylabel(self._y_column_names[0]) return (legend_lines, self._y_column_names)
def plot(self, table, axes): colors = Qualitative() legend_lines = [] x_column = table.columns[self._x_column_name] if not isinstance(x_column.data_type, agate.Number) and \ not isinstance(x_column.data_type, agate.Date) and \ not isinstance(x_column.data_type, agate.DateTime): raise ValueError( 'Only Number, Date and DateTime data are supported for line chart X-axis.' ) for y_column_name in self._y_column_names: y_column = table.columns[y_column_name] if not isinstance(y_column.data_type, agate.Number): raise ValueError( 'Only Number data is supported for line chart Y-axis.') plot_lines = axes.plot(x_column, y_column, linewidth=2, color=colors.next(), label=y_column_name) legend_lines.append(plot_lines[0]) axes.set_xlabel(self._x_column_name) if len(self._y_column_names) == 1: axes.set_ylabel(self._y_column_names[0]) return (legend_lines, self._y_column_names)
def plot(self, table, axes): label_column = table.columns[self._label_column_name] if not isinstance(label_column.data_type, agate.Text) and \ not isinstance(label_column.data_type, agate.Number) and \ not isinstance(label_column.data_type, agate.Date): raise ValueError( 'Only Text, Number and Date data are supported for bar chart labels.' ) series_count = len(self._value_column_names) positions = range(len(label_column)) colors = Qualitative() legend_bars = [] bar_area = 0.65 bar_height = bar_area / len(self._value_column_names) # Display first value at the top of the chart. positions.reverse() for i, value_column_name in enumerate(self._value_column_names): value_column = table.columns[value_column_name] if not isinstance(value_column.data_type, agate.Number): raise ValueError( 'Only Number data is supported for bar chart values.') series_positions = [] for j in positions: series_positions.append(j + (series_count - i) * bar_height) plot_bars = axes.barh(series_positions, value_column, bar_height, color=colors.next(), linewidth=0, label=value_column_name) legend_bars.append(plot_bars[0]) axes.set_ylabel(self._label_column_name) axes.set_yticks([ p + (series_count - i) * bar_height + (bar_area / 2) for p in positions ]) axes.set_yticklabels(table.columns[self._label_column_name]) if len(self._value_column_names) == 1: axes.set_xlabel(self._value_column_names[0]) return (legend_bars, self._value_column_names)
def plot(self, table, axes): label_column = table.columns[self._label_column_name] if ( not isinstance(label_column.data_type, agate.Text) and not isinstance(label_column.data_type, agate.Number) and not isinstance(label_column.data_type, agate.Date) ): raise ValueError("Only Text, Number and Date data are supported for bar chart labels.") series_count = len(self._value_column_names) positions = range(len(label_column)) colors = Qualitative() legend_bars = [] bar_area = 0.65 bar_height = bar_area / len(self._value_column_names) # Display first value at the top of the chart. positions.reverse() for i, value_column_name in enumerate(self._value_column_names): value_column = table.columns[value_column_name] if not isinstance(value_column.data_type, agate.Number): raise ValueError("Only Number data is supported for bar chart values.") series_positions = [] for j in positions: series_positions.append(j + (series_count - i) * bar_height) plot_bars = axes.barh( series_positions, value_column, bar_height, color=colors.next(), linewidth=0, label=value_column_name ) legend_bars.append(plot_bars[0]) axes.set_ylabel(self._label_column_name) axes.set_yticks([p + (series_count - i) * bar_height + (bar_area / 2) for p in positions]) axes.set_yticklabels(table.columns[self._label_column_name]) if len(self._value_column_names) == 1: axes.set_xlabel(self._value_column_names[0]) return (legend_bars, self._value_column_names)
def plot(self, table, axes): label_column = table.columns[self._label_column_name] if not isinstance(label_column.data_type, agate.Text) and \ not isinstance(label_column.data_type, agate.Number) and \ not isinstance(label_column.data_type, agate.Date): raise ValueError('Only Text, Number and Date data are supported for bar chart labels.') positions = range(len(label_column)) colors = Qualitative() legend_bars = [] bar_area = 0.65 bar_width = bar_area / len(self._value_column_names) for i, value_column_name in enumerate(self._value_column_names): value_column = table.columns[value_column_name] if not isinstance(value_column.data_type, agate.Number): raise ValueError('Only Number data is supported for column chart values.') series_positions = [] for j in positions: series_positions.append(positions[j] + (i * bar_width)) plot_bars = axes.bar( series_positions, value_column, bar_width, color=colors.next(), linewidth=0, label=value_column_name ) legend_bars.append(plot_bars[0]) axes.set_xlabel(self._label_column_name) axes.set_xticks([p + (bar_area / 2) for p in positions]) axes.set_xticklabels(table.columns[self._label_column_name]) if len(self._value_column_names) == 1: axes.set_ylabel(self._value_column_names[0]) return (legend_bars, self._value_column_names)