xsticklabel_rotate parameter/value pair arguments

2 vues (au cours des 30 derniers jours)
aine gormley
aine gormley le 17 Oct 2018
Commenté : aine gormley le 20 Oct 2018
Hi, Im trying to plot the following figure, but keep getting the error about xsticklabel.
if true
>> figure;
h = bar(1:7,QIRR_srex,'hist'); hold on;
g(1) = plot(1,1, 'b', 'LineWidth',2.5); hold on;
g(2) = plot(1,1, 'g', 'LineWidth',2.5); hold on;
set(h(1),'facecolor',[0.5 0.5 1])
set(h(2),'facecolor',[0.5 1 0.5])
set(h(3),'facecolor',[1 0.5 0.5])
set(h,'edgecolor','none')
axis([0 8 0 160]);
mf_xticklabel_rotate([1:7],45,[srex_reg],'interpreter','none','Fontsize', 11, 'Fontweight', 'Bold','color', axcolor); %#ok<NBRAK>
ylabel('Q_i_r_r [mm yr^-^1]', 'Fontsize', 14, 'Fontweight', 'Bold');
legend(g, 'OBS', 'IRR', 'Location', 'SouthWest');
set(legend,'YColor','w','XColor','w', 'Fontweight', 'Bold', 'Fontsize', 11,'textcolor', axcolor);
set(gca, 'Fontsize', 14, 'Fontweight', 'Bold','Xcolor', axcolor,'Ycolor', axcolor);
export_fig text/figures_paper/figure_02 -transparent;
Error using matlab.graphics.primitive.Text/set
Invalid parameter/value pair arguments.
Error in mf_xticklabel_rotate (line 154)
set(hText,'HorizontalAlignment','right',varargin{:})
Here is also the part of xsticklabel the error refers to: xAxisLocation = get(gca, 'XAxisLocation');
xAxisLocation = get(gca, 'XAxisLocation');
if strcmp(xAxisLocation,'bottom')
set(hText,'Rotation', rot, 'HorizontalAlignment','right',varargin{:})
else
set(hText,'Rotation', rot, 'HorizontalAlignment','left',varargin{:})
end if true
I have tried multiple things like different putting in rot value directly (ie 90), but it doesnt seem to help. Please can someone help?
  3 commentaires
aine gormley
aine gormley le 17 Oct 2018
Hi; hereis QIRR_srex info:
% % irrigation amounts
QIRR_srex(:,1) = mf_srex(lat_mod, lon_mod, QIRR_obs, island, [], 'WNA', 'CNA', 'MED', 'WAS', 'SAS', 'SEA', 'EAS');
QIRR_srex(:,2) = mf_srex(lat_mod, lon_mod, QIRR_irr, island, [], 'WNA', 'CNA', 'MED', 'WAS', 'SAS', 'SEA', 'EAS');
QIRR_srex(:,3) = mf_srex(lat_mod, lon_mod, QIRR_ctl, island, [], 'WNA', 'CNA', 'MED', 'WAS', 'SAS', 'SEA', 'EAS');
aine gormley
aine gormley le 17 Oct 2018
Hi; here is the function of xticklabel_rotate
function hText = mf_xticklabel_rotate(XTick,rot,varargin)
%hText = xticklabel_rotate(XTick,rot,XTickLabel,varargin) Rotate XTickLabel
%
% Syntax: xticklabel_rotate
%
% Input:
% {opt} XTick - vector array of XTick positions & values (numeric)
% uses current XTick values or XTickLabel cell array by
% default (if empty)
% {opt} rot - angle of rotation in degrees, 90 by default
% {opt} XTickLabel - cell array of label strings
% {opt} [var] - "Property-value" pairs passed to text generator
% ex: 'interpreter','none'
% 'Color','m','Fontweight','bold'
%
% Output: hText - handle vector to text labels
%
% Example 1: Rotate existing XTickLabels at their current position by 90
% xticklabel_rotate
%
% Example 2: Rotate existing XTickLabels at their current position by 45 and change
% font size
% xticklabel_rotate([],45,[],'Fontsize',14)
%
% Example 3: Set the positions of the XTicks and rotate them 90
% figure; plot([1960:2004],randn(45,1)); xlim([1960 2004]);
% xticklabel_rotate([1960:2:2004]);
%
% Example 4: Use text labels at XTick positions rotated 45 without tex interpreter
% xticklabel_rotate(XTick,45,NameFields,'interpreter','none');
%
% Example 5: Use text labels rotated 90 at current positions
% xticklabel_rotate([],90,NameFields);
%
% Note : you can not RE-RUN xticklabel_rotate on the same graph.

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 17 Oct 2018
Which release of MATLAB are you using? If you're using release R2014b or later there are properties that support rotated axis tick labels. If you're using release R2016b or later there are convenience functions that will make it easier to rotate the labels.
  3 commentaires
Steven Lord
Steven Lord le 17 Oct 2018
In that case, try just using xtickangle.
aine gormley
aine gormley le 20 Oct 2018
perfect, thank you :-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Axes Appearance 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!

Translated by