IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
save_legend.m
Go to the documentation of this file.
1 %>@brief Saves current legend as PNG
2 %>@file
3 %>@ingroup graphicsapi ioio
4 %>
5 %> This function will save a PNG with the legend, but will mess with the positioning on the screen
6 %>
7 %> @attention May not work well if the window is maximized
8 %>
9 %> @sa show_legend_only.m
10 %
11 %> @param fn =(new) File name
12 %> @param dpi =0 Dots Per Inch = resolution. 0 = screen resolution
13 %> @return File name
14 function fn = save_legend(fn, dpi)
15 fig_assert();
16 
17 if nargin < 1 || isempty(fn)
18  fn = find_filename('irr_legend', [], 'png');
19 end;
20 if nargin < 2 || isempty(dpi)
21  dpi = 0;
22 end;
23 
24 psavef = get(gcf, 'Position');
25 psavea = get(gca, 'Position');
26 
27 hl = legend();
28 psavel = get(hl, 'Position');
29 usavel = get(hl, 'Units');
30 
32 
33 save_as_png(gcf(), fn, dpi);
34 
35 % Restoration
36 set(hl, 'Units', usavel);
37 set(hl, 'Position', psavel);
38 
39 set(gca, 'Position', psavea);
40 set(gcf, 'Position', psavef);
41 
42 
function show_legend_only()
function save_as_png(in h, in fn, in dpi)
Analysis Session (AS) base class.
Definition: as.m:6
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)
function fig_assert()
function save_legend(in fn, in dpi)