Deleting axes changes legend transparency?
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Adam Danz
on 19 Apr 2023
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'})
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!