Plot won't show line

3 次查看(过去 30 天)
Loraine Luceñara
Loraine Luceñara 2019-7-25
回答: Vinod 2019-7-25
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');

采纳的回答

Vinod
Vinod 2019-7-25
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.

更多回答(0 个)

社区

更多回答在  ThingSpeak Community

类别

Help CenterFile Exchange 中查找有关 Visualize Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by