필터 지우기
필터 지우기

Scatter Diagram with colorbar

조회 수: 3 (최근 30일)
Philipp Mueller
Philipp Mueller 2016년 9월 15일
댓글: Adam 2016년 9월 15일
What is the best solution/way to create a very simple scatter diagram with a colorbar.
My input should be a .txt file with 3 columns -> x - coordinate, y - coordiante and value for filling the dots with color. I have found a simple code but the color information is a little bit different.
I want this color input "colors = [212 34 45 12 5]" not colors = ['r' 'g' 'b' 'y' 'c']. Is an other code better? Thank you.
X = [1 2 3 8 1]
Y = [5 4 5 1 5]
%color = [212 34 45 12 5]
fig = figure;
colors = ['r' 'g' 'b' 'y' 'c']
hold on;
for i=1:5
scatter(X(i), Y(i), 'LineWidth',10,'MarkerFaceColor',colors(i))
end
hold off;
resp = fig2plotly(fig)
plotly_url = resp.url;
  댓글 수: 1
Adam
Adam 2016년 9월 15일
What are those colour values supposed to represent? Are they indices into some colourmap? Otherwise colour must be represented as an RGB triplet.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2016년 9월 15일
You can use RGB color code, like for Red [255 0 0], Green [0 255 0] and Blue [0 0 255] ;
%Force vs Time Different plate angle
X = [1 2 3 8 1] ;
Y = [5 4 5 1 5] ;
%color = [212 34 45 12 5]
fig = figure;
% colors = ['r' 'g' 'b' 'y' 'c'] ;
colors = [255 0 0 ; 0 255 0 ; 0 0 255 ;255 255 0 ;160 160 160] ;
hold on;
for i=1:5
scatter(X(i), Y(i), 'LineWidth',10,'MarkerFaceColor',colors(i,:)/255)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by