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,
0 件のコメント
採用された回答
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 Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!