Plots

Plots are used to visualize data from one or more reports. VaRA-TS comes with its own plot abstraction that uses pyplot, seaborn and similar for plotting, which can tie plot and research data together to be automatically generated.

How to plot your data with VaRA-TS

You can plot your data either by directly using the vara-plot tool, or if you are working with a paper config and want to automate plot generation, take a look at Artefacts.

How to add a new plot in VaRA-TS

You can create a new plot by creating a subclass of Plot. The plot will then be available under the name you declare in the class-level field NAME. Each plot class must override the abstract function plot() that is responsible for generating the plot, as well as the abstract function show() that is called when the plot sould only displayed, but not saved. The latter usually consists of a call self.plot(), followed by a call to pyplot.show().

The data for plots should be retrieved using our data storage abstraction.

Plot helper modules

Module: plot

Base plot module.

exception varats.plot.plot.PlotDataEmpty[source]

Bases: Exception

Throw if there was no input data for plotting.

class varats.plot.plot.Plot(name, **kwargs)[source]

Bases: object

An abstract base class for all plots generated by VaRA-TS.

property name: str

Name of the current plot.

Test: >>> Plot(‘test’).name ‘test’

Return type

str

property style: str

Current plot style.

Test: >>> Plot(‘test’).style ‘classic’

Return type

str

property plot_kwargs: Any

Access the kwargs passed to the initial plot.

Test: >>> p = Plot(‘test’, foo=’bar’, baz=’bazzer’) >>> p.plot_kwargs[‘foo’] ‘bar’ >>> p.plot_kwargs[‘baz’] ‘bazzer’

Return type

Any

static supports_stage_separation()[source]

True, if the plot supports stage separation, i.e., the plot can be drawn separating the different stages in a case study.

Return type

bool

abstract plot(view_mode)[source]

Plot the current plot to a file.

Return type

None

show()[source]

Show the current plot.

Return type

None

plot_file_name(filetype)[source]

Get the file name this plot; will be stored to when calling save.

Parameters

filetype (str) – the file type for the plot

Return type

str

Returns

the file name the plot will be stored to

Test: >>> p = Plot(‘test’, project=’bar’) >>> p.plot_file_name(‘svg’) ‘bar_test.svg’ >>> p = Plot(‘foo’, project=’bar’, plot_case_study=CaseStudy(‘baz’, 42)) >>> p.plot_file_name(‘png’) ‘baz_42_foo.png’

save(path=None, filetype='svg')[source]

Save the current plot to a file.

Parameters
  • path (Optional[Path]) – The path where the file is stored (excluding the file name).

  • filetype (str) – The file type of the plot.

Return type

None

abstract calc_missing_revisions(boundary_gradient)[source]

Calculate a list of revisions that could improve precisions of this plot.

Parameters

boundary_gradient (float) – The maximal expected gradient in percent between two revisions, every thing that exceeds the boundary should be further analyzed.

Return type

Set[str]

plots: Dict[str, Type[Any]] = {'plot': <class 'varats.plot.plot.Plot'>}

Module: plot_utils

Plot module for util functionality.

varats.plot.plot_utils.check_required_args(required_args)[source]

Check if all required graph args are passed by the user.

Return type

Callable[[Callable[..., Any]], Callable[..., Any]]

varats.plot.plot_utils.find_missing_revisions(data, git_path, cmap, should_insert_revision, to_commit_hash, are_neighbours)[source]

Calculate a set of revisions that could be missing because the changes between certain points are to steep.

Return type

Set[str]

varats.plot.plot_utils.pad_axes(ax, pad_x=None, pad_y=None)[source]

Add some padding to the axis limits.

Return type

None

varats.plot.plot_utils.align_yaxis(ax1, value1, ax2, value2)[source]

Adjust ax2 ylimit so that value2 in ax2 is aligned to value1 in ax1.

See https://stackoverflow.com/a/26456731

Return type

None

varats.plot.plot_utils.adjust_yaxis(ax, ydif, value)[source]

Shift axis ax by ydiff, maintaining point value at the same location.

See https://stackoverflow.com/a/26456731

Return type

None


Module: plots

General plots module.

class varats.plot.plots.PlotRegistry(name, bases, attrs)[source]

Bases: type

Registry for all supported plots.

to_snake_case_pattern = re.compile('(?<!^)(?=[A-Z])')
plots: Dict[str, Type[Any]] = {'plot': <class 'varats.plot.plot.Plot'>}
plots_discovered = False
static get_plot_types_help_string()[source]

Generates help string for visualizing all available plots.

Return type

str

Returns

a help string that contains all available plot names.

static get_class_for_plot_type(plot_type)[source]

Get the class for plot from the plot registry.

Parameters

plot_type (str) – The name of the plot.

Returns: The class implementing the plot.

Return type

Type[varats.plot.plot.Plot]

varats.plot.plots.build_plots(**args)[source]

Build the specfied plot(s).

Parameters

**args – the arguments for the plot(s)

Return type

None

varats.plot.plots.build_plot(plot)[source]

Builds the given plot.

Parameters

plot (varats.plot.plot.Plot) – the plot to build

Return type

None

varats.plot.plots.prepare_plot(**kwargs)[source]

Instantiate a plot with the given args.

Parameters

**kwargs – the arguments for the plot

Return type

varats.plot.plot.Plot

Returns

the instantiated plot

varats.plot.plots.prepare_plots(**args)[source]

Instantiate the specified plot(s).

First, compute missing arguments that are needed by most plots.

Parameters

**args – the arguments for the plot(s)

Return type

Iterable[varats.plot.plot.Plot]

Returns

an iterable of instantiated plots