|
388 | 388 | % 30/05/23: (3.39) Fixed exported bgcolor of uifigures or figures in Live Scripts (issue #377)
|
389 | 389 | % 06/07/23: (3.40) For Tiff compression, use AdobeDeflate codec (if available) instead of Deflate (issue #379)
|
390 | 390 | % 29/11/23: (3.41) Fixed error when no filename is specified nor available in the exported figure (issue #381)
|
| 391 | +% 05/12/23: (3.42) Fixed unintended cropping of colorbar title in PDF export with -transparent (issue #382) |
391 | 392 | %}
|
392 | 393 |
|
393 | 394 | if nargout
|
|
425 | 426 | [fig, options] = parse_args(nargout, fig, argNames, varargin{:});
|
426 | 427 |
|
427 | 428 | % Check for newer version and exportgraphics/copygraphics compatibility
|
428 |
| - currentVersion = 3.41; |
| 429 | + currentVersion = 3.42; |
429 | 430 | if options.version % export_fig's version requested - return it and bail out
|
430 | 431 | imageData = currentVersion;
|
431 | 432 | return
|
|
1089 | 1090 |
|
1090 | 1091 | % Correct black titles to off-black
|
1091 | 1092 | % https://www.mathworks.com/matlabcentral/answers/567027-matlab-export_fig-crops-title
|
1092 |
| - try |
1093 |
| - hTitle = get(hAxes, 'Title'); |
1094 |
| - for idx = numel(hTitle) : -1 : 1 |
1095 |
| - color = get(hTitle,'Color'); |
1096 |
| - if isequal(color,[0,0,0]) || isequal(color,'k') |
1097 |
| - set(hTitle(idx), 'Color', [0,0,0.01]); %off-black |
1098 |
| - else |
1099 |
| - hTitle(idx) = []; % remove from list |
1100 |
| - end |
1101 |
| - end |
1102 |
| - catch |
1103 |
| - hTitle = []; |
1104 |
| - end |
| 1093 | + hTitle = fixBlackText(hAxes,'Title'); |
| 1094 | + hColorBars = unique([findall(fig,'tag','Colorbar'), ... |
| 1095 | + getappdata(hAxes,'LayoutPeers')]); |
| 1096 | + hCbTxt = fixBlackText(hColorBars,'Title'); % issue #382 |
1105 | 1097 | end
|
1106 | 1098 | % Generate an eps
|
1107 | 1099 | print2eps(tmp_nam, fig, options, printArgs{:}); %winopen(tmp_nam)
|
|
1110 | 1102 | if options.transparent %&& ~isequal(get(fig, 'Color'), 'none')
|
1111 | 1103 | eps_remove_background(tmp_nam, 1 + using_hg2(fig));
|
1112 | 1104 |
|
1113 |
| - % Revert the black axes colors |
| 1105 | + % Revert the black axles/titles colors |
1114 | 1106 | set(hXs, 'XColor', [0,0,0]);
|
1115 | 1107 | set(hYs, 'YColor', [0,0,0]);
|
1116 | 1108 | set(hZs, 'ZColor', [0,0,0]);
|
1117 | 1109 | set(hXrs, 'Color', [0,0,0]);
|
1118 | 1110 | set(hYrs, 'Color', [0,0,0]);
|
1119 | 1111 | set(hZrs, 'Color', [0,0,0]);
|
1120 | 1112 | set(hTitle,'Color',[0,0,0]);
|
| 1113 | + set(hCbTxt,'Color',[0,0,0]); |
1121 | 1114 | end
|
1122 | 1115 | %}
|
1123 | 1116 | % Restore the figure's previous background color (if modified)
|
@@ -2441,6 +2434,22 @@ function change_rgb_to_cmyk(fname) % convert RGB => CMYK within an EPS file
|
2441 | 2434 | set(hBlackAxles, axleName, [0,0,0.01]); % off-black
|
2442 | 2435 | end
|
2443 | 2436 |
|
| 2437 | +function hText = fixBlackText(hObject, propName) |
| 2438 | + try |
| 2439 | + hText = get(hObject, propName); |
| 2440 | + for idx = numel(hText) : -1 : 1 |
| 2441 | + color = get(hText,'Color'); |
| 2442 | + if isequal(color,[0,0,0]) || isequal(color,'k') |
| 2443 | + set(hText(idx), 'Color', [0,0,0.01]); %off-black |
| 2444 | + else |
| 2445 | + hText(idx) = []; % remove from list |
| 2446 | + end |
| 2447 | + end |
| 2448 | + catch |
| 2449 | + hText = []; |
| 2450 | + end |
| 2451 | +end |
| 2452 | + |
2444 | 2453 | % Issue #269: format-specific options
|
2445 | 2454 | function [optionsCells, bitDepth] = getFormatOptions(options, formatName)
|
2446 | 2455 | bitDepth = [];
|
|
0 commit comments