Splitapply, each data of group in a new figure/plot

Hi all,
I am using the function splitapply. However I have problems with plotting each group in another figure (or hide one or more groups).
Currently I am using (attachment with .mat-file):
hold on splitapply(@(difference_mean,difference)plot(difference_mean,difference,'o'),difference_mean,difference,G);
It would be the best to create three seperate figures with each group another figure. Alternatively, create 3 times the same figure and delete the other data.
Can somebody provide me with de solution :)?
Greetings,
Martijn

 採用された回答

Duncan Po
Duncan Po 2016 年 5 月 17 日

0 投票

You can do it but not with an anonymous function. You need a separate function to pass into splitapply:
function myplot(dm,d)
figure;
plot(dm,d,'o');
Pass this function into splitapply:
splitapply(@myplot,difference_mean,difference,G);

4 件のコメント

KFrenkie
KFrenkie 2016 年 5 月 17 日
Thanks Duncan,
This solved my problem :)!
Jan Orwat
Jan Orwat 2016 年 5 月 29 日
Actually, to be 100% accurate it is possible to do with single anonymous function:
splitapply(@(X, Y)plot(X, Y, 'o', 'Parent', axes('Parent', figure)), difference_mean, difference, G);
As you can see it's not as elegant as Duncan Po's solution.
Meet Desai
Meet Desai 2019 年 6 月 26 日
Is there any way that I can do splitapply and also get different title, name of axes for different graphs?
Thank you.
Sterling Baird
Sterling Baird 2020 年 10 月 19 日
Make that an argument to your custom plotting function?

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

製品

質問済み:

2016 年 5 月 16 日

コメント済み:

2020 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by