Hi everybody, I have a 2 column matrix to plot, one with the dates in number and the other column with the values. My problem is the date labels to plot on the x axis, because if I have 100obs I cannot print 100 date labels. In order to face it I tried with some loops but I have an inconsistency on the time range (same space interval different time period of months). I suppose there is an easy way to do it, so if I have a column-vector x with the dates in number and y with the values. What I have to do in order to plot it?
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/9/2012 5:47:16 PM |
|
"mklcst mklcst" wrote in message <k00t34$t35$1@newscl01ah.mathworks.com>...
> Hi everybody, I have a 2 column matrix to plot, one with the dates in number and the other column with the values. My problem is the date labels to plot on the x axis, because if I have 100obs I cannot print 100 date labels. In order to face it I tried with some loops but I have an inconsistency on the time range (same space interval different time period of months). I suppose there is an easy way to do it, so if I have a column-vector x with the dates in number and y with the values. What I have to do in order to plot it?
Providing your number-dates are Matlab datenums, just plot(x,y) as normal and then do:
datetick x % or datetick('x')
Alternatively, open the documentation with "doc" and search for something like "plot dates".
|
|
0
|
|
|
|
Reply
|
juestan-matlabnews6h8 (7)
|
8/9/2012 6:06:17 PM
|
|
Thank you Justin.
But I don't see the label in date format as 'mmm-yy' but in numeric one.
If I set "set(gca,'XTick',x)" I see an overlapped text and plot.
"Justin Ashmall" <juestan-matlabnews6h8@yahoo.co.uk> wrote in message <k00u6p$3hq$1@newscl01ah.mathworks.com>...
> "mklcst mklcst" wrote in message <k00t34$t35$1@newscl01ah.mathworks.com>...
> > Hi everybody, I have a 2 column matrix to plot, one with the dates in number and the other column with the values. My problem is the date labels to plot on the x axis, because if I have 100obs I cannot print 100 date labels. In order to face it I tried with some loops but I have an inconsistency on the time range (same space interval different time period of months). I suppose there is an easy way to do it, so if I have a column-vector x with the dates in number and y with the values. What I have to do in order to plot it?
>
> Providing your number-dates are Matlab datenums, just plot(x,y) as normal and then do:
> datetick x % or datetick('x')
>
> Alternatively, open the documentation with "doc" and search for something like "plot dates".
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/10/2012 7:06:22 AM
|
|
"mklcst mklcst" wrote in message <k02bte$l1q$1@newscl01ah.mathworks.com>...
> Thank you Justin.
> But I don't see the label in date format as 'mmm-yy' but in numeric one.
> If I set "set(gca,'XTick',x)" I see an overlapped text and plot.
Are your dates Matlab datenums?
> > Providing your number-dates are Matlab datenums
Did you check the documentation?
> > open the documentation with "doc" and search for something like "plot dates".
Looking at the the documentation for datetick it says:
"The axis data values should be generated by or be compatible with the output of the datenum function."
I suspect your "dates in number" are some odd format and that's why it's not working. You don't give any examples so it's impossible to tell.
|
|
0
|
|
|
|
Reply
|
juestan-matlabnews6h8 (7)
|
8/10/2012 10:48:09 AM
|
|
My dates vector in in datenum, the problem is that if I set the gca Thr plot is overlapped... I searched on DOC and also I googled it my I didn't find a solution to my problem.
So let's start with an example, suppose you have 1200 of monthly obs (for conveniente se simulate from a standard normal) and a vector of datenums from 1/1/1900 to 31/12/1999.
Can you show me how to proceed?
"Justin Ashmall" <juestan-matlabnews6h8@yahoo.co.uk> wrote in message <k02ot9$riq$1@newscl01ah.mathworks.com>...
> "mklcst mklcst" wrote in message <k02bte$l1q$1@newscl01ah.mathworks.com>...
> > Thank you Justin.
> > But I don't see the label in date format as 'mmm-yy' but in numeric one.
> > If I set "set(gca,'XTick',x)" I see an overlapped text and plot.
>
> Are your dates Matlab datenums?
> > > Providing your number-dates are Matlab datenums
>
> Did you check the documentation?
> > > open the documentation with "doc" and search for something like "plot dates".
>
> Looking at the the documentation for datetick it says:
> "The axis data values should be generated by or be compatible with the output of the datenum function."
>
> I suspect your "dates in number" are some odd format and that's why it's not working. You don't give any examples so it's impossible to tell.
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/10/2012 2:26:10 PM
|
|
On 8/10/2012 9:26 AM, mklcst mklcst wrote:
[Do NOT toppost...hard conversation follow makes]
> My dates vector in in datenum, the problem is that if I set the gca Thr
> plot is overlapped......
You don't set gca, you use datetick()
doc datetick % and friends...
--
|
|
0
|
|
|
|
Reply
|
none1568 (6651)
|
8/10/2012 2:41:56 PM
|
|
Yes I use: datetick(xData,'mmm-yy','keeplimit');
where xData is a datenum vector.
The problem is that I see in the plot the x-axis label in number
dpb <none@non.net> wrote in message <k036js$e2g$1@speranza.aioe.org>...
> On 8/10/2012 9:26 AM, mklcst mklcst wrote:
>
> [Do NOT toppost...hard conversation follow makes]
>
> > My dates vector in in datenum, the problem is that if I set the gca Thr
> > plot is overlapped......
>
> You don't set gca, you use datetick()
>
> doc datetick % and friends...
>
> --
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/10/2012 3:11:17 PM
|
|
On 8/10/2012 9:26 AM, mklcst mklcst wrote:
....
> So let's start with an example, suppose you have 1200 of monthly obs
> ... and a vector of datenums from 1/1/1900 to 31/12/1999.
> Can you show me how to proceed?
....
>> t=linspace(datenum(1900,1,1),datenum(1999,12,31),1200)';
>> d=rand(size(t));
>> plot(t,d)
>> datetick('x','yyyy')
--
|
|
0
|
|
|
|
Reply
|
none1568 (6651)
|
8/10/2012 3:19:06 PM
|
|
On 8/10/2012 10:11 AM, mklcst mklcst wrote:
{TOP POSTING REPAIRED (ONCE) NO MORE RESPONSES IF YOU PERSIST)
> dpb <none@non.net> wrote in message <k036js$e2g$1@speranza.aioe.org>...
>> On 8/10/2012 9:26 AM, mklcst mklcst wrote:
....
>> You don't set gca, you use datetick()
....
> Yes I use: datetick(xData,'mmm-yy','keeplimit');
> where xData is a datenum vector.
....
doc datetick
NB the first argument definition per documentation.
> datetick(tickaxis) labels the tick lines of an axis using dates,
> replacing the default numeric labels. tickaxis is the string 'x',
> 'y', or 'z'. The default is 'x'.
--
|
|
0
|
|
|
|
Reply
|
none1568 (6651)
|
8/10/2012 3:46:56 PM
|
|
ok, I get it. What about if I want to increase the number of displayed labels?
dpb <none@non.net> wrote in message <k03adt$o0s$1@speranza.aioe.org>...
> On 8/10/2012 10:11 AM, mklcst mklcst wrote:
>
> >> On 8/10/2012 9:26 AM, mklcst mklcst wrote:
> ...
>
>
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/10/2012 5:15:23 PM
|
|
On 8/10/2012 12:15 PM, mklcst mklcst wrote:
> ok, I get it. What about if I want to increase the number of displayed
> labels?
doc datetick
--
|
|
0
|
|
|
|
Reply
|
none1568 (6651)
|
8/10/2012 5:39:13 PM
|
|
I don't understand if I have to build manually the vector of dates.
dpb <none@non.net> wrote in message <k03h04$914$1@speranza.aioe.org>...
> On 8/10/2012 12:15 PM, mklcst mklcst wrote:
> > ok, I get it. What about if I want to increase the number of displayed
> > labels?
>
> doc datetick
>
> --
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/11/2012 7:07:09 AM
|
|
"mklcst mklcst" wrote in message <k050as$enf$1@newscl01ah.mathworks.com>...
> I don't understand if I have to build manually the vector of dates.
t=now+(1:10);
plot(t,rand(size(t)));
set(gca,'xtick',t,'xlim',t([1 end]));
datetick('x','keeplimits','keepticks');
% Bruno
|
|
0
|
|
|
|
Reply
|
b.luong5955 (6344)
|
8/11/2012 8:22:07 AM
|
|
Bruno maybe you enlightened me, so if xData is my "t" (as in your example) if I code:
set(gca,'xtick',xData([1,50,100,150,300,end]),'xlim',xData([1 end]));
I enable the label of obs 1, 50, 100, 150,300, end ?
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k054nf$qmn$1@newscl01ah.mathworks.com>...
> "mklcst mklcst" wrote in message <k050as$enf$1@newscl01ah.mathworks.com>...
> > I don't understand if I have to build manually the vector of dates.
>
> t=now+(1:10);
> plot(t,rand(size(t)));
>
> set(gca,'xtick',t,'xlim',t([1 end]));
> datetick('x','keeplimits','keepticks');
>
> % Bruno
|
|
0
|
|
|
|
Reply
|
mkcst (12)
|
8/11/2012 5:42:07 PM
|
|
"mklcst mklcst" wrote in message <k035m2$bo4$1@newscl01ah.mathworks.com>...
> My dates vector in in datenum, the problem is that if I set the gca Thr plot is overlapped... I searched on DOC and also I googled it my I didn't find a solution to my problem.
> So let's start with an example, suppose you have 1200 of monthly obs (for conveniente se simulate from a standard normal) and a vector of datenums from 1/1/1900 to 31/12/1999.
> Can you show me how to proceed?
>
>
> "Justin Ashmall" <juestan-matlabnews6h8@yahoo.co.uk> wrote in message <k02ot9$riq$1@newscl01ah.mathworks.com>...
> > "mklcst mklcst" wrote in message <k02bte$l1q$1@newscl01ah.mathworks.com>...
> > > Thank you Justin.
> > > But I don't see the label in date format as 'mmm-yy' but in numeric one.
> > > If I set "set(gca,'XTick',x)" I see an overlapped text and plot.
> >
> > Are your dates Matlab datenums?
> > > > Providing your number-dates are Matlab datenums
> >
> > Did you check the documentation?
> > > > open the documentation with "doc" and search for something like "plot dates".
> >
> > Looking at the the documentation for datetick it says:
> > "The axis data values should be generated by or be compatible with the output of the datenum function."
> >
> > I suspect your "dates in number" are some odd format and that's why it's not working. You don't give any examples so it's impossible to tell.
Hello Justin Ashmall,
I am experiencing the same problem described below. How could I get this fixed?
Cheers,
Juliana
|
|
0
|
|
|
|
Reply
|
juju_petroleo (1)
|
5/4/2013 2:13:09 PM
|
|
On 5/4/2013 9:13 AM, Juliana Santos wrote:
....
> I am experiencing the same problem described below. How could I get this
> fixed?
....
Well, there is no "below" but as the responses in the thread in general
note, to display dates on an axis w/ Matlab,
a) generate the subject axis values via datenum() and friends, and
b) utilized datetick() on the proper axis w/ format and all as desired
doc datenum % and friends
doc datetick
No specifics shown, no specifics in response are possible...
--
|
|
0
|
|
|
|
Reply
|
none1568 (6651)
|
5/4/2013 2:42:41 PM
|
|
|
15 Replies
30 Views
(page loaded in 0.199 seconds)
|