Skip to content
Snippets Groups Projects
Commit b8e75ae6 authored by nugget's avatar nugget
Browse files

Fix merge conflicts.

parent c9bc37e2
Branches
Tags
2 merge requests!12v.0.1 for alpha release,!8First OOP implementation of tagplot.py.
Image diff could not be displayed: it is too large. Options to address this: view the blob.
Image diff could not be displayed: it is too large. Options to address this: view the blob.
data/Bild.png

137 KiB

This diff is collapsed.
import matplotlib.pyplot as plt
def set_FST_template(project_directory):
plt.style.use(f'{project_directory}\\Code\\''FST.mplstyle')
class Colors():
def __init__(self):
self.rgb_colors = {
'blue' : (0, 0.31, 0.45),
'red' : (0.91, 0.31, 0.24),
'green' : (0.69, 0.8, 0.31),
'black' : (0, 0, 0),
'orange' : (0.93, 0.48, 0.20),
'petrol' : (0.31, 0.71, 0.58),
'grey' : (0.54, 0.54, 0.54),
'yellow' : (0.99, 0.79, 0)
}
def get_rgb(self, color_name):
if color_name in self.rgb_colors.keys():
return self.rgb_colors[color_name]
else:
print(f"Error: Color '{color_name}' does not exist.\nAvailable colors are: {list(self.rgb_colors.keys())}")
def get_color_names(self):
return list(self.rgb_colors.keys())
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 20 12:22:33 2021
example workflow for integrating plotIDs
@author: Richter
"""
# %% Module einbinden
import sys
import numpy as np
from numpy import random
# import h5py as h5
# import matplotlib
import matplotlib.pyplot as plt
from tagplot import PlotOptions, tagplot
from publish import publish
from fcn_help.FST_colors import Colors
plt.style.use('fcn_help/FST.mplstyle')
# %matplotlib qt
# %matplotlib inline
# %% Pfade hinzufügen
sys.path.append("fcn_core")
sys.path.append("fcn_help")
# %% 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
# Colors
colors = Colors() # create instance from class
color_list = colors.get_color_names()
# Create plot
color1 = colors.get_rgb('black')
color2 = colors.get_rgb('yellow')
# 1.Figure
fig1 = plt.figure()
plt.plot(x, y, color=color1)
plt.plot(x, y_2, color=color2)
# 2.Figure
plt.clf # Close figure
fig2 = plt.figure()
plt.plot(x, y, color=color2)
plt.plot(x, y_2, color=color1)
plt.clf # Close figure
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('fcn_help', '/home/chief/Dokumente/fst/plotid_python/data',
fig1, 'Bild', 'individual')
......@@ -28,6 +28,7 @@ y = random.rand(100) + 2
y_2 = np.sin(x) + 2
# %% Create figure
# Create plot
color1 = 'black'
color2 = 'yellow'
......
......@@ -9,6 +9,7 @@ from tagplot_matplotlib import tagplot_matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from tagplot import PlotOptions
# %% Create data
x = np.linspace(0, 10, 100)
......@@ -41,12 +42,15 @@ position = (0.975, 0.35)
class Test_tagplot_matplotlib(unittest.TestCase):
def test_mplfigures(self):
[figs, ID] = tagplot_matplotlib(
fig, ProjectID, method, rotation, position)
options = PlotOptions(fig, ProjectID, method, rotation, position)
[figs, ID] = tagplot_matplotlib(options)
self.assertIsInstance(figs[0], Figure)
self.assertIsInstance(figs[1], Figure)
def test_mplerror(self):
options = PlotOptions(3, ProjectID, method, rotation, position)
with self.assertRaises(TypeError):
tagplot_matplotlib(3, ProjectID, method, rotation, position)
tagplot_matplotlib(options)
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment