Skip to content
Snippets Groups Projects

Fallback engine implementation

Merged Mayr, Hannes requested to merge fallback into dev
16 files
+ 362
66
Compare changes
  • Side-by-side
  • Inline
Files
16
+ 19
19
@@ -2,14 +2,13 @@
"""
Example workflow for integrating plotID.
With tagplot an ID can be generated an printed on the plot. To export the plot
along with the corresponding research data and the plot generating script use
the function publish.
With tagplot() an ID can be generated and printed on the plot. To export the
plot along with the corresponding research data and the plot generating
script use the function publish().
"""
# %% Import modules
import numpy as np
# import h5py as h5
import matplotlib.pyplot as plt
from plotid.tagplot import tagplot
from plotid.publish import publish
@@ -17,44 +16,45 @@ from plotid.publish import publish
# %% Set Project ID
PROJECT_ID = "MR04_"
# %% Choose Plot engine
PLOT_ENGINE = "matplotlib"
# %% Create sample data
x = np.linspace(0, 10, 100)
y = np.random.rand(100) + 2
y_2 = np.sin(x) + 2
# %% Create figures
# %% Create sample figures
# 1. figure
IMG1 = 'image1.png'
FIG1 = plt.figure()
plt.plot(x, y, color='black')
plt.plot(x, y_2, color='yellow')
plt.savefig(IMG1)
# 2. figure
IMG2 = 'image2.png'
FIG2 = plt.figure()
plt.plot(x, y, color='blue')
plt.plot(x, y_2, color='red')
plt.savefig(IMG2)
# %% TagPlot
# If multiple figures should be tagged, figures must be provided as list.
FIGS_AS_LIST = [FIG1, FIG2]
IMGS_AS_LIST = [IMG1, IMG2]
[TAGGED_FIGS, ID] = tagplot(FIGS_AS_LIST, PLOT_ENGINE, prefix=PROJECT_ID,
id_method='random', location='west')
# Example for how to use tagplot with matplotlib figures
[TAGGED_FIGS, ID] = tagplot('FIGS_AS_LIST', 'matplotlib', prefix=PROJECT_ID,
id_method='time', location='west')
# %% 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)
# Example for how to use tagplot with image files
# [TAGGED_FIGS, ID] = tagplot(IMGS_AS_LIST, 'image', prefix=PROJECT_ID,
# id_method='random', location='west')
# %% Publish
# Arguments: Source directory, destination directory, figure, plot name,
# publish-mode).
# Arguments: Source directory or files as list, destination directory, figures,
# plots or images.
publish(['../README.md', '../tests', '../LICENSE'],
publish(['../README.md', '../dist', '../LICENSE'],
'/home/chief/Dokumente/fst/plotid_python/data',
FIGS_AS_LIST, 'Bild', 'individual')
TAGGED_FIGS, 'Bild')
Loading