Why are half of the XTickLabels not shown using saveas(), but all are shown using hgexport()?
1 次查看(过去 30 天)
显示 更早的评论
I would prefer to be using saveas(), because the thread that I found hgexport() in ( here - outdated?) states that "HGEXPORT syntax is not a documented usage and thus might change in a future release of MATLAB."
Not sure if I'm missing something, or if this is a bug, but this is my code:
% Getting Started
clear all
close all
% Variables
dataFile = 'Algorithm_Test_Data.mat';
varTyp = 'AUC';
outputOptions.Format = 'tiffn';
genCol = [255/255 153/255 0/255];
oriCol = [255/255 204/255 0/255];
% Main
load(dataFile); % Imports genericVar and originalVar, each a one column vector if with 10 elements
% Output - Raw Data
maxHeight = 1.25 * max([0, max(genericVar), max(originalVar)]);
minHeight = 1.25 * min([0, min(genericVar), min(originalVar)]);
roundVal = findRound(abs(maxHeight - minHeight)); % Function I created, determines appropriate scale to round the yaxis numbers too
maxHeight = ceil(maxHeight / roundVal) * roundVal;
minHeight = floor(minHeight / roundVal) * roundVal;
custYAxis = linspace(minHeight, maxHeight, 6);
rawDataFig = figure('Visible', 'Off', 'units', 'normalized', 'Position', [0 0 1 1]);
[hAx, hLineOne, hLineTwo] = plotyy(1, genericVar, 2, originalVar);
axis(hAx(1), [0, 3, minHeight, maxHeight]);
axis(hAx(2), [0, 3, minHeight, maxHeight]);
set(hLineOne, 'Marker', 'd', 'MarkerFaceColor', genCol, 'MarkerEdgeColor', genCol, 'MarkerSize', 15);
set(hLineTwo, 'Marker', '^', 'MarkerFaceColor', oriCol, 'MarkerEdgeColor', oriCol, 'MarkerSize', 15);
set(hAx(1), 'OuterPosition', [0 0 1 .95], 'XTickLabel', '', 'XTick', [], 'YTick', linspace(minHeight, maxHeight, 6), 'FontSize', 18);
set(hAx(2), 'XTickLabel', char(' ', ' ', 'Generic', ' ', 'Original', ' ', ' '), 'FontSize', 24, 'FontWeight', 'Bold', 'TickLength', [0 0], 'YTick', []);
ylabel(varTyp, 'FontSize', 24, 'FontWeight', 'Bold');
title('Raw Data', 'FontSize', 32, 'FontWeight', 'Bold');
set(rawDataFig, 'Visible', 'On');
hgexport(rawDataFig, 'RawData.tif', outputOptions);
saveas(rawDataFig, 'usingSaveAs.tif', 'tiffn');
Result from hgexport():
Result from saveas():
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!