Simple xtickformat question | MATLAB | 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
Simple xtickformat question
Avatar
lboucher
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
1
October 22, 2017 - 7:29 pm
sp_Permalink sp_Print sp_EditHistory

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');

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOnlineSmall Online
2
October 23, 2017 - 3:06 pm
sp_Permalink sp_Print

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.  

Avatar
lboucher
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
October 23, 2017 - 9:50 pm
sp_Permalink sp_Print

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.

Avatar
lboucher
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
4
October 24, 2017 - 7:21 am
sp_Permalink sp_Print

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: cstapels, jacktheripper125
19 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:

Nsneilotof

angieus2

goldiepw11

BinanceoSt

gnarender123@gmail.com

edenderest

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee