X and Y axis labels overwritten and illiegible
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Ameer Hamza
le 25 Juin 2018
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 commentaires
John Micco
le 25 Juin 2018
3 commentaires
Ameer Hamza
le 26 Juin 2018
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.
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!