Change Width for YAxis (both) but not the grid

11 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Star Strider
Star Strider il 2 Mag 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 Commenti
Tiago Dias
Tiago Dias il 2 Mag 2019
oh ok, I was trying just YAxis(1) and YAxis(2), not chaning also the ax(1) and ax(2)
thanks

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by