color of area depending on value | MATLAB IoT Analytics | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
color of area depending on value
No permission to create posts
May 7, 2019
10:50 am
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

a third question, if I may ...

I'm using an area to display the difference between two lines.

diff = line1(1:maxCount) - line2(1:maxCount);
a = area(line1.Timestamps(1:maxCount), diff(1:maxCount));

How could I change the color depending on the resulting value? E.g. everything in 'green' except if values '<5' which should be displayed in 'red'.

The area starts below zero:
set (a, 'BaseValue', min-2.5)

Thanks for your help

May 7, 2019
1:02 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 754
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline
May 8, 2019
1:41 am
Avatar
obod0002

Silver
Members
Forum Posts: 19
Member Since:
March 13, 2019
sp_UserOfflineSmall Offline

hmm, maybe my question was not as precise as it should have been...
I'm looking for a way to paint an area in two different cvolors depending on its value, e.g. as in this example from my Raspberry Pi where the area is either 'green' or 'red'. The color depends on the result of the maths from 'line1 - line2'.
RPIplotsmall.jpgImage Enlarger

How could I do that in MATLAB?

sp_PlupAttachments Attachments
May 14, 2019
10:21 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 754
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

This is not quite what you wanted, but its closer. It uses the color property of the scatter plot.

sz=300;
x=1:200;
myVals=10*rand(1,200);
sameVals=ones(200,1);
plot(x,myVals);
hold
scatter(x,sameVals,sz,myVals,'filled','s')
Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
32 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Fathima22, jefflam1994, harrydawson, markpaul7931, sgarsvk2rdx, Win Win

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457