How to modift gplotmatrix legend marker size?

Hi all,
I have a pretty huge timetable Qmz (83955x272) and an array TimeCode(table, 83955x1) which identifies certain meteo conditions (number from 0 to 4).
I want to plot the Qmz data with different color in function of the values in TimeCode.
Qmz=table2timetable(OriginalData);
TimePamCode.Properties.VariableNames(1) = "Code";
P=gplotmatrix(Qmz.DateTime,Qmz.(4),TimePamCode.Code);
h = findobj('Tag','legend');
set(h, 'String', {'No data','Ambient','Ambient2','Ambient3','Ambient4'})
I'm happy of the result but how to handle the color (with customized ones) of the markers plotted with gplotmatrix and (MAINLY) how to increase the size of the marker in the legend? I cannot see the point and then the color!
Cheers

 Respuesta aceptada

Taylor
Taylor el 30 de Nov. de 2023

1 voto

7 comentarios

Dyuman Joshi
Dyuman Joshi el 30 de Nov. de 2023
That marker size does not affect the markers displayed in the legend, which is what OP is asking about.
Taylor
Taylor el 30 de Nov. de 2023
https://www.mathworks.com/matlabcentral/answers/50250-how-can-i-change-the-marker-size-in-legend
Luca D'Angelo
Luca D'Angelo el 1 de Dic. de 2023
Hi Taylor, thank you for your reply.
I've tried the method suggested by Adam Danz and I got this error.
ax = axes();
hold on
gplotmatrix(Qmz.DateTime,Qmz.(i),TimePamCode.Code);
% copy the objects
hCopy = copyobj(h, ax);
Error using copyobj
Copyobj cannot create a copy of an invalid handle.
Is it this one the one did you refer to?
Both methods from Shawn Daugherty and Adam Danz should work. The pain with each of them is that, in those methods, you have access to the legend and icon objects. That object is not immediately available to you when using gplotmatrix. You can access them after the legend has been created, but it is much more straightforward to return them when you create the legend. To that end, I recommend opening the gplotmatrix function with:
open gplotmatrix
Then, save a copy as "gplotmatrix2" or something along those lines. In the copied file, edit line 404 so that you return the legend and icon objects. Finally, incorporate either method to change the legend icon marker size. Save the file again, and call it in the future instead of the original gplotmatrix.
Luca D'Angelo
Luca D'Angelo el 1 de Dic. de 2023
Do you mean like this?
if (doleg)
gn = gn(ismember(1:size(gn,1),g),:);
[ax, h]= legend(ax(1,cols),gn);
end
Exactly. Following Daugherty's method you would also add
% Find the 'line' objects
h = findobj(h,'Type','line');
% Find lines that use a marker
h = findobj(h,'Marker','none','-xor');
% Resize the marker in the legend
set(h,'MarkerSize',20);
before the "end".
Luca D'Angelo
Luca D'Angelo el 13 de Dic. de 2023
thanks a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2023a

Preguntada:

el 29 de Nov. de 2023

Comentada:

el 13 de Dic. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by