Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab question: Xtick and Xticklabel handeling.

Status
Not open for further replies.

serval

Marine/Ocean
Jul 19, 2006
1
My question is very simple: How to put the "XtickLabels" (for example months: Jan, Feb, Mar, etc.) in between two "Xticks"! (using "grid on" for the "Xticks"). That is, put the xlabels in diferent position than the xticks.

For example, if we have a time series of 365 values, I would like to obtain a plot with "13 Xticks" and "12 Xticklables": each Xticklabel should be in between two Xticks (for example the Xticklabel "January" should be in between the Xtick "1" and the Xtick "31"). I've tried with:

%========================================
close all
clear all

monthlim=[1,31,59,90,120,151,181,212,243,273,304,334,365]; %13 Xticks.
xticklabels=['J';'F';'M';'A';'M';'J';'J';'A';'S';'O';'N';'D']; %12 XtickLabels.

y=rand(1,365);
plot([1:365],y)
set(gca,'Xlim',[1,365],'XTick',monthlim,'XTicklabel',xticklabels)
grid on
%========================================

...But this can never work since I am using the same position for the "Xticks" and for the "Xticklabels".

Anybody know how to resolve this problem?.

I would realy apreciate any help or sugestion.

Than you for your time!

Serval.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor