PROBLEM with SCATTER using DATA CONTROL OF COLOR

5 次查看(过去 30 天)
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