Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:22:23+00:00 2026-06-11T08:22:23+00:00

I have the following code for producing a plot of data that extends two

  • 0

I have the following code for producing a plot of data that extends two years in terms of day of year:

time = datenum('2008-04-17 02:00'):datenum('2009-11-24 12:27');
dateV = datevec(time);
for i = 1:length(time);
    DOY(i) = time(i) - datenum(dateV(i,1),0,0);
end
data = rand(length(time),1);
plot(time,data);
set(gca,'XTick',floor(time(1:50:end))','XTickLabel',floor(DOY(1:50:end))) 

Could someone suggest a method for ensuring the ticks on the xaxis are for day numbers that are multiples of 10 i.e. 110, 160 etc.

ADDED SECTION:

DateTime=datestr(datenum('2007-01-01 00:00','yyyy-mm-dd HH:MM'):1/24:...
    datenum('2011-12-31 23:00','yyyy-mm-dd HH:MM'),...
    'yyyy-mm-dd HH:MM');
time = datenum(DateTime,'yyyy-mm-dd HH:MM');

dateV = datevec(time);
for i = 1:length(time);
    DOY(i) = time(i) - datenum(dateV(i,1),0,0);
end
data = rand(length(time),1);
plot(time,data);

mydays = ~mod(floor(DOY),40);  %true for days that are multiples of 10
set(gca,'XTick',floor(time(mydays))','XTickLabel',floor(DOY(mydays))) 

Error using set
Values must be monotonically increasing

This can be fixed by removing floor, i.e.

set(gca,'XTick',time(mydays),'XTickLabel',floor(DOY(mydays))) 

But it generates the labels in bold, why is this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:22:25+00:00Added an answer on June 11, 2026 at 8:22 am

    You can generate an index to days that are multiples of N using the mod function. This function returns you the remainder after dividing a number by N.

     mydays = ~mod(floor(DOY),10);  %true for days that are multiples of 10
     data = rand(length(time),1);
     plot(time,data);
     set(gca,'XTick',time(mydays),'XTickLabel',floor(DOY(mydays))) 
    

    In your case having each multiple of 10 would lead to too many labels on the x-axis, so maybe try multiple of 40, which produces the following: image.

    Finally, if you want to change the axis labels so that it is no longer in bold, you can use:

    set(gca, 'FontWeight', 'normal');
    

    or similarly you can alter its size and font:

    set(gca, 'FontSize', 14, 'FontName', 'Calibri')
    

    EDIT: corrected typo in previous code, and added note on altering label font

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have code that is producing the following unhandled exception: Error Message: System.Reflection.TargetParameterCountException: Parameter
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for inserting data into database using PDO. It inserts data
I have following code that I am compiling in a .NET 4.0 project namespace
I have following code: def whatever(url, data=None): req = urllib2.Request(url) res = urllib2.urlopen(req, data)
I have what is, to me, a confusing situation. The following code is producing
The following code is producing an Unsupported operator types error: $data = $modelData +
I have the following code which is producing this error. I cannot understand why
I have the following code that automates a slideshow between the different slides as
I have a theory why the following code is not producing the results I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.