X and Y axis labels overwritten and illiegible
5 ビュー (過去 30 日間)
古いコメントを表示
I wrote the following code to put both the X and Y axis on log scale and do a scatter plot:
% Create figure
fig = figure;
title(['Test target transitions for ', date]);
set(fig, 'PaperOrientation', 'landscape')
xlabel('Number of Samples')
ylabel('Ratio of transitions / Number of Samples')
% Create axes
axes1 = axes('Parent',fig);
xtickformat('%10.4f');
ytickformat('%10.4f');
% Set the remaining axes properties
set(axes1,...
'XMinorTick','off',...
'XScale','log',...
'YMinorTick','off',...
'YScale','log');
% Create scatter
sflaky= scatter(X1,Y1);
hold(axes1,'on');
% Create scatter
snotflaky = scatter(X1,Y2);
p95Line = plot(points95(:,2), points95(:,1));
set(p95Line , 'LineWidth', 4);
p99Line = plot(points99(:,2), points99(:,1));
set(p99Line, 'LineWidth', 4);
p999Line = plot(points999(:,2), points999(:,1));
set(p999Line, 'LineWidth', 4);
legend([sflaky, snotflaky, p95Line, p99Line, p999Line], ...
{'flaky', 'not flaky', '95% pFlaky', '99% pFlaky', '99.9% pFlaky'});
When I run the code, I get garbled X and Y tick labels and I am not sure why. Reproduced both online and in my local version of MATLAB.
See the attached PDF file for an example of what it looks like.
0 件のコメント
回答 (2 件)
Ameer Hamza
2018 年 6 月 25 日
I don't have your data, therefore, can't test the complete code but I guess the problem is happening because your code is effectively creating 2 axes objects, which overlaps and creating illegible text. Try changing the order of lines at the beginning of your code as follow
fig = figure;
% Create axes
axes1 = axes('Parent',fig);
title(['Test target transitions for ', date]);
set(fig, 'PaperOrientation', 'landscape')
xlabel('Number of Samples')
ylabel('Ratio of transitions / Number of Samples')
xtickformat('%10.4f'); ytickformat('%10.4f');
% Set the remaining axes properties
set(axes1,...
'XMinorTick','off',...
'XScale','log',...
'YMinorTick','off',...
'YScale','log');
0 件のコメント
John Micco
2018 年 6 月 25 日
3 件のコメント
Ameer Hamza
2018 年 6 月 26 日
I am not sure whether it is a bug. It might be an intended behavior because it is more convenient to display and read values in the exponential form in log scale. Although it would be nice if MATLAB still provide control over label format even in log scale.
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!