Skip to content

fairvis.export

Export of an assessment as one figure, e.g. for a manuscript.

The figure is rendered by kaleido in a headless Chrome or Chromium, started for each rendering. The shared server of kaleido is not used: it mixes up the results of concurrent calls and blocks if no browser is installed.

EXPORT_FORMATS module-attribute

EXPORT_FORMATS = {
    "png": "image/png",
    "jpeg": "image/jpeg",
    "svg": "image/svg+xml",
    "pdf": "application/pdf",
}

Formats of the export with their MIME type.

WIDTH module-attribute

WIDTH = 1000

Width of the exported figure in px, the unit of the vector formats.

HEIGHT module-attribute

HEIGHT = 1400

Height of the exported figure in px.

SCALE module-attribute

SCALE = 3

Scale of the raster formats: 3000 px wide, 300 dpi at a width of 10 inch.

combined_figure

combined_figure(df_data, name)

One figure of an assessment: the bar plot above the polar bar plots.

The figure has one legend of the categories and states the version of fair-ca-visualization and its DOI, so it can be cited.

Parameters:

Name Type Description Default
df_data DataFrame

assessment of a model, see fairvis.data_io.load_assessment.

required
name str

name of the assessed model, shown in the title as text.

required

Returns:

Type Description
Figure

the figure, sized for the export.

browser_available

browser_available()

Whether a Chrome or Chromium for the export is installed.

Returns:

Type Description
bool

True if kaleido finds a browser, also one installed with plotly_get_chrome.

figure_bytes

figure_bytes(fig, fmt)

Render a figure as a file.

Parameters:

Name Type Description Default
fig Figure

the figure, e.g. of combined_figure.

required
fmt str

format of the file, a key of EXPORT_FORMATS.

required

Returns:

Type Description
bytes

the content of the file.

Raises:

Type Description
ValueError

if the format is not one of EXPORT_FORMATS.

RuntimeError

if no Chrome or Chromium is installed.