Something went wrong on our end
Select Git revision
EV3.doctree
-
Tim Stadtmann authored
Sphinx generates a redundant html-file 'source.html'. Each internal href, derived from a link to a class/method/attribute, links source.html and not the corresponding file (e.g. EV3.html when referencing EV3.connect()). The postprocessing script now fixes these wrong links.
Tim Stadtmann authoredSphinx generates a redundant html-file 'source.html'. Each internal href, derived from a link to a class/method/attribute, links source.html and not the corresponding file (e.g. EV3.html when referencing EV3.connect()). The postprocessing script now fixes these wrong links.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
tagplot.py 2.66 KiB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tag your plot with an ID.
For publishing the tagged plot along your research data have a look at the
module publish.
Functions:
TagPlot(figure object, string) -> list
"""
import warnings
from plotoptions import PlotOptions
from tagplot_matplotlib import tagplot_matplotlib
def tagplot(figs, engine, prefix='', id_method=1, location='east'):
"""
Tag your figure/plot with an ID.
After determining the plot engine, TagPlot calls the corresponding
function which tags the plot.
Parameters
----------
figs : list
Figures that should be tagged.
engine : string
Plot engine which should be used to tag the plot.
prefix : string
Will be added as prefix to the ID.
id_method : int, optional
id_method for creating the ID. Create an ID by Unix time is referenced
as 1, create a random ID with id_method=2. The default is 1.
location : string, optional
Location for ID to be displayed on the plot. Default is 'east'.
Raises
------
RuntimeWarning
DESCRIPTION.
Returns
-------
list
The resulting list contains two lists each with as many entries as
figures were given. The first list contains the tagged figures.
The second list contains the corresponding IDs as strings.
"""
if isinstance(location, str):
pass
else:
raise TypeError("Location is not a string.")
match location:
case 'north':
rotation = 0
position = (0.35, 0.975)
case 'east':
rotation = 90
position = (0.975, 0.35)
case 'south':
rotation = 0
position = (0.35, 0.015)
case 'west':
rotation = 90
position = (0.025, 0.35)
case 'southeast':
rotation = 0
position = (0.75, 0.015)
case 'custom':
# TODO: Get rotation and position from user input & check if valid
rotation = 0
position = (0.5, 0.5)
case _:
warnings.warn(f'Location "{location}" is not a defined '
'location, TagPlot uses location "east" '
'instead.')
rotation = 90
position = (0.975, 0.35)
option_container = PlotOptions(figs, prefix, id_method,
rotation, position)
option_container.validate_input()
match engine:
case 'matplotlib' | 'pyplot':
return tagplot_matplotlib(option_container)
case _:
raise ValueError(
f'The plot engine "{engine}" is not supported.')