Skip to content
Snippets Groups Projects
Commit 4d1397a6 authored by Nicola VIGANO's avatar Nicola VIGANO
Browse files

Figures: improved figure generation


Signed-off-by: default avatarNicola VIGANO <N.R.Vigano@cwi.nl>
parent 91983746
No related branches found
No related tags found
No related merge requests found
......@@ -156,10 +156,16 @@ function add_inset(ax, ex_props)
region_end = ex_props.region(1:2) + ex_props.region(3:4) - 1 - shifts;
yy = linspace(region_start(1), region_end(1), ex_props.position(3));
xx = linspace(region_start(2), region_end(2), ex_props.position(4));
zz = [1 2 3];
[xx, yy, zz] = ndgrid(xx, yy, zz);
if (numel(size(cdata)) == 3)
zz = [1 2 3];
[xx, yy, zz] = ndgrid(xx, yy, zz);
inset_data = interp3(cdata, xx, yy, zz, 'nearest');
inset_data = interp3(cdata, xx, yy, zz, 'nearest');
else
[xx, yy] = ndgrid(xx, yy);
inset_data = interp2(cdata, xx, yy, 'nearest');
end
hold(ax, 'on')
% watch out for the inversion of coordinates xx and yy here
......
......@@ -13,6 +13,8 @@ function [f, ax, img] = gtFigureCreateFromPicture(img, mask, varargin)
'pixel_to_cm', 0.05, ...
'borders', true, ...
'colorbar', true, ...
'colorbar_font_size', 18, ...
'axes_ticks', true, ...
'pixel_size', [], ...
'extras', [] );
[conf, rej_conf] = parse_pv_pairs(conf, varargin);
......@@ -63,7 +65,8 @@ function [f, ax, img] = gtFigureCreateFromPicture(img, mask, varargin)
clims_img = [min(img(:)), max(img(:))];
end
else
clims_img = [conf.clims(1), min(conf.clims(2), max(img(:)))];
clims_img = [conf.clims(1), conf.clims(2)];
% clims_img = [conf.clims(1), min(conf.clims(2), max(img(:)))];
end
img_size = [size(img, 2), size(img, 1)];
......@@ -81,6 +84,13 @@ function [f, ax, img] = gtFigureCreateFromPicture(img, mask, varargin)
end
colormap(ax, conf.cmap)
if (~conf.borders || ~conf.axes_ticks)
set(ax, 'xtick', [])
set(ax, 'xticklabel', [])
set(ax, 'ytick', [])
set(ax, 'yticklabel', [])
end
if (~isempty(conf.extras))
if (isempty(conf.pixel_size) && gtFigureExtrasRequireParameters(conf.extras))
p = gtLoadParameters();
......
function gtFigureSetSize(f, ax, conf, img_size)
img_size = img_size * conf.pixel_to_cm;
if (exist('img_size', 'var') && ~isempty(img_size))
img_size = img_size * conf.pixel_to_cm;
else
img_size = conf.figure_size;
end
set(f, 'Units', 'centimeters')
if (~conf.borders)
if (~conf.colorbar)
figure_position = [0, 0, img_size];
else
figure_position = [0, 0, img_size] + [0, 0, 2, 0];
figure_position = [0, 0, img_size] + [0, 0, 3, 1];
end
set(f, 'Position', figure_position)
set(f, 'Paperposition', figure_position)
......@@ -16,17 +20,28 @@ function gtFigureSetSize(f, ax, conf, img_size)
set(cb, 'Units', 'centimeters')
position = [img_size(1)+0.35, 0, 0.65, img_size(2)];
set(cb, 'Position', position)
set(cb, 'FontSize', conf.colorbar_font_size)
end
set(ax, 'Units', 'centimeters')
set(ax, 'Position', [0, 0, img_size])
else
if (~isempty(conf.label))
size_padding = 2;
lower_offset = 1.75;
if (conf.axes_ticks)
size_padding = 2;
lower_offsets = [1, 1.75];
else
size_padding = 1.5;
lower_offsets = [0.5, 1.25];
end
else
size_padding = 1.5;
lower_offset = 1;
if (conf.axes_ticks)
size_padding = 1.5;
lower_offsets = [1, 1];
else
size_padding = 1;
lower_offsets = [0.5, 0.5];
end
end
set(ax, 'Units', 'centimeters')
......@@ -35,23 +50,24 @@ function gtFigureSetSize(f, ax, conf, img_size)
set(f, 'Position', figure_position)
set(f, 'Paperposition', figure_position)
else
figure_position = [0, 0, img_size] + [0, 0, 3, size_padding];
figure_position = [0, 0, img_size] + [0, 0, 3.5, size_padding+0.5];
set(f, 'Position', figure_position)
set(f, 'Paperposition', figure_position)
cb = colorbar('peer', ax, 'location', 'EastOutside');
set(cb, 'Units', 'centimeters')
position = [img_size(1)+1.35, lower_offset, 0.65, img_size(2)];
position = [img_size(1)+lower_offsets(1)+0.35, lower_offsets(2), 0.65, img_size(2)];
set(cb, 'Position', position)
set(cb, 'FontSize', conf.colorbar_font_size)
end
axes_position = [1, lower_offset, img_size];
axes_position = [lower_offsets, img_size];
set(ax, 'Position', axes_position)
if (~isempty(conf.label))
l = uicontrol('Style', 'Text', 'parent', f, ...
'String', conf.label, 'FontWeight', 'bold');
set(l, 'Units', 'centimeters')
position = [1, 0.25, img_size(1), 0.75];
position = [lower_offsets(1), 0.25, img_size(1), 0.75];
set(l, 'Position', position)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment