Deleting axes changes legend transparency?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ben
el 19 de Abr. de 2023
Comentada: Ben
el 28 de Abr. de 2023
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 comentarios
Respuesta aceptada
Adam Danz
el 19 de Abr. de 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'})
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!