MATLAB Answers

0

Change Width for YAxis (both) but not the grid

Asked by Tiago Dias on 2 May 2019
Latest activity Commented on by Star Strider
on 3 May 2019
Hello,
I want to change both YAxis Width but ax1.YAxis.Linewidth = 1.5 command doesnt work. I would like the width of both Yaxis be the same as XAxis, while remaining the grid vertical and horizontal lines like in the plot i attached.
% Plot the coefficients Scaled
out = figure;
set(out,'PaperUnits','centimeters','PaperPosition',[0 0 29 21], 'PaperOrientation','landscape');
yyaxis left
bar(Lasso_coefficient_order_scaled)
yyaxis right
plot(count_coefficient_Lasso(Lasso_index_order),'O','MarkerFaceColor','black','MarkerEdgeColor','black','MarkerSize',6)
xlim([0 size(Lasso_sum_coefficients,2)+1]) % esthetics -> To get an extra space in the plot for the last variable (+1)
set(gca, 'XTickLabel', var_list2);
xticks(1:1:size(var_list2,2));
xtickangle(90);
title('Lasso');
xlabel('Variables','FontWeight','bold')
grid on; ax = gca; ax.XAxis.LineWidth = 1.5;
yyaxis(ax,'left');
set(ax,'YColor',[0 0 0]);
ylabel('Coefficients Importance','FontWeight','bold')
yticks(0:5:100);
ax1 = gca;
yyaxis(ax1,'right')
set(ax1,'YColor',[0 0 0])
ylabel('Number of Selections');
when i use
ax.YAxis.LineWidth = 1.5;
The following error ocurrs:
Expected one output from a curly brace or dot indexing expression, but there were 2 results.
Error in function_metric (line 343)
ax.YAxis.LineWidth = 1.5;
Thanks for the help

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Star Strider
on 2 May 2019
 Accepted Answer

That is a bit more complicated than it would otherwise appear to be.
This works in my test plot:
ax(1).YAxis(1).LineWidth = 1.5;
ax(2).YAxis(2).LineWidth = 1.5;

  2 Comments

oh ok, I was trying just YAxis(1) and YAxis(2), not chaning also the ax(1) and ax(2)
thanks
As always, my pleasure.

Sign in to comment.