How can I "connect" the colorbar to my values of a scatter plot?
조회 수: 7 (최근 30일)
이전 댓글 표시
How can I "connect" the colorbar to my values (between 0 and 1) of a scatter plot?
a = rand(1000,1);
C = 1-[a a a];
scatter(1:length(a),a,60,C,'fill')
colormap(C);
colorbar;
Here you can see that the colorbar is not gradually changing from 0 to 1.. How to fix it?
댓글 수: 0
채택된 답변
Star Strider
2024년 6월 22일
I am not certain what you want to do, or what you intend by ‘connect’.
One option —
a = rand(1000,1);
% C = 1-[a a a];
C = ([1;1;1]*linspace(1, 0, 1000)).';
scatter(1:length(a),a,60,C,'fill')
colormap(C);
colorbar;
.
댓글 수: 6
Star Strider
2024년 6월 24일
As always, my pleasure!
No worries! Often, these sorts of mathematical concepts are difficult to describe.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!