f



Unable to get "datetick('x','HHPM')" to work..

Dear all,

I been trying to learn this example "Plot traffic count data against date ticks for hours of the day showing AM and PM." which is found here.. http://www.mathworks.co.jp/access/helpdesk/help/techdoc/ref/datetick.html

but it seems I have problem with this command, datetick('x','HHPM') and it gave me this message...
??? Error using ==> datetick
Unknown date format: HHPM

However I tried using the second last command, plot(xdate,count) and it is plot the graph with out the x-axis label in date/time...

Any help this this will be great..

Thanks.

Jon Kho 
0
JonKho
6/18/2010 2:20:08 AM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

8 Replies
960 Views

Similar Articles

[PageSpeed] 14

JonKho Kho wrote:
....

> but it seems I have problem with this command, datetick('x','HHPM') and 
> it gave me this message...
> ??? Error using ==> datetick
> Unknown date format: HHPM
....

doc datetick

has list of recognized formats for the datetime string format...

--
0
dpb
6/18/2010 2:23:11 AM
dpb <none@non.net> wrote in message <hvelf7$3ml$1@news.eternal-september.org>...
> JonKho Kho wrote:
> ...
> 
> > but it seems I have problem with this command, datetick('x','HHPM') and 
> > it gave me this message...
> > ??? Error using ==> datetick
> > Unknown date format: HHPM
> ...
> 
> doc datetick
> 
> has list of recognized formats for the datetime string format...
> 
> --

Hi, and thanks for replying... didn't knew about "doc" i have been using "help".. 

anyway, I did tried this command previously, datetick('x','HH:MM PM') but it is still not working...

Update: I manually input the command on the console.. and it is not working.. even i used the "clear" commant to remove any values made earlier...

however, I used the editor and it works!!

I noticed the intervals is 6hrs apart.. it is possible to make it 30mins or 1hr apart??

Thanks..
0
JonKho
6/18/2010 2:54:20 AM
JonKho Kho wrote:
....

> anyway, I did tried this command previously, datetick('x','HH:MM PM') 
> but it is still not working...
> 
> Update: I manually input the command on the console.. and it is not 
> working.. even i used the "clear" commant to remove any values made 
> earlier...
> 
> however, I used the editor and it works!!

That would indicate some sort of typo or other issue impossible to 
diagnose from afar w/o session to look at...

> I noticed the intervals is 6hrs apart.. it is possible to make it 30mins 
> or 1hr apart??

That would be set by 'xtick' intervals if the autoscale selection 
doesn't suit...

--
0
dpb
6/18/2010 4:13:25 AM
> 
> That would be set by 'xtick' intervals if the autoscale selection 
> doesn't suit...
> 
> --

Hi, Thanks for your reply... I followed your advice.. and i found this.. http://www.mathworks.com/support/solutions/en/data/1-15TK6/index.html?solution=1-15TK6

dear all, 

Now I am trying to make it integrate to the earlier coding.. but I have no luck...

I am looking at this....
% Place the axis label at this point
XMidPoint = Xl(1)+abs(diff(Xl))/2;
tl = text(XMidPoint,LowYPoint,'X-Axis Label', ...
'VerticalAlignment','top', ...
'HorizontalAlignment','center');

Thanks
0
JonKho
6/18/2010 7:59:08 AM
JonKho Kho wrote:
>>
>> That would be set by 'xtick' intervals if the autoscale selection 
>> doesn't suit...
>>
>> -- 
> 
> Hi, Thanks for your reply... I followed your advice.. and i found this.. 
....

well, that's not exactly my advice...if you want to follow that lead I'd 
suggest downloading the function referenced and utilizing it.

My suggestion was to retrieve the default datenums from the autoscaled 
x-axis with something like

xtk = get(gca,'xtick');

and modify that array to suit the number and spacing desired and then

set(gca,'xtick',xtk_modified);

--
0
dpb
6/18/2010 1:05:21 PM
> well, that's not exactly my advice...if you want to follow that lead I'd 
> suggest downloading the function referenced and utilizing it.
> 
> My suggestion was to retrieve the default datenums from the autoscaled 
> x-axis with something like
> 
> xtk = get(gca,'xtick');
> 
> and modify that array to suit the number and spacing desired and then
> 
> set(gca,'xtick',xtk_modified);

Hi and thanks for your reply.. I will check it out and understand more about it.. also is it even possible to use on the x-axis in the 3d bar graph like this?? I am playing around with it on this type of presentation..

http://i48.tinypic.com/2v3n0cp.jpg

thanks.
0
JonKho
6/19/2010 3:21:04 AM
Here is the update...

I direct edited it by

xtk = [4,5,6]

and 

set(gca,'YTickLabel',xtk )

But it still shows "1,2,3" and i am not sure what is happening...

here is the screenshot..

http://i47.tinypic.com/2ikqkc3.jpg

thanks
0
JonKho
6/19/2010 3:55:05 AM
"JonKho Kho" <email@school.com> wrote in message <hvhf2p$3m2$1@fred.mathworks.com>...
> Here is the update...
> 
> I direct edited it by
> 
> xtk = [4,5,6]
> 
> and 
> 
> set(gca,'YTickLabel',xtk )
> 
> But it still shows "1,2,3" and i am not sure what is happening...
> 
> here is the screenshot..
> 
> http://i47.tinypic.com/2ikqkc3.jpg
> 
> thanks

dear all..

I manged to complete it.. using this thread... http://www.mathworks.es/matlabcentral/newsreader/view_thread/47953

but i need to adjust the positions of the labels... how can i do it een trying for couple of hours...

here is the coding..

function set_xtick_label(tick_labels, angle, axis_label)
% SET_XTICK_LABEL Print the xtick labels at an angle instead of horizontally
% set_xtick_label(tick_labels, angle, axis_label)
%
% angle default = 90
% axis_label default = ''
%
% This is derived from Solution Number: 5375 on mathworks.com
% See set_xtick_label_demo for an example

if nargin < 2, angle = 90; end
if nargin < 3, axis_label = []; end

% Reduce the size of the axis so that all the labels fit in the figure.
pos = get(gca,'Position');
set(gca,'Position',[pos(1), .2, pos(3) .65])

ax = axis; % Current axis limits
axis(axis); % Fix the axis limits
Yl = ax(3:4); % Y-axis limits

%set(gca, 'xtick', 1:length(tick_labels));
set(gca, 'xtick', 0.7:1:length(tick_labels));
Xt = get(gca, 'xtick');

% Place the text labels
t = text(Xt,Yl(1)*ones(1,length(Xt)),tick_labels);
set(t,'HorizontalAlignment','right','VerticalAlignment','top', 'Rotation', angle);

% Remove the default labels
set(gca,'XTickLabel','')

% Get the Extent of each text object. This
% loop is unavoidable.
for i = 1:length(t)
  ext(i,:) = get(t(i),'Extent');
end

% Determine the lowest point. The X-label will be
% placed so that the top is aligned with this point.
LowYPoint = min(ext(:,2));

% Place the axis label at this point
if ~isempty(axis_label)
  Xl = get(gca, 'Xlim');
  XMidPoint = Xl(1)+abs(diff(Xl))/2;
  tl = text(XMidPoint,LowYPoint, axis_label, 'VerticalAlignment','top', ...
'HorizontalAlignment','center');
end

Thanks!!
0
JonKho
6/20/2010 8:10:27 AM
Reply: