How to change colors in Scatter plot?

How to change colors in Scatter plot? I need to change the default colors "dark red and dark blue" into "light red and light green"

回答 (1 件)

KSSV
KSSV 2016 年 10 月 14 日

2 投票

x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
RGB = [255 153 153]/256 ;
RGB = [204 204 255]/256 ;
scatter(x,y,[],RGB)
Choose your required color RGB array.

5 件のコメント

Rehab Ali
Rehab Ali 2016 年 10 月 14 日
Thanks for your help My data has 2 values. Each one of these values are represented in color. I need to change the colors of these 2 values but I still need to get 2 colors
KSSV
KSSV 2016 年 10 月 14 日
clc; clear all ;
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
RGB1 = repmat([255 153 153]/256 ,length(x)/2,1) ;
RGB2 = repmat([204 204 255]/256 ,length(x)/2,1) ;
RGB = [RGB1 ; RGB2] ;
scatter(x,y,[],RGB)
Rehab Ali
Rehab Ali 2016 年 10 月 15 日
編集済み: Walter Roberson 2016 年 10 月 15 日
Thanks alot for your help
my data is:
0.385500 -0.116750 1
-0.575000 0.050250 2
0.004250 -0.788250 1
0.438250 0.544500 2
0.460250 0.610250 1
0.505000 0.110750 2
The first column is x, the second is y and the third is the output (z)
I'm using
scatter (x,y,5,z,'filled')
This gave me all the z data as function is x, y ( which what I need) but with 2 colors hard to be differentiated.
I need to change the default colors with colors easy to differentiate between them
When I use your function
RGB1 = repmat([255 153 153]/256 ,length(x)/2,1) ;
RGB2 = repmat([204 204 255]/256 ,length(x)/2,1) ;
RGB = [RGB1 ; RGB2] ;
scatter(xX,yX,zX,,RGB)
It gives me an error "Expression or statement is incorrect "
I don't know why this is incorrect
Thanks a lot for your time and help
Walter Roberson
Walter Roberson 2016 年 10 月 15 日
You missed the point size parameter
scatter(xX, yX, 5, RGB, 'filled')
Walter Roberson
Walter Roberson 2016 年 10 月 15 日
I recommend:
coltab = [255 153 153; 204 204 255];
RGB = coltab(z(:), :);
pointsize = 5;
scatter(x, y, pointsize, RGB, 'filled');

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

カテゴリ

タグ

質問済み:

2016 年 10 月 14 日

コメント済み:

2016 年 10 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by