2017-05-19 271 views
0

我在Matlab中有一個scatterplot,想知道是否有任何方法來改變其中一個點的顏色?更改matlab中特定點的顏色?

+0

該解決方案適合您嗎? – OmG

+0

不,不是真的。它只是在我的觀點中間放一個紅點,我想改變實際點的顏色。 – Lauren

+0

您的可視化有什麼區別? – OmG

回答

2

你可以繪製圖表,然後重新繪製你想要的點。

% plot the curve or graph 
    hold on 
    plot(x,y,'.r') 

嘗試hold on,然後繪製點要以指定顏色(r),你有興趣(x,y)

0

如果你不想覆蓋在第一第二的情節,您可以分別繪製每個點並使用手柄。這樣,您可以稍後在每個點上執行任意更改。

你可以在下面找到一個例子。

% Generate some numbers 
x = randn(10,1); 
y = randn(10,1); 

% Plot each point individually 
figure 
hold on 
for idx = 1 : numel(x) 
    hdl(idx) = plot(x(idx),y(idx),'marker','.','color','k') 
end 

% change color, markerstyle, x-position, etc... 
hdl(2).Color = [1 0 0] 
hdl(3).Marker = 'o' 
hdl(5).XData = 1 
0
x = rand(10,1) ; 
y = rand(10,1) ; 
scatter(x,y) ; 

[x1,y1] = getpts ; 

hold on 
plot(x1,y1,'Or') ; 

點擊該點,你要在提示時改變顏色。