2015-06-05 142 views
2

您如何在Matlab中生成一個類似於此的分類散點圖?中的R產生Matlab中的分類散點圖

Categorical scatter plot in R

上述圖表中,響應於this question

+0

我會用'subplot' ......這些都是真正的三個獨立的地塊。或者,您可以縮放每個數據集「x」 - 值以適應定義的範圍(我會選擇'1'),然後只爲每個數據添加一個常量。 – Dan

回答

3

您可以使用scatter無證jitter屬性:

% create example data 
ydata = rand(50, 3)*2+2; 

[r, c] = size(ydata); 

xdata = repmat(1:c, r, 1); 

% for explanation see 
% http://undocumentedmatlab.com/blog/undocumented-scatter-plot-jitter 
scatter(xdata(:), ydata(:), 'r.', 'jitter','on', 'jitterAmount', 0.05); 

hold on; 

plot([xdata(1,:)-0.15; xdata(1,:) + 0.15], repmat(mean(ydata, 1), 2, 1), 'k-') 

ylim([0 max(ydata(:)+1)]) 

這導致:

Example figure

1

我知道這個帖子是老了,但我最近更新了這個功能,你可能會發現有用的,因爲它始終以相同的方式分發點,並允許對點的形狀,顏色和分佈進行非常高度的個性化。我認爲它很好地再現了一些出版物中顯示的這些圖形的形狀。看看,如果你有興趣

http://www.mathworks.com/matlabcentral/fileexchange/54243-univarscatter

Image of the plots

+0

看起來非常好,一定會試一試!格拉西亞斯... – Giuseppe