필터 지우기
필터 지우기

PROBLEM with SCATTER using DATA CONTROL OF COLOR

조회 수: 5 (최근 30일)
francois heslot
francois heslot 2021년 10월 29일
댓글: francois heslot 2021년 11월 8일
Hello,
I want to make a SCATTER PLOT , USING A SECOND ARRAY FOR COLOR CONTROL.
I encounter the PROBLEM of NO COLOR CONTROL by THE SECOND ARRAY, see below the deceptively simple lines of code.
% TTT = vector array ( 1 X 20000 double)
% A = data array ( 100 X 20000 double ) [with many NaN's]
% B = data array ( 100 X 20000 double ) [with many NaN's]
% see ATTACHMENT : mat-file containing T, A, B
% B contains NaN's and STRICTLY POSITIVE numbers (a requirement for color
% control
scatter(T, A, '.'); % Data = T and A only;
% (COLOR IS CONTROLLED BY THE ARRAY A):
% gives the following figure:
% Below is my tentative of a data-driven color control using the array B
scatter(T, A, B,'.');
% the figure obtained is below; No color change has occurred !!!
% (the only significative change is the 'dot' size that is now unexpectedly
% larger. This was not exactly my goal here...)
I DO NOT SUCCEED in getting color control by the array B.
YOUR HELP WILL BE APPRECIATED !!
THANKS,

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 10월 29일
편집: Cris LaPierre 2021년 10월 29일
The color in your first plot is controlled by the figure colororder property, and not by A. Basically, each series is plotted using the next color in the colororder property. Once all the colors have been used, it restarts at the first color. Because there are only 7 colors in the default colororder, your plot cycles through the colors many times.
Note that color is the 4th input to scatter. The 3rd input is size, and corresponds to where you have input B.
B does not work as a color input because it is neither a vector nor a mx3 matrix of RGB triplets (see here). The solution is to plot your data one row at a time.
% Load your data
load TAB.mat
for c = 1:size(A,1)
scatter(T, A(c,:),[], B(c,:),'.');
hold on
end
hold off

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by