Skip to content
Snippets Groups Projects

Fallback engine implementation

16 files
+ 362
66
Compare changes
  • Side-by-side
  • Inline

Files

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