Figure Builder

class eddington.plot.figure_builder.FigureBuilder(title: dataclasses.InitVar = None, xlabel: dataclasses.InitVar = None, ylabel: dataclasses.InitVar = None, grid: dataclasses.InitVar = False, legend: dataclasses.InitVar = False)

Builder class for creating a figure.

add_data(data: eddington.fitting_data.FittingData, label: Optional[str] = None, color: Optional[str] = None)

Add scatter to figure.

Parameters:
  • data – Data to plot
  • label (str) – Label of the error bar to add to the legend.
  • color (str) – Color of the error bar.
Returns:

self

Return type:

FigureBuilder

Raises:

PlottingError – Raised when data doesn’t have x or y values

add_error_bar(x: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e8050>, List[float]], xerr: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e8110>, List[float], None], y: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e81d0>, List[float]], yerr: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e8290>, List[float], None], label: Optional[str] = None, color: Optional[str] = None)

Add error bar to figure.

Parameters:
  • x (floats list or numpy.ndarray) – X values of the error bar
  • xerr (floats list or numpy.ndarray) – X error values of the error bar
  • y (floats list or numpy.ndarray) – Y values of the error bar
  • yerr (floats list or numpy.ndarray) – Y error values of the error bar
  • label (str) – Label of the error bar to add to the legend.
  • color (str) – Color of the error bar.
Returns:

self

Return type:

FigureBuilder

add_grid()

Set grid lines to figure.

Returns:self
Return type:FigureBuilder
add_horizontal_line(interval: eddington.interval.Interval, y_value: float, linestyle: eddington.plot.line_style.LineStyle = <LineStyle.SOLID: 'solid'>, color: Optional[str] = None)

Add horizontal line to figure.

Parameters:
  • interval (Interval) – Interval representing x values
  • y_value (float) – y value of the horizontal line
  • linestyle (LineStyle) – Line style of the horizontal line
  • color (str) – Optional. Color of the line style
Returns:

self

Return type:

FigureBuilder

add_instruction(instruction: eddington.plot.figure_builder.FigureInstruction) → eddington.plot.figure_builder.FigureBuilder

Add general instruction to plot building.

Parameters:instruction (FigureInstruction) – Instruction instance for what to add to the figure
Returns:self
Return type:FigureBuilder
Raises:PlottingError – Raised when trying to add a unique instruction for the second time.
add_legend()

Set legend lines to figure.

Returns:self
Return type:FigureBuilder
add_plot(interval: eddington.interval.Interval, a: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e84d0>, List[float]], func: eddington.fitting_function_class.FittingFunction, label: Optional[str] = None, color: Optional[str] = None, linestyle: eddington.plot.line_style.LineStyle = <LineStyle.SOLID: 'solid'>)

Add plot to figure.

Parameters:
  • interval (Interval) – Interval representing x values
  • func (FittingFunction) – Function to show its plot
  • a (floats list or numpy.ndarray) – parameters to use as input to fitting function
  • label (str) – Label of the plot to add to the legend.
  • color (str) – Optional. Color of the line style
  • linestyle (LineStyle) – Line style of the horizontal line
Returns:

self

Return type:

FigureBuilder

add_scatter(x: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e8350>, List[float]], y: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a80e8410>, List[float]], label: Optional[str] = None, color: Optional[str] = None)

Add scatter to figure.

Parameters:
  • x (floats list or numpy.ndarray) – X values of the error bar
  • y (floats list or numpy.ndarray) – Y values of the error bar
  • label (str) – Label of the error bar to add to the legend.
  • color (str) – Color of the error bar.
Returns:

self

Return type:

FigureBuilder

add_title(title: str)

Add title instruction to figure.

Parameters:title (str) – Title to add to the figure
Returns:self
Return type:FigureBuilder
add_x_log_scale()

Set x axis scale to logarithmic scale.

Returns:self
Return type:FigureBuilder
add_xlabel(xlabel: str)

Add x label instruction to figure.

Parameters:xlabel (str) – X axis label to add to the figure
Returns:self
Return type:FigureBuilder
add_y_log_scale()

Set y axis scale to logarithmic scale.

Returns:self
Return type:FigureBuilder
add_ylabel(ylabel: str)

Add y label instruction to figure.

Parameters:ylabel (str) – Y axis label to add to the figure
Returns:self
Return type:FigureBuilder
build() → eddington.plot.figure.Figure

Build figure.

Returns:Built figure item
Return type:Figure
grid = False
legend = False
title = None
xlabel = None
ylabel = None