Coloring scatter plot based on count number

15 visualizaciones (últimos 30 días)
Butterflyfish
Butterflyfish el 17 de Sept. de 2021
Comentada: Butterflyfish el 18 de Sept. de 2021
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).
Many thanks for your help!

Respuesta aceptada

Adam Danz
Adam Danz el 17 de Sept. de 2021
Editada: Adam Danz el 17 de Sept. de 2021
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

Más respuestas (0)

Categorías

Más información sobre Orange en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by