4:08 am

Silver

June 22, 2016

Hi,

I'm posting weather data to a few channels on ThingSpeak, for example this outdoor temperature:

I know how to change the color for the entire line in the graph, but since this is an outdoor temperature in Norway - where the temperature changes between above and below freezing on a regular basis - it would be really nice to have the graph line have different colors above and below freezing. Specifically, I would like it to be blue below 0 (freezing point on the Centigrade scale) and red above 0.

Any ideas how to do that?

12:06 am

Top

January 30, 2014

3:49 pm

MathWorks

August 25, 2015

Here is an example MATLAB code snippet to help you get started:

% Read data from your channel

[data, time] = thingSpeakRead(130083, 'NumPoints', 8000, 'Fields', 1);

% Create variables for holding values greater than zero and less than zero

dataGtZero = NaN(1, length(data));

dataLsZero = NaN(1, length(data));

% Assign values to the variables

% dataGtZero has all values of data that are greater than zero

dataGtZero(data>0) = data(data>0);

% dataLsZero has all values of data that are less than zero

dataLsZero(data<0) = data(data<0);

% Plot both chunks of data and specify color to be blue ('b') for data less than zero and red for the other.

plot(time, dataLsZero, 'b');

hold on;

plot(time, dataGtZero, 'r')

Most Users Ever Online: 114

Currently Online:

25 Guest(s)

Currently Browsing this Page:

1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

JamesVex, meghanfr69, raqueldk69, soniafw2, vitalijDrine, JosephAmapyAdministrators: Hans: 387, lee: 457