PlotID_example.m 2.5 KB
Newer Older
Hock, Martin's avatar
Hock, Martin committed
1
%% Example Script
Lemmer, Jan's avatar
Lemmer, Jan committed
2
% This Script is mend to demonstrate the capabilities of the PlotID tool.
Lemmer, Jan's avatar
Lemmer, Jan committed
3
% please run Initilisation.m before first time use
Lemmer, Jan's avatar
Lemmer, Jan committed
4
5

%% Clear and set environment
6
addpath('Examples');
Lemmer, Jan's avatar
Lemmer, Jan committed
7
clear; close all; clc;
Lemmer, Jan's avatar
Lemmer, Jan committed
8

9
10
%% Data (only necessary for this example)
[x, y, datapath] = createExampleData('matlab');
Hock, Martin's avatar
Hock, Martin committed
11

12
13
14
15
16
%% Plotting
% This is still part of a normal script to produce plots.
% Make sure to save each figure in a variable to pass it to PlotID-functions.
fig1 = figure;
plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]);
17

Lemmer, Jan's avatar
Lemmer, Jan committed
18
19
20
% -------------- PlotID Implementation starts here. -------------------------

%% ----- 1. Tag the plot -----
21
22
% TagPlot adds visible ID(s) to the figure(s) and to the figures property 'Tag'
% every time you run tagPlot you will get an new ID
23

24
25
26
27
% Syntax: 
% fig = PlotID.TagPlot(fig);
% [figs, IDs] = PlotID.TagPlot(figs);
% [figs, IDs] = PlotID.TagPlot(figs, options);
28

29
[fig1, ID] = PlotID.TagPlot(fig1);
30

31
32
33
% you can influence the design and position of the Tag with the following
% Name-Value Arguments: 'Fontsize', 'Color', 'Location',
% 'DistanceToAxis','Position','Rotation' 
34

35
fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]);
Lemmer, Jan's avatar
Lemmer, Jan committed
36

37
38
39
% Example: blue tag with fontsize 12 in the south
[fig2, ID] = PlotID.TagPlot(fig2, 'FontSize', 12, 'Color', [0 0 1],...
    'Location','south');
40

41
% You can find the description to all options in the readme
Lemmer, Jan's avatar
Lemmer, Jan committed
42

Lemmer, Jan's avatar
Lemmer, Jan committed
43
44
45
%%  ----  2. Publishing -----
% Second part of PlotID 
% Exports your plot, the research data and the associated scripts to a
46
47
% folder named with your ID

Lemmer, Jan's avatar
Lemmer, Jan committed
48
49
50
% The functions needs the file location of the script, the location of the
% data and the figure and can take several options (see readme). 

51
52
53
% Syntax: 
% Publish(DataPaths,scriptPath, figure)
% Publish(DataPaths,scriptPath, figure, options)
Lemmer, Jan's avatar
Lemmer, Jan committed
54

55
% Path of the m.script that you use for creating your plot.
56
% note: mfilename only works if called from within a script or function
57
scriptPath = [mfilename('fullpath'),'.m']; 
Lemmer, Jan's avatar
Lemmer, Jan committed
58

Lemmer, Jan's avatar
Lemmer, Jan committed
59
60
% file paths of the datasets used for the plot (don't forget the extension) 
% note: use absolute paths for best practice
Lemmer, Jan's avatar
Lemmer, Jan committed
61
% datapath = 'test_data.mat'; 
62
locations =  datapath; 
Hock, Martin's avatar
Hock, Martin committed
63

64
65
%call publish
PlotID.Publish(locations,scriptPath, fig2)
Hock, Martin's avatar
Hock, Martin committed
66

67
% Your plot, script and all the data that you provided are now published.
Lemmer, Jan's avatar
Lemmer, Jan committed
68

Lemmer, Jan's avatar
Lemmer, Jan committed
69
% ---------------------------------
70
71
%% Further examples and help
% You find more examples in the Examples folder:
72
%   - Passing Variables
Lemmer, Jan's avatar
Lemmer, Jan committed
73
74
75
76
%   - Advanced usage 
%   - Working with HDF5-files
%   - Using a central data folder
%   - How to use advanced config-files