Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
more xticks displayed in datetick?

Subject: more xticks displayed in datetick?

From: Mike Liu

Date: 17 Jun, 2011 03:42:02

Message: 1 of 7

Hi,

I have about a dataset with 8000x1 vector.
x is in datenumber.
When I use datetick:
datetick('x','yy/mm','keepticks');
there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?

Mike

Subject: more xticks displayed in datetick?

From: TideMan

Date: 17 Jun, 2011 04:08:51

Message: 2 of 7

On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
> Hi,
>
> I have about a dataset with 8000x1 vector.
> x is in datenumber.
> When I use datetick:
> datetick('x','yy/mm','keepticks');
> there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?
>
> Mike

Could you have given us any less information?
You say you have a vector, but you must have 2 vectors, x and
something else.
What is the time span you're trying to plot?
If it is only one month, then of course only January will be
displayed.

But in answer to your question, yes you can have any number of xticks
you like, just specify them like this:
set(gca,...
   'XTick',[x(1):10:x(end)])
would give ticks every 10 days.

Subject: more xticks displayed in datetick?

From: Mike

Date: 17 Jun, 2011 05:04:44

Message: 3 of 7

On Jun 17, 12:08 pm, TideMan <mul...@gmail.com> wrote:
> On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
>
> > Hi,
>
> > I have about a dataset with 8000x1 vector.
> > x is in datenumber.
> > When I use datetick:
> > datetick('x','yy/mm','keepticks');
> > there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?
>
> > Mike
>
> Could you have given us any less information?
> You say you have a vector, but you must have 2 vectors, x and
> something else.
> What is the time span you're trying to plot?
> If it is only one month, then of course only January will be
> displayed.
>
> But in answer to your question, yes you can have any number of xticks
> you like, just specify them like this:
> set(gca,...
>    'XTick',[x(1):10:x(end)])
> would give ticks every 10 days.

Sorry, forgot to mention.
The time span is from 2004/01/01 to 2010/12/31. y is within [0,2].
I'd like to plot xtics with every first day of Jan., Apr., Jul., Oct.
spanning 2004~2010.
Thank you very much for your reply.

Mike

Subject: more xticks displayed in datetick?

From: Mike

Date: 17 Jun, 2011 05:29:53

Message: 4 of 7

On Jun 17, 1:04 pm, Mike <sulfate...@gmail.com> wrote:
> On Jun 17, 12:08 pm, TideMan <mul...@gmail.com> wrote:
>
>
>
>
>
> > On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
>
> > > Hi,
>
> > > I have about a dataset with 8000x1 vector.
> > > x is in datenumber.
> > > When I use datetick:
> > > datetick('x','yy/mm','keepticks');
> > > there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?
>
> > > Mike
>
> > Could you have given us any less information?
> > You say you have a vector, but you must have 2 vectors, x and
> > something else.
> > What is the time span you're trying to plot?
> > If it is only one month, then of course only January will be
> > displayed.
>
> > But in answer to your question, yes you can have any number of xticks
> > you like, just specify them like this:
> > set(gca,...
> >    'XTick',[x(1):10:x(end)])
> > would give ticks every 10 days.
>
> Sorry, forgot to mention.
> The time span is from 2004/01/01 to 2010/12/31.  y is within [0,2].
> I'd like to plot xtics with every first day of Jan., Apr., Jul., Oct.
> spanning 2004~2010.
> Thank you very much for your reply.
>
> Mike- Hide quoted text -
>
> - Show quoted text -

I've tried set(......,x(1):step:x(end)) for various step. I change the
step value and find the min and max x plotted will be changed.
How can I have the min and max of x values plotted?
Thanks.

Mike

Mike

Subject: more xticks displayed in datetick?

From: TideMan

Date: 17 Jun, 2011 05:40:39

Message: 5 of 7

On Jun 17, 5:29 pm, Mike <sulfate...@gmail.com> wrote:
> On Jun 17, 1:04 pm, Mike <sulfate...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 17, 12:08 pm, TideMan <mul...@gmail.com> wrote:
>
> > > On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I have about a dataset with 8000x1 vector.
> > > > x is in datenumber.
> > > > When I use datetick:
> > > > datetick('x','yy/mm','keepticks');
> > > > there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?
>
> > > > Mike
>
> > > Could you have given us any less information?
> > > You say you have a vector, but you must have 2 vectors, x and
> > > something else.
> > > What is the time span you're trying to plot?
> > > If it is only one month, then of course only January will be
> > > displayed.
>
> > > But in answer to your question, yes you can have any number of xticks
> > > you like, just specify them like this:
> > > set(gca,...
> > >    'XTick',[x(1):10:x(end)])
> > > would give ticks every 10 days.
>
> > Sorry, forgot to mention.
> > The time span is from 2004/01/01 to 2010/12/31.  y is within [0,2].
> > I'd like to plot xtics with every first day of Jan., Apr., Jul., Oct.
> > spanning 2004~2010.
> > Thank you very much for your reply.
>
> > Mike- Hide quoted text -
>
> > - Show quoted text -
>
> I've tried set(......,x(1):step:x(end)) for various step. I change the
> step value and find the min and max x plotted will be changed.
> How can I have the min and max of x values plotted?
> Thanks.
>
> Mike
>
> Mike

You need to go read the handle graphics portion of the Matlab help.
It's all there.
I don't have the patience to spoon-feed you.

Subject: more xticks displayed in datetick?

From: Steven_Lord

Date: 17 Jun, 2011 13:45:51

Message: 6 of 7



"Mike" <sulfateion@gmail.com> wrote in message
news:af73fb49-a8a4-4d32-965e-4a2971ea90cf@z7g2000prh.googlegroups.com...
> On Jun 17, 12:08 pm, TideMan <mul...@gmail.com> wrote:
>> On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
>>
>> > Hi,
>>
>> > I have about a dataset with 8000x1 vector.
>> > x is in datenumber.
>> > When I use datetick:
>> > datetick('x','yy/mm','keepticks');
>> > there are too many ticks. But if I use without 'keepticks', there only
>> > january displayed. Can I have more xticks displayed?
>>
>> > Mike
>>
>> Could you have given us any less information?
>> You say you have a vector, but you must have 2 vectors, x and
>> something else.
>> What is the time span you're trying to plot?
>> If it is only one month, then of course only January will be
>> displayed.
>>
>> But in answer to your question, yes you can have any number of xticks
>> you like, just specify them like this:
>> set(gca,...
>> 'XTick',[x(1):10:x(end)])
>> would give ticks every 10 days.
>
> Sorry, forgot to mention.
> The time span is from 2004/01/01 to 2010/12/31. y is within [0,2].
> I'd like to plot xtics with every first day of Jan., Apr., Jul., Oct.
> spanning 2004~2010.
> Thank you very much for your reply.

Then generate a vector of serial date numbers corresponding to your desired
ticks (the DATENUM function will help you do this) and SET the XTick
property to that vector of serial date numbers. Then use DATETICK with
'keeplimits'.

% Generate date to plot and plot it
x = datenum('1/1/2011'):datenum('12/31/2011');
y = sin((1:length(x))-1);
plot(x, y)

% Determine the first day of each month
firstDays = datenum(2011, 1:12, ones(1, 12));

% Update the tick locations
set(gca, 'XTick', firstDays);

% Update the tick text
datetick('x', 'mmm dd', 'keepticks')

% Make sure the axes spans the entire year
xlim(x([1 end]))

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: more xticks displayed in datetick?

From: Roozbeh Daneshvar

Date: 9 Nov, 2012 21:21:09

Message: 7 of 7

If you don't have the patience, then why bother to come here and reply?
I would suggest you either don't reply or if you are doing so, do it in a nice and polite way. Many people are using this opportunity to resolve problems, learn and improve their programming. If it is upsetting you, please let others do it.


TideMan <mulgor@gmail.com> wrote in message <a947bc77-95b4-473f-a5ad-82ec2438560d@b21g2000yqc.googlegroups.com>...
> On Jun 17, 5:29 pm, Mike <sulfate...@gmail.com> wrote:
> > On Jun 17, 1:04 pm, Mike <sulfate...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > On Jun 17, 12:08 pm, TideMan <mul...@gmail.com> wrote:
> >
> > > > On Jun 17, 3:42 pm, "Mike Liu" <sulfate...@gmail.com> wrote:
> >
> > > > > Hi,
> >
> > > > > I have about a dataset with 8000x1 vector.
> > > > > x is in datenumber.
> > > > > When I use datetick:
> > > > > datetick('x','yy/mm','keepticks');
> > > > > there are too many ticks. But if I use without 'keepticks', there only january displayed. Can I have more xticks displayed?
> >
> > > > > Mike
> >
> > > > Could you have given us any less information?
> > > > You say you have a vector, but you must have 2 vectors, x and
> > > > something else.
> > > > What is the time span you're trying to plot?
> > > > If it is only one month, then of course only January will be
> > > > displayed.
> >
> > > > But in answer to your question, yes you can have any number of xticks
> > > > you like, just specify them like this:
> > > > set(gca,...
> > > >    'XTick',[x(1):10:x(end)])
> > > > would give ticks every 10 days.
> >
> > > Sorry, forgot to mention.
> > > The time span is from 2004/01/01 to 2010/12/31.  y is within [0,2].
> > > I'd like to plot xtics with every first day of Jan., Apr., Jul., Oct.
> > > spanning 2004~2010.
> > > Thank you very much for your reply.
> >
> > > Mike- Hide quoted text -
> >
> > > - Show quoted text -
> >
> > I've tried set(......,x(1):step:x(end)) for various step. I change the
> > step value and find the min and max x plotted will be changed.
> > How can I have the min and max of x values plotted?
> > Thanks.
> >
> > Mike
> >
> > Mike
>
> You need to go read the handle graphics portion of the Matlab help.
> It's all there.
> I don't have the patience to spoon-feed you.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us