Set scatter plot color with RGB

Hi!
I've got a question concerning my scatter plot.
I would like to set the color of the hexagons ('h') with a RGB triplet.
I tried with the help MATLAB gives under scatter with the following code:
scatter(xM14s,yM14s,125,'h','MarkerEdgeColor',[1 1 1], 'linewidth',2)
However this gives an error:
h(n) = matlab.graphics.chart.primitive.Scatter('Parent', parax, ...
which I don't understand.
In the same diagram I have:
lsline
h = lsline;
set(h(1),'color',[0.5 0.5 0.5],'linewidth',1)
Does this have to do with the error? When I remove the scatter plot and leave the lsline, the error however goes away.
Thanks!

3 件のコメント

Scott MacKenzie
Scott MacKenzie 2021 年 5 月 24 日
Your code looks fine. But, bear in mind that your defined color for the marker edges is white: [1 1 1]. So, the markers will be invisible (assuming your background is the default white).
Sean Bredella
Sean Bredella 2021 年 5 月 24 日
Yes, i have tried with other Colors aswell. The problem is it gives me an error and no plot...
Image Analyst
Image Analyst 2021 年 5 月 24 日
x = rand(100,1);
y = rand(100,1);
MarkerColor = [0.5, 0.5, 0.5];
scatter(x, y, 40, MarkerColor, 'filled');
grid on;

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

回答 (1 件)

Image Analyst
Image Analyst 2021 年 5 月 24 日
編集済み: Image Analyst 2021 年 5 月 24 日

0 投票

I don't know what you mean by hexagons but to see the 3-D scatterplot of the RGB gamut, use colorcloud().
rgbImage = imread('peppers.png');
colorcloud(rgbImage);

3 件のコメント

Sean Bredella
Sean Bredella 2021 年 5 月 24 日
just scatter(x,y,colorcloud([1 0.4 0.5])) as an example?
Image Analyst
Image Analyst 2021 年 5 月 24 日
No. colorcloud() does the scatterplot itself.
rgbImage = imread('peppers.png');
colorcloud(rgbImage);
Sean Bredella
Sean Bredella 2021 年 5 月 24 日
Thank you ver much for the effort.
But i have a 2D scatter plot and i want a specific color i made with an RGB Vector...

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

カテゴリ

質問済み:

2021 年 5 月 24 日

コメント済み:

2021 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by