vfd package

Submodules

vfd.builder module

Mimic matplotlib interface to generate VFD files

class vfd.builder.AxesBuilder(axes=None)[source]

Bases: object

Class that mimics the behaviour of matplotlib.pyplot.axes to produce vfd files.

contour(*args, **kwargs)[source]
contourf(*args, **kwargs)[source]
errorbar(x, y, yerr=None, xerr=None, **kwargs)[source]
get_data()[source]
legend(*args, **kwargs)[source]
loglog(*args, **kwargs)[source]
pcolor(*args, **kwargs)[source]
pcolormesh(*args, **kwargs)[source]
plot(*args, **kwargs)[source]
semilogx(*args, **kwargs)[source]
semilogy(*args, **kwargs)[source]
set_title(title, *args)[source]
set_xlabel(label, **kwargs)[source]
set_xlim(*args, **kwargs)[source]
set_ylabel(label, **kwargs)[source]
set_ylim(*args, **kwargs)[source]
text(x, y, s, **kwargs)[source]
twinx()[source]
twiny()[source]
class vfd.builder.Builder(to_matplotlib=True)[source]

Bases: object

Class that mimics the behaviour of matplotlib.pyplot to produce vfd files.

Consider calling the supplant_pyplot method or adding “plt=Builder()” to your plotting script to add vfd file generation.

contour(*args, **kwargs)[source]
contourf(*args, **kwargs)[source]
errorbar(x, y, yerr=None, xerr=None, **kwargs)[source]
get_data()[source]
legend(*args, **kwargs)[source]
loglog(*args, **kwargs)[source]
pcolor(*args, **kwargs)[source]
pcolormesh(*args, **kwargs)[source]
plot(*args, **kwargs)[source]
savefig(fname, **kwargs)[source]
savevfd(fname)[source]

Save the data as a vfd file.

This method is automatically called when savefig is called, so whenever an image is exported, so it is the VFD. However, the original export is not overridden by the created VFD.

Parameters:fname – Path where the file will be saved. If the extension is not vfd, it will be changed to it.
semilogx(*args, **kwargs)[source]
semilogy(*args, **kwargs)[source]
show()[source]
subplots(*args, **kwargs)[source]
text(x, y, s, **kwargs)[source]
title(title, *args)[source]
to_json(compact=False, compact_arrays=True)[source]

Return a JSON representation of the data.

Parameters:
  • compact (bool) – Whether to save space in detriment of readability.
  • compact_arrays (bool) – If compact was False, whether to make 1d arrays of numbers compact. This both improves readability and saves space.
Returns:

A JSON representation of the data.

Return type:

str

xlabel(label, **kwargs)[source]
xlim(*args, **kwargs)[source]
ylabel(label, **kwargs)[source]
ylim(*args, **kwargs)[source]
class vfd.builder.FigureBuilder(builder, fig=None)[source]

Bases: object

Class that mimics the behaviour of matplotlib.pyplot.figure to produce vfd files.

savefig(fname, **kwargs)[source]
vfd.builder.supplant_pyplot()[source]

Replace the pyplot module by a Builder instance

vfd.cli module

Console script for vfd.

vfd.vfd module

Python API for vfd

vfd.vfd.create_matplotlib_script(description, export_name='untitled', context=None, export_format=None, marker_list=None, color_list=None, line_list=None, tight_layout=None, scale_multiplot=False)[source]

Create a matplotlib script to plot the VFD with the given description.

Parameters:
  • description (dict) – Description of the VFD, obtained parsing the JSON.
  • export_name (str) – Name to give to the script file and the plots generated therein.
  • context (str) – Matplotlib context to use in the script.
  • export_format (str or list of str) – Format(s) to export to.
  • marker_list (list of str) – Markers to use cyclically for series which are not joined.
  • color_list (list) – Colors to use when an index requests to do so.
  • line_list (list of str) – Line styles to use when requested.
  • tight_layout (bool) – Use the tight_layout function to fit the plot.
  • scale_multiplot (bool) – Whether to automatically increase the size of multiplots.
Returns:

Python code which will create the plot.

Return type:

str

vfd.vfd.create_scripts(path='.', run=False, blocking=True, expand_glob=True, **kwargs)[source]

Create a script to generate a plot for the VFD file in the given path.

Parameters:
  • path (str) – Path to the VFD file.
  • run (bool) – Whether to run the script upon creation.
  • blocking (bool) – If run is True, whether to wait for the calls to end.
  • expand_glob (bool) – Whether regular expressions are expanded (e.g., .vfd or *.vfd)
  • **kwargs – Additional arguments to supply to create_matplotlib_script.
Raises:
  • FileNotFoundError – If the file was not found.
  • json.JSONDecodeError – If the file was opened, but it is not a well-built JSON.
  • jsonschema.ValidationError – If the opened file was a well-built JSON but not a well-built VFD.
vfd.vfd.create_xlsx(path='.', expand_glob=True)[source]

Create a xlsx file for the VFD file in the given path.

Parameters:
  • path (str) – Path to the VFD file.
  • expand_glob (bool) – Whether regular expressions are expanded (e.g., .vfd or *.vfd)
Raises:
  • FileNotFoundError – If the file was not found.
  • json.JSONDecodeError – If the file was opened, but it is not a well-built JSON.
  • jsonschema.ValidationError – If the opened file was a well-built JSON but not a well-built VFD.
vfd.vfd.export_xlsx(description, file_path)[source]

Create a matplotlib script to plot the VFD with the given description.

Parameters:
  • description (dict) – Description of the VFD, obtained parsing the JSON.
  • file_path (str) – Path to the created file.
vfd.vfd.python_to_json(data, compact=False, compact_arrays=True)[source]

Return a JSON representation of the data.

Parameters:
  • data (dict) – A Python object representing a VFD.
  • compact (bool) – Whether to save space in detriment of readability.
  • compact_arrays (bool) – If compact was False, whether to make 1d arrays of numbers compact. This both improves readability and saves space.
Returns:

A JSON representation of the data.

Return type:

str

vfd.vfd.str_to_python(description)[source]

Find a Python representation for the given data in a string.

Parameters:

description (str) – A string defining the JSON object.

Returns:

A python representation of the VFD.

Return type:

dict

Raises:
  • json.JSONDecodeError – If the string does not define a well-built JSON.
  • jsonschema.ValidationError – If string defines a JSON but not a well-built VFD.
vfd.vfd.validate_vfd(data)[source]

Check if the given data is a well-built VFD

Parameters:data (dict) – The data to check
Raises:jsonschema.ValidationError – If the data is not a well-built VFD.

Module contents

Top-level package for Vernacular Figure Description.