Plot won't show line

4 views (last 30 days)
Loraine Luceñara
Loraine Luceñara on 25 Jul 2019
Answered: Vinod on 25 Jul 2019
I've been trying to plot a chart on thingspeak. but the line won't seem to appear. How do I make the line appear?
I've tried to change the line to a dashed line, I've also tried to varying the linewidth but all it got me were much bigger markers. I've checked and all the arrays right size. If it helps, the timestamps array is a datetime array.
Here is all of my code:
% Channel ID to read data from
readChannelID = 827912;
% Temperature Field ID
TemperatureFieldID = 1;
% Wind speed Field ID
HumidityFieldID = 4;
% Channel Read API Key
% If your channel is private, then enter the read API
% Key between the '' below:
readAPIKey = 'CZD7YSPVMXAAI188';
% Read Data. Learn more about the thingSpeakRead function by
% going to the Documentation tab on the right side pane of this page.
[data, timeStamps] = thingSpeakRead(readChannelID, 'Fields',[TemperatureFieldID HumidityFieldID], ...
'NumPoints', 300, ...
'ReadKey', readAPIKey);
% Extract the temperature data from the first column
temperatureData = data(:, 1);
% Extract the windspeed data from the second column
HumidityData = data(:, 2);
% Visualize Data
yyaxis left
plot(timeStamps, temperatureData,'mo-',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',5);
ylabel('Temperature');
hold on;
yyaxis right
plot(timeStamps, HumidityData, '--mo',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',5);
ylabel('Humdity');

Accepted Answer

Vinod
Vinod on 25 Jul 2019
My guess is that your data has a bunch of NaN's in it which is causing the issue.
Look at the documentation of the rmmissing and fillmissing functions in MATLAB as a way to remove or fill the missing points before plotting.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on Visualize Data in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!