MATLAB: Xsticklabel_rotate parameter/value pair arguments

xlabel xticklabel_rotate figure pair arguments

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?

Best Answer

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.