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

 Risposta accettata

Taylor
Taylor il 30 Nov 2023

7 Commenti

That marker size does not affect the markers displayed in the legend, which is what OP is asking about.
https://www.mathworks.com/matlabcentral/answers/50250-how-can-i-change-the-marker-size-in-legend
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.
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".
thanks a lot!

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by