Simple xtickformat question | MATLAB | 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
Simple xtickformat question
No permission to create posts
October 22, 2017
7:29 pm
Avatar
lboucher
New Member
Members
Forum Posts: 4
Member Since:
October 22, 2017
sp_UserOfflineSmall Offline

Hi All

I'm a newb and this should be a real simple question.
Trying to plot some data for the past week which works, but the X Ticks are unreadable.
I would like it to just display the month and day, regardless of scrolling or zooming.

Link to unreadable plot
https://thingspeak.com/apps/matlab_visualizations/180907

I have been searching the documenation on xtickformat and xdatetick, but nothing works.

My code is below, if I run it with the xtickform('MM-dd') i get the following error.

Error using xtickformat (line 34)
Invalid numeric tick label format.

Error in Last Week Cabin Well Temperature (line 30)
xtickformat('MM-dd');

Also, a secondary question. I would like 1 line to plot solid, and another to plot only markers. I assume I must specifically edit each line as desire after the thinkspeakplot command, but I don't know the syntax.

 

Any help is much appreaciated. Thanks!

readChannelID = [339540];
fieldIDs = [1,2,3,4];
readAPIKey = '';
[TempData,timeStamps] = thingSpeakRead(readChannelID,'fields',fieldIDs,'NumDays',7,'ReadKey',readAPIKey);

thingSpeakPlot(timeStamps,TempData,'xlabel','TimeStamps',...
'ylabel','Measured Values','title','Last Week Cabin Temperature Data',...
'Legend',{'Well Temp','Power Loss Well Min Temp','Outside Temp','Power Loss Outside Temp'},'grid','on');

xtickformat('MM-dd');

October 23, 2017
3:06 pm
Avatar
cstapels
Moderator
Members


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

thingSpeakPlot() has some extra functionality built in to simplify things, but it doesn't have all of the MATLAB plot options. 

You could use plot();

plot(timeStamps,TempData);
xlabel('TimeStamps');
ylabel('Measured Values');
title('Last Week Cabin Temperature Data');
grid on
legend({'Well Temp','Power Loss Well Min Temp','Outside Temp','Power Loss Outside Temp'})
xtickformat('MM-dd');

For your secondary question, have a look at the line specification page.  There are some examples using multiple line styles there.  

October 23, 2017
9:50 pm
Avatar
lboucher
New Member
Members
Forum Posts: 4
Member Since:
October 22, 2017
sp_UserOfflineSmall Offline

Thanks!

I was thinking along those lines, but wasn't sure how much of Matlab thingspeak supports.

Been about 10 years since i have done heavy matlab work.

October 24, 2017
7:21 am
Avatar
lboucher
New Member
Members
Forum Posts: 4
Member Since:
October 22, 2017
sp_UserOfflineSmall Offline

Follow on question.

Now i have a plot looking the way I want, but I loose the dynamic zooming capability.

Inspecting the html coming back to the browser, it appears that  using the plot command results in an image coming back to the browser instead of a webplot when using thingSpeakPlot.

Any way to get zoom control when using regular old plot.

I do online there is some fancy javascript out there to make nice looking plots, but thats probably more work than i need to do.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
19 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:

MiguelWap, JamesdinnA, ScottTug, ThomasApesy, RicardoVeque, AlbertRop

Administrators: Hans: 387, lee: 457