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

  • SEARCH
  • Home
  • 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 8259907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:58:09+00:00 2026-06-08T02:58:09+00:00

I am having difficulties on plotting time on the xaxis. I have some overlapping

  • 0

I am having difficulties on plotting time on the xaxis. I have some overlapping labels. See below:

plot

This is my code:

time=datenum(0,0,0,0,0,timeinseconds);
labs=1:10:length(time);

figure(3);
plotyy(time,xvalue,time,dens);
datetick('x','HH:MM');
set(gca,'XTick',time(labs),'XTickLabel',time(labs)); 
legend('xval','CDF');
title('Crash on Oct.10 2008 at 15:59pm');
xlabel('Time');

First, why are the labels overlapping with the old ones? And secondly, how I can get the label to rotate 90degrees? I tried some other matlab functions to turn the labels but none seem able to tackle time format labels.

  • 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-08T02:58:11+00:00Added an answer on June 8, 2026 at 2:58 am

    Calling plotyy you create two axis objects. Your overlap problem does probably come from the fact that you modify only one set of those axis, while leaving the other as it was originally set up.

    One option is handling both of the created axis when you call plotyy by:

    [AX, H1, H2] = plotyy( time, xvalue, time, dens);
    

    Your first option here is setting up both of the axis, contained within the array of handlers AX, via changing the'XTick' propriety as:

    set( AX(1), 'XTick', time(labs), 'XTickLabel', time(labs));
    set( AX(2), 'XTick', time(labs), 'XTickLabel', time(labs));
    

    But you also have the option of leaving the labels for the second axis empty, replacing the second line above:

    set( AX(1), 'XTick', time(labs), 'XTickLabel', time(labs));
    set( AX(2), 'XTick', time(labs), 'XTickLabel', []);
    

    The official documentation of plotyy and Using Multiple X- and Y-Axes can be of further help for you.


    If you take a look on the example there, namely, plotyy documentation:

    figure
    x = 0:0.01:20;
    y1 = 200*exp(-0.05*x).*sin(x);
    y2 = 0.8*exp(-0.5*x).*sin(10*x);
    [AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
    

    and as you did before, try to modify only the AX(2), which is equivalent to what you got writing gca:

    set(AX(2),'XtickLabel',1:0.1:20)
    

    you will observe that the same overlapping error takes place.

    With respect to rotating the labels 90 deg, I’m afraid that’s not currently supported by Matlab. However, you can probably get that done using one of the available packages on FileExchange. Either xticklabelrotate or Rotate Tick Label could be the one.

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

Sidebar

Related Questions

I'm having difficulties to understand the code below taken from this page http://trevordavis.net/play/jquery-one-page-nav/ (tutorial
I'm having difficulties adding momentum to my spinning wheel. I have this wheel (something
I'm having difficulties working with some legacy enums that have multiple zero values. Whenever
I'm having difficulties parsing a string. This is the structure I have: Title:Avatar,Year:2009,Rated:PG-13,Released:18 Dec
I am having difficulties figuring this out. I can see I am posting XML
I having difficulties setting my footer properly. I have a Bottom navigation bar as
I am having difficulties in disabling href links through jquery. I am using this
I'm having difficulties grasping how to do this. I am making a product options
I am having difficulties to code a simple jquery enlarge image feature on a
I'm having difficulties reading an app.config using the ConfigurationManager. I have a custom section,

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.