Deleting axes changes legend transparency?
2 ビュー (過去 30 日間)
古いコメントを表示
I'm making a plot using gplotmatrix. I only need the lower half of the plot beneath the diagonal, so I have removed the upper half of the plot by setting the visibility of the axes and data points to 'off'.
However, in deleting these objects, the legend becomes slightly transparent, and after trying many fixes I have not been able to make the legend opaque.
I do not know if this is a bug or a feature, but any suggestions of how to remedy it are much appreciated. I've included before/after images as well as code that replicates this issue. Thanks!
x = rand(100,5);
group = zeros(100,1);
group(1:33) = 1;
group(34:66) = 2;
group(67:end) = 3;
figure(1)
[h,ax,bax] = gplotmatrix(x,[],group,[],[],[],'on','hist',[],[])
figure(2)
[h,ax,bax] = gplotmatrix(x,[],group,[],[],[],'on','hist',[],[])
% Remove axes in upper triangular portion of the gplotmatrix plot
for i = 1:5
for j = i+1:5
set(ax(i,j),'Visible','off');
set(findobj(ax(i,j),'type','line'),'Visible','off');
end
end
% Attempt (unsuccessfully) to force legend text color
leg = findobj(gcf,'Tag','legend')
set(leg,'Location','south','Orientation','horizontal','TextColor',[0, 0, 0, 1]);
0 件のコメント
採用された回答
Adam Danz
2023 年 4 月 19 日
In gplotmatrix, the legend is associated with the axes in the upper right corner. When the visibility of that axes is off, the legend goes dim.
You can add a legend to a different axes but you'll need to create the names to appear in the legend.
[h,ax,bax] = gplotmatrix(x,[],group,[],[],[],'off','hist',[],[]);
% Don't add default legend ^^^
% Add legend to bottom left corner
legend(ax(end-1,1),{'1','2','3'})
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!