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

Publish plots with fallback/picture/PIL engine.

parent 8513e4bb
No related branches found
No related tags found
2 merge requests!19merge dev for new release v.0.1.2,!17Fallback engine implementation
......@@ -48,13 +48,9 @@ FIGS_AS_LIST = [FIG1, FIG2]
IMGS_AS_LIST = [img1, img2]
[TAGGED_FIGS, ID] = tagplot(IMGS_AS_LIST, PLOT_ENGINE, prefix=PROJECT_ID,
id_method='random', location='north')
id_method='random', location='west')
print(type(TAGGED_FIGS[0]))
# %% Save figure as tiff-file, but publish also exports the plot to a picture
# file in the destination folder.
# for i, figure in enumerate(TAGGED_FIGS):
# NAME = "Test"+str(i)+".tiff"
# figure.savefig(NAME)
# %% Publish
# Arguments: Source directory, destination directory, figure, plot name,
......@@ -62,4 +58,4 @@ print(type(TAGGED_FIGS[0]))
publish(['../README.md', '../tests', '../LICENSE'],
'/home/chief/Dokumente/fst/plotid_python/data',
FIGS_AS_LIST, 'Bild', 'individual')
TAGGED_FIGS, 'Bild', 'individual')
......@@ -53,13 +53,17 @@ def save_plot(figures, plot_names, extension='png'):
raise IndexError('There are more plot names than figures.')
plot_path = []
# match type(figures):
# case matplotlib.figure.Figure:
# PIL has different classes for different file formats. Therefore, the
# type is checked to contain 'PIL' and 'ImageFile'.
if all(x in str(type(figure)) for x in ['PIL', 'ImageFile']):
figure.save(plot_path)
elif 'matplotlib.figure.Figure' in str(type(figure)):
for i, fig in enumerate(figures):
plt.figure(fig)
plot_path.append(plot_names[i] + '.' + extension)
plt.savefig(plot_path[i])
# case _:
# raise TypeError('The given figure is not a valid figure object.')
else:
raise TypeError('The given figure is not a valid figure object.')
return plot_path
......@@ -51,5 +51,4 @@ def tagplot_image(plotid_object):
int(img.height*(1-plotid_object.position[1]))), txt)
plotid_object.figs[i] = img
# img.save(f'hello_{i}.png')
return [plotid_object.figs, ids_as_list]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment