-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2318 from opencobra/develop
Develop
- Loading branch information
Showing
91 changed files
with
8,814 additions
and
2,461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule +HCP
added at
458a25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
|
||
% What can Panel do? | ||
% | ||
% This demo just shows off what Panel can do. It is not | ||
% intended as part of the tutorial - this begins in | ||
% demopanel2. | ||
% | ||
% (a) It's easy to create a complex layout | ||
% (b) You can populate it as you would a subplot layout | ||
% | ||
% Now, move on to demopanel2 to learn how to use panel. | ||
|
||
|
||
|
||
%% (a) | ||
|
||
% clf | ||
figure(1) | ||
clf | ||
|
||
% create panel | ||
p = panel(); | ||
|
||
% layout a variety of sub-panels | ||
p.pack('h', {1/3 []}) | ||
p(1).pack({2/3 []}); | ||
p(1,1).pack(3, 2); | ||
p(2).pack(6, 2); | ||
|
||
% set margins | ||
p.de.margin = 2; | ||
p(1,1).marginbottom = 12; | ||
p(2).marginleft = 20; | ||
p.margin = [13 10 2 2]; | ||
|
||
% and some properties | ||
p.fontsize = 8; | ||
|
||
|
||
|
||
%% (b) | ||
|
||
% data set 1 | ||
for m = 1:3 | ||
for n = 1:2 | ||
|
||
% prepare sample data | ||
t = (0:99) / 100; | ||
s1 = sin(t * 2 * pi * m); | ||
s2 = sin(t * 2 * pi * n * 2); | ||
|
||
% select axis - see data set 2 for an alternative way to | ||
% access sub-panels | ||
p(1,1,m,n).select(); | ||
|
||
% plot | ||
plot(t, s1, 'r', 'linewidth', 1); | ||
hold on | ||
plot(t, s2, 'b', 'linewidth', 1); | ||
plot(t, s1+s2, 'k', 'linewidth', 1); | ||
|
||
% finalise axis | ||
axis([0 1 -2.2 2.2]); | ||
set(gca, 'xtick', [], 'ytick', []); | ||
|
||
end | ||
end | ||
|
||
% label axis group | ||
p(1,1).xlabel('time (unitless)'); | ||
p(1,1).ylabel('example data series'); | ||
|
||
% data set 2 | ||
source = 'XYZXYZ'; | ||
|
||
% an alternative way to access sub-panels is to first get a | ||
% reference to the parent... | ||
q = p(2); | ||
|
||
% loop | ||
for m = 1:6 | ||
for n = 1:2 | ||
|
||
% select axis - these two lines do the same thing (see | ||
% above) | ||
% p(2, m, n).select(); | ||
q(m, n).select(); | ||
|
||
% prepare sample data | ||
data = randn(100, 1) * 0.4; | ||
|
||
% do stats | ||
stats = []; | ||
stats.source = source(m); | ||
stats.binrange = [-1 1]; | ||
stats.xtick = [-0.8:0.4:0.8]; | ||
stats.ytick = [0 20]; | ||
stats.bincens = -0.9:0.2:0.9; | ||
stats.values = data; | ||
stats.freq = hist(data, stats.bincens); | ||
stats.percfreq = stats.freq / length(data) * 100; | ||
stats.percpeak = 30; | ||
|
||
% plot | ||
demopanel_minihist(stats, m == 6, n == 1); | ||
|
||
end | ||
end | ||
|
||
% label axis group | ||
p(2).xlabel('data value (furlongs per fortnight)'); | ||
p(2).ylabel('normalised frequency (%)'); | ||
|
||
% data set 3 | ||
p(1, 2).select(); | ||
|
||
% prepare sample data | ||
r1 = rand(100, 1); | ||
r2 = randn(100, 1); | ||
|
||
% plot | ||
plot(r1, r1+0.2*r2, 'k.') | ||
hold on | ||
plot([0 1], [0 1], 'r-') | ||
|
||
% finalise axis | ||
xlabel('our predictions'); | ||
ylabel('actual measurements') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
% Basic use. Panel is just like subplot. | ||
% | ||
% (a) Create a grid of panels. | ||
% (b) Plot into each sub-panel. | ||
|
||
|
||
|
||
%% (a) | ||
|
||
% create a NxN grid in gcf (this will create a figure, if | ||
% none is open). | ||
% | ||
% you can pass the figure handle to the constructor if you | ||
% need to attach the panel to a particular figure, as: | ||
% | ||
% p = panel(h_figure) | ||
% | ||
% NB: you can use this code to compare using panel() with | ||
% using subplot(). you should find they do much the same | ||
% thing in this case, but with a slightly different layout. | ||
|
||
N = 2; | ||
use_panel = 1; | ||
clf | ||
|
||
% PREPARE | ||
if use_panel | ||
p = panel(); | ||
p.pack(N, N); | ||
end | ||
|
||
|
||
|
||
%% (b) | ||
|
||
% plot into each panel in turn | ||
|
||
for m = 1:N | ||
for n = 1:N | ||
|
||
% select one of the NxN grid of sub-panels | ||
if use_panel | ||
p(m, n).select(); | ||
else | ||
subplot(N, N, m + (n-1) * N); | ||
end | ||
|
||
% plot some data | ||
plot(randn(100,1)); | ||
|
||
% you can use all the usual calls | ||
xlabel('sample number'); | ||
ylabel('data'); | ||
|
||
% and so on - generally, you can treat the axis panel | ||
% like any other axis | ||
axis([0 100 -3 3]); | ||
|
||
end | ||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
|
||
% You can nest Panels as much as you like. | ||
% | ||
% (a) Create a grid of panels. | ||
% (b) Plot into three of the sub-panels. | ||
% (c) Create another grid in the fourth. | ||
% (d) Plot into each of these. | ||
|
||
|
||
|
||
%% (a) | ||
|
||
% create a panel in gcf. | ||
% | ||
% "p" is called the "root panel", which is the special panel | ||
% whose parent is the figure window (usually), rather than | ||
% another panel. | ||
p = panel(); | ||
|
||
% pack a 2x2 grid of panels into it. | ||
p.pack(2, 2); | ||
|
||
|
||
|
||
%% (b) | ||
|
||
% plot into the first three panels | ||
for m = 1:2 | ||
for n = 1:2 | ||
|
||
% skip the 2,2 panel | ||
if m == 2 && n == 2 | ||
break | ||
end | ||
|
||
% select the panel (create an axis, and make that axis | ||
% current) | ||
p(m, n).select(); | ||
|
||
% plot some stuff | ||
plot(randn(100,1)); | ||
xlabel('sample number'); | ||
ylabel('data'); | ||
axis([0 100 -3 3]); | ||
|
||
end | ||
end | ||
|
||
|
||
|
||
%% (c) | ||
|
||
% pack a further grid into p(2, 2) | ||
% | ||
% all panels start as "uncommitted panels" (even the root | ||
% panel). the first time we "select()" one, we commit it as | ||
% an "axis panel". the first time we "pack()" one, we commit | ||
% it as a "parent panel". once committed, it can't change | ||
% into the other sort. | ||
% | ||
% this call commits p(2,2) as a parent panel - the six | ||
% children it creates all start as uncommitted panels. | ||
p(2, 2).pack(2, 3); | ||
|
||
|
||
|
||
%% (d) | ||
|
||
% plot into the six new sub-sub-panels | ||
for m = 1:2 | ||
for n = 1:3 | ||
|
||
% select the panel - this commits it as an axis panel | ||
p(2, 2, m, n).select(); | ||
|
||
% plot some stuff | ||
plot(randn(100,1)); | ||
xlabel('sample number'); | ||
ylabel('data'); | ||
axis([0 100 -3 3]); | ||
|
||
end | ||
end | ||
|
||
% note this alternative, equivalent, way to reference a | ||
% sub-panel | ||
p_22 = p(2, 2); | ||
|
||
% plot another bit of data into the six sub-sub-panels | ||
for m = 1:2 | ||
for n = 1:3 | ||
|
||
% select the panel | ||
p_22(m, n).select(); | ||
|
||
% plot more stuff | ||
hold on | ||
plot(randn(100,1)*0.3, 'r'); | ||
|
||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.