A plot with four subplots (quadrants)

Hello,
I am working on a mood detection algorithm (from music) and I am currently stuck at the GUI.
I need to plot something similar to Thayer's arousal-valence emotion plane (four quadrants), here's what it looks like: Thayer
Now, it's not really technical, it's more about formatting the plot so it looks like that. I've tried everything I can but couldn't get to that result.
Basically what I need to do is this: if my function returns 1, a point would be plotted on the yellow panel (scatter plot maybe?), if answer is 2 - green, 3 - blue, 4 - red.
Is it possible? If it is, any idea of how I can do this?
Thank you in advance!
M.

3 件のコメント

Sara
Sara 2014 年 4 月 16 日
Do you need it to look like the picture or are you ok with having 4 plots? The point you're plotting, is it at a random location inside acolored box or at specific meaningful location? Would something like this work:
suplot(2,2,n)
plot(...)
where n is the number of the panel (1=red,2=yellow,3=blue,4=green in the figure you've posted).
Mihnea
Mihnea 2014 年 4 月 16 日
I've already tried it that way and while it is efficient indeed it doesn't look too good.
I'll keep trying with subplots but if anyone's got any other ideas, feel free to share them.
Sara
Sara 2014 年 4 月 16 日
You can use the quadrants of a classic plot: x>0,y>0 for yellow; x<0,y>0 for red and so on. In this way it's just one plot. And if you want to color the background, you can use the patch command.

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

 採用された回答

Kelly Kearney
Kelly Kearney 2014 年 4 月 16 日

1 投票

There are several options of the file exchange to alter the spacing/margins/etc. of subplots (e.g. subaxis). Though for just 4 plots just using axes with the 'position' option should suffice:
l = [0.1 0.5; 0.1 0.5];
b = [0.5 0.5; 0.1 0.1];
c = {'r', 'y'; 'b', 'g'};
for ii = 1:4
ax(ii) = axes('position', [l(ii) b(ii) 0.4 0.4], 'color', c{ii});
end

1 件のコメント

Mihnea
Mihnea 2014 年 4 月 17 日
This works perfectly, thank you!
M.

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

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 4 月 16 日

1 投票

If you have multiple subplots, you need to do some tricky stuff to get them close together. Why not just create an image and display that in a single axes control? Then put annotation over it with plot(), annotation(), text(), etc..

4 件のコメント

Mihnea
Mihnea 2014 年 4 月 16 日
I'll try that and see how it goes, thank you!
Mihnea
Mihnea 2014 年 4 月 16 日
This seems to work:
x = [0 0];
y1 = [0 0];
y2 = [0 0];
y3 = [0 0];
y4 = [0 0];
off_x = max(x) - min(x);
off_y = max([max(y1)-min(y1), max(y2)-min(y2), max(y3)-min(y3), max(y4)-min(y4)]);
plot(x,y1); hold on;
plot(x+off_x,y2);
plot(x+off_x,y3+off_y);
plot(x,y4+off_y);
How can I set the background colour to each individual plot?
Thank you, M.
Image Analyst
Image Analyst 2014 年 4 月 17 日
That's not what I was thinking, but that might work too. Just use patch() or fill() to put up a colored rectangle.
Mihnea
Mihnea 2014 年 4 月 17 日
Yup, did it! Thank you!

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

Mihnea
Mihnea 2014 年 4 月 17 日

0 投票

It looks exactly as I wanted except for a small problem, the borders (or the black lines, they might be axes). Here's what it looks like: Screenshot
Is there a way to hide them? I've tried set(gca,'Visible','off') but it hides the whole thing, axis off does exactly the same thing.
Thank you in advance!

3 件のコメント

Image Analyst
Image Analyst 2014 年 4 月 17 日
Who's answer should you have put your answer under as a comment (Kelly or me)? Also, your link seems to be broken.
Kelly Kearney
Kelly Kearney 2014 年 4 月 17 日
Assuming this comment applied to my solution, you can set the xcolor and ycolor properties to match your figure background. I'm assuming for now you're not interested in tick labels; if you need those it might require a bit more fiddling.
set(gcf, 'color', 'w');
set(ax, 'xcolor', 'w', 'ycolor', 'w', 'xtick', [], 'ytick', [])
Mihnea
Mihnea 2014 年 4 月 17 日
@Image Analyst, Kelly's, sorry for the confusion.
@Kelly, thank you, it worked!

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

質問済み:

2014 年 4 月 16 日

コメント済み:

2014 年 4 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by