Change Width for YAxis (both) but not the grid

조회 수: 11 (최근 30일)
Tiago Dias
Tiago Dias 2019년 5월 2일
댓글: Star Strider 2019년 5월 3일
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

채택된 답변

Star Strider
Star Strider 2019년 5월 2일
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
Tiago Dias
Tiago Dias 2019년 5월 2일
oh ok, I was trying just YAxis(1) and YAxis(2), not chaning also the ax(1) and ax(2)
thanks
Star Strider
Star Strider 2019년 5월 3일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by