Filter löschen
Filter löschen

PROBLEM with SCATTER using DATA CONTROL OF COLOR

5 Ansichten (letzte 30 Tage)
francois heslot
francois heslot am 29 Okt. 2021
Kommentiert: francois heslot am 8 Nov. 2021
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,

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 29 Okt. 2021
Bearbeitet: Cris LaPierre am 29 Okt. 2021
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

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by