Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_matlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_matlab
Commits
bd3d59df
Commit
bd3d59df
authored
3 years ago
by
Lemmer, Jan
Browse files
Options
Downloads
Patches
Plain Diff
Fixes
#21
, Fixes Error when trying to export the same ID again
parent
ae012aaf
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!13
PreRelease_V0.1
,
!12
PreRelease_V0.1
,
!3
Fixes #21, Fixes Error when trying to export the same ID again
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CI_files/default_test.m
+6
-0
6 additions, 0 deletions
CI_files/default_test.m
example.m
+33
-11
33 additions, 11 deletions
example.m
fcn_core/Publish.m
+25
-16
25 additions, 16 deletions
fcn_core/Publish.m
fcn_core/TagPlot.m
+16
-8
16 additions, 8 deletions
fcn_core/TagPlot.m
with
80 additions
and
35 deletions
CI_files/default_test.m
+
6
−
0
View file @
bd3d59df
...
...
@@ -5,6 +5,12 @@ function [result] = default_test()
clear
;
clc
;
close
all
;
addpath
(
'./fcn_core'
,
'./fcn_help'
);
% clean up, if previous run failed
try
delete
CI_files
/
export
/
*
CI_files
/
*.
mat
CI_files
/
*.
h5
rmdir
(
'CI_files/export'
,
's'
);
end
ProjectID
=
'Test01'
;
%% Data
% some random data
...
...
This diff is collapsed.
Click to expand it.
example.m
+
33
−
11
View file @
bd3d59df
...
...
@@ -55,33 +55,55 @@ a = example_fcn(a);
% Make sure to save each figure in a variable to pass to PlotID-functions.
fig
(
1
)
=
figure
;
plot
(
x
,
y
,
'-k'
);
box
off
set
(
gca
,
'TickDir'
,
'out'
,
'YLim'
,
[
0
,
4
]);
hold
on
%fig(2) = figure;
box
off
;
hold
on
;
plot
(
x1
,
y1
,
'-r'
);
set
(
gca
,
'TickDir'
,
'out'
,
'YLim'
,
[
0
,
4
]);
%% Example 1: single plot based on two data-sets
%% Tag the plot
% PlotID Implementation starts here.
% TagPlot adds a visible ID to the figure and to the property
fig.Tag
[
figs
,
ID
]
=
TagPlot
(
fig
,
ProjectID
);
% TagPlot adds a visible ID to the figure
(s)
and to the
figures
property
% 'Tag'
[
fig
,
ID
]
=
TagPlot
(
fig
,
ProjectID
);
%% Publishing
% Second part of plotID
% The functions needs the file location, the location of the data and the
% figure and can take several options.
% TODO add explanations for Options
path
.
script
=
mfilename
(
'fullpath'
);
% filename of the m.script
% file name of the dataset
path
.
script
=
mfilename
(
'fullpath'
);
% filename of the m.script
% file names of the datasets
path
.
rdata
=
{
dataset1
,
dataset2
}
;
% don't forget the extension
Publish
(
path
,
ID
,
figs
,
'Location'
,
'local'
,
'Method'
,
'centraliced'
)
Publish
(
path
,
ID
,
fig
(
1
),
'Location'
,
'local'
,
'Method'
,
'centraliced'
)
%% Example 2 : multiple plots plot, all based on two data-set2
% for individual data-sets, use an appropriate array
fig
(
2
)
=
figure
;
plot
(
x
,
y
,
'-b'
);
box
off
;
hold
on
;
plot
(
x1
,
y1
,
'--k'
);
set
(
gca
,
'TickDir'
,
'out'
,
'YLim'
,
[
0
,
4
]);
% tag both plots
[
fig
,
IDs
]
=
TagPlot
(
fig
,
ProjectID
);
% data locations
path
.
script
=
mfilename
(
'fullpath'
);
% filename of the m.script
% file names of the datasets
path
.
rdata
=
{
dataset2
}
;
% don't forget the extension
% publsihing via for-loop
for
i
=
1
:
numel
(
fig
)
disp
(
string
(
i
));
Publish
(
path
,
IDs
{
i
},
fig
(
i
),
'Location'
,
'local'
,
'Method'
,
'centraliced'
);
end
%% Second Plot with identical data to test centralized method
% ToDO Add better description
fig2
=
figure
;
plot
(
x
,
y
,
'-k'
);
...
...
This diff is collapsed.
Click to expand it.
fcn_core/Publish.m
+
25
−
16
View file @
bd3d59df
function
Publish
(
DataPaths
,
ID
,
figure
s
,
options
)
function
Publish
(
DataPaths
,
ID
,
figure
,
options
)
%Publishes saves plot, data and measuring script
% Location sets the storage location. 'local' sets the storage location
% to the current folder (an export folder will be created), 'server' is a
...
...
@@ -10,12 +10,21 @@ function Publish(DataPaths, ID, figures, options)
arguments
DataPaths
ID
(
1
,:)
{
mustBeNonzeroLengthText
}
% ID must be provided
figure
s
(
1
,:)
{
mustBeFigure
}
% Checks if
F
igures a
re
figure
s
figure
(
1
,:)
{
mustBeFigure
}
% Checks if
f
igure
i
s a figure
object
options
.
Location
{
mustBeMember
(
options
.
Location
,[
'local'
,
'server'
,
'CI-Test'
])}
=
'local'
% storage path
options
.
Method
{
mustBeMember
(
options
.
Method
,[
'individual'
,
'centraliced'
])}
=
'individual'
options
.
CopyUserFCN
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
true
end
%catch multiple figures in fig
if
numel
(
figure
)
>
1
figure
=
figure
(
1
);
msg
=
[
'Publish is designed for handeling one figure at once'
newline
,
...
'- publishes uses only the first figure.'
newline
,
...
'Consider an external for loop for multi figure export as provided in example.m'
];
warning
(
msg
);
end
switch
options
.
Location
case
'local'
storPath
=
fullfile
(
pwd
,
'export'
);
...
...
@@ -28,7 +37,9 @@ folderName = char(ID);
%% Create Data-Directory
addpath
(
storPath
);
if
mkdir
(
fullfile
(
storPath
,
folderName
))
if
isfolder
(
fullfile
(
storPath
,
folderName
))
error
([
'Folder '
,
folderName
,
' exists - Plot was already published '
]);
elseif
mkdir
(
fullfile
(
storPath
,
folderName
))
else
error
(
'Directory could not be created - check remote path and permissions'
);
end
...
...
@@ -79,20 +90,18 @@ switch options.Method
% Create a copy of the research data
createFileCopy
(
DataPaths
.
rdata
,
folderName
,
storPath
,
ID
,
'data'
);
end
%% Export the Plots
try
for
i
=
1
:
numel
(
figures
)
fig
=
figures
(
i
);
PlotName
=
[
ID
,
'_plot'
,
num2str
(
i
)];
% Der Plotnamen
%% Export the Plot
%try
PlotName
=
[
ID
,
'_plot'
];
% plotname
RemotePath
=
fullfile
(
storPath
,
folderName
,
PlotName
);
% Matlab figure
savefig
(
fig
,
RemotePath
);
exportgraphics
(
fig
,[
RemotePath
,
'.png'
],
'Resolution'
,
300
);
disp
([
num2str
(
i
),
' of '
,
num2str
(
numel
(
figures
)),
' figures exported'
]
);
end
catch
warning
(
'Plot export was not successful'
)
end
savefig
(
fig
ure
,
RemotePath
);
% the png should only be a preview
exportgraphics
(
figure
,[
RemotePath
,
'.png'
],
'Resolution'
,
300
);
%
end
%
catch
%
warning('Plot export was not successful')
%
end
disp
([
'publishing of '
,
ID
,
' done'
]);
...
...
@@ -100,5 +109,5 @@ end %function
function
tf
=
mustBeFigure
(
h
)
%checks if input is a figure object
tf
=
strcmp
(
get
(
h
,
'type'
),
'figure'
)
&
isa
(
h
,
'matlab.ui.Figure'
);
tf
=
strcmp
(
get
(
h
,
'type'
),
'figure'
)
&
isa
(
h
,
'matlab.ui.Figure'
);
end
This diff is collapsed.
Click to expand it.
fcn_core/TagPlot.m
+
16
−
8
View file @
bd3d59df
function
[
figs
,
ID
]
=
TagPlot
(
figs
,
prefix
,
options
)
function
[
figs
,
ID
s
]
=
TagPlot
(
figs
,
prefix
,
options
)
%TagPlot adds IDs to figures
% The ID is placed visual on the figure window and as Tag (property of figure)
% TagPlot can tag multiple figures at once
% TagPlot can tag multiple figures at once.
% If a single Plot is taged IDs is a char, otherwise it is a cell array of
% chars
% prefix is the project number (string or char)
%
% The ID is placed on the 'east' per default, if you want it somwhere
...
...
@@ -44,21 +46,27 @@ switch options.Location
warning
([
options
.
Location
,
' is not a defined location, TagPlot uses location east instead'
]);
options
.
Location
=
'east'
;
options
.
Position
=
[
1
,
0.4
];
end
IDs
=
cell
(
numel
(
figs
),
1
);
for
n
=
1
:
numel
(
figs
)
ID
=
CreateID
;
% Create ID
ID
=
[
prefix
,
'-'
,
ID
];
% add Prefix
ID
s
{
n
}
=
CreateID
;
% Create ID
ID
s
{
n
}
=
[
prefix
,
'-'
,
ID
s
{
n
}
];
% add Prefix
axes
=
get
(
figs
(
n
),
'CurrentAxes'
);
% Axes object for text annotation
% Limits for relative Positioning
ylim
=
get
(
axes
,
'YLim'
);
xlim
=
get
(
axes
,
'XLim'
);
%ID
position
=
[
options
.
Position
(
1
)
*
xlim
(
2
),
options
.
Position
(
2
)
*
ylim
(
2
)];
text
(
axes
,
position
(
1
),
position
(
2
),
ID
,
'Fontsize'
,
options
.
Fontsize
,
...
text
(
axes
,
position
(
1
),
position
(
2
),
ID
s
{
n
}
,
'Fontsize'
,
options
.
Fontsize
,
...
'Rotation'
,
options
.
Rotation
,
'VerticalAlignment'
,
'bottom'
,
'Color'
,
...
0.65
*
[
1
1
1
],
'BackgroundColor'
,
'w'
);
set
(
figs
(
n
),
'Tag'
,
ID
);
set
(
figs
(
n
),
'Tag'
,
IDs
{
n
});
end
if
numel
(
figs
)
==
1
% use char instead of a cell arry for a single ID
IDs
=
IDs
{
1
};
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment