Coloring scatter plot based on count number
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a table (results) with time as a first column (result.time) and the count of an event in the second (result.event). I would like to plot the counts through time and colour the dots depending on the count number.
This is the start of my table:
time = ({'25-Jul-2018 00:00:00';'25-Jul-2018 00:15:00';'25-Jul-2018 00:30:00';'25-Jul-2018 00:45:00';'25-Jul-2018 01:00:00';'25-Jul-2018 01:15:00';'25-Jul-2018 01:30:00';'25-Jul-2018 01:45:00';'25-Jul-2018 02:00:00';'25-Jul-2018 02:15:00';'25-Jul-2018 02:30:00';'25-Jul-2018 02:45:00';'25-Jul-2018 03:00:00';'25-Jul-2018 03:15:00';'25-Jul-2018 03:30:00';'25-Jul-2018 03:45:00';'25-Jul-2018 04:00:00';'25-Jul-2018 04:15:00';'25-Jul-2018 04:30:00';'25-Jul-2018 04:45:00'})
time = datetime(time,'InputFormat','dd-MMM-yyyy HH:mm:ss');
event = ([0; 1; 0; 1; 0; 0; 2; 0; 0; 4; 0; 0; 0; 0; 0; 0; 0; 5; 10; 2])
results = table(time,event)
scatter(results.time,results.event)
In the scatter plot, I would like the event markers to be coloured differently depending on their value (e.g. from yellow for small numbers to red for bigger numbers).
I have found some interesting ideas there: https://in.mathworks.com/matlabcentral/answers/28849-coloring-scatterplots-based-on-frequency-of-point-occurrence-in-input but it is not exactly what I need.
Many thanks for your help!
0 件のコメント
採用された回答
Adam Danz
2021 年 9 月 17 日
編集済み: Adam Danz
2021 年 9 月 17 日
Unchanged base code
time = ({'25-Jul-2018 00:00:00';'25-Jul-2018 00:15:00';'25-Jul-2018 00:30:00';'25-Jul-2018 00:45:00';'25-Jul-2018 01:00:00';'25-Jul-2018 01:15:00';'25-Jul-2018 01:30:00';'25-Jul-2018 01:45:00';'25-Jul-2018 02:00:00';'25-Jul-2018 02:15:00';'25-Jul-2018 02:30:00';'25-Jul-2018 02:45:00';'25-Jul-2018 03:00:00';'25-Jul-2018 03:15:00';'25-Jul-2018 03:30:00';'25-Jul-2018 03:45:00';'25-Jul-2018 04:00:00';'25-Jul-2018 04:15:00';'25-Jul-2018 04:30:00';'25-Jul-2018 04:45:00'});
time = datetime(time,'InputFormat','dd-MMM-yyyy HH:mm:ss');
event = ([0; 1; 0; 1; 0; 0; 2; 0; 0; 4; 0; 0; 0; 0; 0; 0; 0; 5; 10; 2]);
results = table(time,event);
Define color
scatter(results.time,results.event, 90, results.event, 'filled')
set colormap
colormap(flipud(autumn(255)))
cb = colorbar();
ylabel(cb, 'Count') % redundant with y-axis
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!