Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
This project is licensed under the MIT License.
Learn more
example.py 1.37 KiB
# -*- coding: utf-8 -*-
"""
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.
"""
# %% Import modules
import numpy as np
from numpy import random
# import h5py as h5
# import matplotlib
import matplotlib.pyplot as plt
from tagplot import tagplot
from publish import publish
# %% Project ID
ProjectID = "MR04_"
# %% Plot engine
plot_engine = "matplotlib"
# %% Create sample data
x = np.linspace(0, 10, 100)
y = random.rand(100) + 2
y_2 = np.sin(x) + 2
# %% Create figure
# Create plot
color1 = 'black'
color2 = 'yellow'
# 1.Figure
fig1 = plt.figure()
plt.plot(x, y, color=color1)
plt.plot(x, y_2, color=color2)
# 2.Figure
fig2 = plt.figure()
plt.plot(x, y, color=color2)
plt.plot(x, y_2, color=color1)
fig = [fig1, fig2]
# %% TagPlot
# p1 = PlotOptions(fig, plot_engine, prefix=ProjectID,
# method='2', location='east')
# [figs, ID] = p1.tagplot()
[figs, ID] = tagplot(fig, plot_engine, prefix=ProjectID,
id_method='2', location='west')
# %% Figure als tiff-Datei abspeichern
for i, figure in enumerate(figs):
name = "Test"+str(i)+".tiff"
figure.savefig(name)
# %% Publish
publish('tests', '/home/chief/Dokumente/fst/plotid_python/data',
fig1, 'Bild', 'individual')