Change colour of plot when colouring according to a variable
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
William Garrett
am 16 Mär. 2020
Bearbeitet: Aghamarsh Varanasi
am 18 Mär. 2020
I have some air quality data from a room and an activity log which tells me if anybody was in it.
I have created a plot showing the change in pollution concentration over time and I have coloured the plot according to activity (1 = activity; 0 = no activity).
However, when there is no activity, the plot is yellow - which is hard to see. How do I change this? I have used the following code:
scatter(Table.Date_Time, Table.Concentration, 5, Table.Activity)
0 Kommentare
Akzeptierte Antwort
Aghamarsh Varanasi
am 18 Mär. 2020
Bearbeitet: Aghamarsh Varanasi
am 18 Mär. 2020
Hi,
I understand that you are plotting air quality data using scatter function. You wanted to change the color of the plot based on the value in the variable ‘activity’. You could use the ‘MarkerFaceColor’ and ‘MarkerEdgeColor’ name-value pairs in the scatter function to change the color of your plot.
You could use a if statement to differentiate the activity variable. A sample MATLAB code could be
if activity == 0
scatter(Table.Date_Time, Table.Concentration, 5, Table.Activity, 'MarkerFaceColor', 'red');
else
scatter(Table.Date_Time, Table.Concentration, 5, Table.Activity, 'MarkerFaceColor', 'blue');
end
For further reference on coloring of a scatter plot refer : https://www.mathworks.com/help/matlab/ref/scatter.html
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!