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

 採用された回答

Taylor
Taylor 2023 年 11 月 30 日

1 投票

7 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 11 月 30 日
That marker size does not affect the markers displayed in the legend, which is what OP is asking about.
Taylor
Taylor 2023 年 11 月 30 日
https://www.mathworks.com/matlabcentral/answers/50250-how-can-i-change-the-marker-size-in-legend
Luca D'Angelo
Luca D'Angelo 2023 年 12 月 1 日
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?
Taylor
Taylor 2023 年 12 月 1 日
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 2023 年 12 月 1 日
Do you mean like this?
if (doleg)
gn = gn(ismember(1:size(gn,1),g),:);
[ax, h]= legend(ax(1,cols),gn);
end
Taylor
Taylor 2023 年 12 月 1 日
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 2023 年 12 月 13 日
thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2023a

質問済み:

2023 年 11 月 29 日

コメント済み:

2023 年 12 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by