Skip to content
Snippets Groups Projects
Commit 6f716786 authored by Mayr, Hannes's avatar Mayr, Hannes
Browse files

Allow to not print the ID on to the plot by passing id_on_plot=False to tagplot().

parent db346d3c
No related branches found
No related tags found
2 merge requests!52Create v0.2.2,!45Allow to not print the ID on to the plot by passing id_on_plot=False to tagplot().
Pipeline #850100 waiting for manual action
......@@ -64,6 +64,8 @@ Optional parameters can be used to customize the tag process.
Location for ID to be displayed on the plot. Default is 'east'.
- *qrcode* : boolean, optional
Experimental support for encoding the ID in a QR Code.
- *id_on_plot* : boolean, optional
Print ID on the plot. Default: True.
Example:
```python
......
......@@ -40,6 +40,8 @@ class PlotOptions:
The default is 'time'.
qrcode : bool, optional
Experimental status. Print qrcode on exported plot. Default: False.
id_on_plot: bool, optional
Print ID on the plot. Default: True.
"""
def __init__(self, figs, rotation, position, **kwargs):
......@@ -51,6 +53,7 @@ class PlotOptions:
self.prefix = kwargs.get("prefix", "")
self.id_method = kwargs.get("id_method", "time")
self.qrcode = kwargs.get("qrcode", False)
self.id_on_plot = kwargs.get("id_on_plot", True)
def __str__(self):
"""Representation if an object of this class is printed."""
......
......@@ -48,6 +48,7 @@ def tagplot_image(plotid_object):
plotid_object.figure_ids.append(img_id)
img = Image.open(img)
if plotid_object.id_on_plot:
img_txt = Image.new("L", font.getsize(img_id))
draw_txt = ImageDraw.Draw(img_txt)
draw_txt.text((0, 0), img_id, font=font, fill=255)
......
......@@ -47,8 +47,9 @@ def tagplot_matplotlib(plotid_object):
fig_id = create_id(plotid_object.id_method)
fig_id = plotid_object.prefix + fig_id
plotid_object.figure_ids.append(fig_id)
plt.figure(fig)
if plotid_object.id_on_plot:
plt.figtext(
x=plotid_object.position[0],
y=plotid_object.position[1],
......
......@@ -39,14 +39,19 @@ class TestTagplot(unittest.TestCase):
Test if the string representation of a PlotOptions object is correct.
"""
plot_obj = PlotOptions(
"FIG", ROTATION, POSITION, prefix="xyz", id_method="random"
"FIG",
ROTATION,
POSITION,
prefix="xyz",
id_method="random",
id_on_plot=False,
)
self.assertEqual(
str(plot_obj),
"<class 'plotid.plotoptions.PlotOptions'>: {'figs': "
"'FIG', 'figure_ids': [], 'rotation': 270, 'position'"
": (100, 200), 'prefix': 'xyz', 'id_method': "
"'random', 'qrcode': False}",
"'random', 'qrcode': False, 'id_on_plot': False}",
)
def test_str_plotidtransfer(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment