"2-d line plot" dosent show correct on external site. iframe | ThingSpeak Apps | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
"2-d line plot" dosent show correct on external site. iframe
Avatar
popunonkok

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
1
January 9, 2017 - 12:59 pm
sp_Permalink sp_Print

I copy and paste the iframe code from a visualisation that works great on the thingspeak site, the page for my channel. 

 

But when I past the code on my own page the graph dosent show in the expected way. On the thingspeak page the graph is the standard blue thin line for a 2d plot. But on my page it just shows the standard thingspeak red with dots. The colour is not a problem but the time period showing isnt correct either. The 2d plot is showing 1 day of data on the thingspeak page, but on my page it dosent show a complete day.

 

The iframe code Im using.

Avatar
akhila

Forum Posts: 21
sp_UserOfflineSmall Offline
2
January 10, 2017 - 8:08 am
sp_Permalink sp_Print

Hi popunonkok

Is this a public MATLAB Visualization? Would it be possible share the MATLAB code without the channel id or API keys to enable us to investigate this issue further? 

Thanks

Akhila 

Avatar
popunonkok

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
3
January 10, 2017 - 11:20 am
sp_Permalink sp_Print

The way the graph looks at my channels  page at Thingspeak.

Image Enlarger

 

The way the Graph looks in the iFrame on my own page.

Image Enlarger

 

The iFrame code snippet:

<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/119501"></iframe>

 

The code from Matlab Visualisation

% Template MATLAB code for visualizing data from a channel as a 2D line
% plot using THINGSPEAKPLOT function.

% Prior to running this MATLAB code template, assign the channel ID to read
% data from to the 'readChannelID' variable. Also, assign the field ID
% within the channel that you want to read data from to plot.

% TODO - Replace the [] with channel ID to read data from:
readChannelID = [XXXXXXXX];
% TODO - Replace the [] with the Field ID to read data from:
fieldID1 = [2];

% Channel Read API Key
% If your channel is private, then enter the read API
% Key between the '' below:
readAPIKey = 'XXXXXXXX';

%% Read Data %%

[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumDays',1, 'ReadKey', readAPIKey);

%% Visualize Data %%

thingSpeakPlot(time, data);

Any help would be appreciated.

 

Tanks in advance.

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
4
January 10, 2017 - 9:50 pm
sp_Permalink sp_Print sp_EditHistory

Let's try this:

1) Create a new text document and save it as Test.html

2) In the text document, add this:

<html>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/YourMATLABVizNumber"></iframe>
</html>

3) Open this up in your browser. Does this look like you expect?
 
If this does not look like the plot you expect, confirm that the plot generated by your MATLAB visualization is added to your channel and the YourMATLABVisualizationNumber corresponds to the plot for your channel.
Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
5
January 10, 2017 - 10:13 pm
sp_Permalink sp_Print sp_EditHistory

Here's an example MATLAB visualization that I have made public and inserted into HTML

<html>
<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/119981"></iframe>
</html>
Avatar
popunonkok

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
6
January 11, 2017 - 6:59 am
sp_Permalink sp_Print

I dont know what I did but it seems to be working now.

 

I try to ask another question here before starting a new topic.

 

Is there a way to tilt the x axis lables 45 degrees on a 2-d line plot? When I google I can see that the function exist on matlab but I cant seem to get it to work on the thingspeak plugin page. Where I enter the code for the plot.

Im also looking to set a min and max value for the y axis in the plot. It is easy on the default Thingspeak graph but in the code for a plot i cant get it to work. I have used the examples that I have found that regards Matlab but not thingspeak.

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
7
January 11, 2017 - 7:51 am
sp_Permalink sp_Print

You can certainly use the method described in the documentation here: http://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html

This should work for axes generated by PLOT and similar commands. 

Avatar
popunonkok

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
8
January 11, 2017 - 10:57 am
sp_Permalink sp_Print

Thanks for the reply but that does not seem to work.

% Template MATLAB code for visualizing data from a channel as a 2D line
% plot using THINGSPEAKPLOT function.

% Prior to running this MATLAB code template, assign the channel ID to read
% data from to the 'readChannelID' variable. Also, assign the field ID
% within the channel that you want to read data from to plot.

% TODO - Replace the [] with channel ID to read data from:
readChannelID = [XXXXX];
% TODO - Replace the [] with the Field ID to read data from:
fieldID1 = [2];

% Channel Read API Key
% If your channel is private, then enter the read API
% Key between the '' below:
readAPIKey = 'XXXXXXXXXX';

%% Read Data %%

[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumDays',1, 'ReadKey', readAPIKey);

xtickangle(45)

%% Visualize Data %%

thingSpeakPlot(time, data);

It does not generate a Error but the xtick lables are straight as an arrow, not 45 degrees. I also tried with a trailing semicolon, ( ; ) with no difference.

There are lots of stuff I would like to "adjust/customise", number of decimals and time format are 2 things.

 

Image Enlarger

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
9
January 11, 2017 - 11:15 am
sp_Permalink sp_Print

I do not expect the xtick label to work with thingSpeakPlot.

Try MATLAB's PLOT command instead.

Avatar
popunonkok

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
10
January 11, 2017 - 12:34 pm
sp_Permalink sp_Print

Hmmm... I just went through the menu Apps -> MATLAB Visualization -> Create a 2d line plot.

Where and how do I find a way to do a MATLAB PLOT instead?

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
11
January 11, 2017 - 5:22 pm
sp_Permalink sp_Print

In the code example you have above, replace the line

thingSpeakPlot(time, data); 

with

plot(time,data);

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: cstapels
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

yeseniara11

RomanFug

JamesPes

RobertBak

ScottSmiva

Amourhotte

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee