Filter löschen
Filter löschen

Change Width for YAxis (both) but not the grid

7 Ansichten (letzte 30 Tage)
Tiago Dias
Tiago Dias am 2 Mai 2019
Kommentiert: Star Strider am 3 Mai 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

Akzeptierte Antwort

Star Strider
Star Strider am 2 Mai 2019
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 Kommentare
Tiago Dias
Tiago Dias am 2 Mai 2019
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 am 3 Mai 2019
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by