COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Plot date labels

• Email
• Follow

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

See related articles to this posting

"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

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.

> > 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

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 (7455) 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 (7455) 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 (7455) 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 (7455) 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 (6403) 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

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 (7455) 5/4/2013 2:42:41 PM

15 Replies
39 Views

Similar Articles

12/13/2013 6:30:58 PM
[PageSpeed]

Similar Artilces:

Plotting date-time series in 3D how to handle date-time to plot
I have a year's worth of time series data that I would like to plot in 3d using ListPlot3D. ListPlot3D does not accept the system formatted dates like the 2D utility DateListPlot. Q1. What is the best way to plot this type of time series in 3D where the date-times may cross January 1 and two or more years? A week's worth of data is appended. I have previously been doing this by converting raw csv data file's date-time to a Julian Day in Excel and then importing to Mathematica. I would like to simplify things by doing the entire import and plot routine in Mathematica dir...

plot label
Hi guys!! I would like to make some plots, but only with certain number shown in the x and y axis. Is there any clever command to do that in IDL ?? For example write only 3000, 3500, 4000, 4500 rather then 3100,3200,3300 etc .... Or, example, to write 3000 in bigger size, 3500 in smaller, 4000 in bigger on so on ... Thanks! S. Steve.Morris@libero.it wrote: > Hi guys!! > I would like to make some plots, but only with certain number shown in > the x and y axis. Is there any clever command to do that in IDL ?? Clever? No. > For example write only 3000, 3500, 4000, 4500 rather ...

Label placement on plots
Hi, Related to my earlier post: When I copy and paste the figures into MSWord with a new default font, the axis tick labels overwrite the axis text label because the program is not giving enough vertical room for both. Is there an easy way around this? Thanks again, Mike Michael Woodmansee wrote: > When I copy and paste the figures into MSWord with a new default font, the axis tick labels overwrite the axis text label because the program is not giving enough vertical room for both. Is there an easy way around this? short answer: no longer answer: we save the figs as <.ps>/<.eps...

plotting xaxis with date
Hi I have x axis as years that is, for example, 21223 Here 2 corresponds to year 12 is month and 23 is day now using this below commands, I have done yy=strmid(p1(1),7,1) mm=strmid(p1(1),8,2) dd=strmid(p1(1),10,2) s=strcompress(dd+'/'+mm+'/'+'200'+yy,/remove_all) and now s=23/12/2002 like this I have converted my x axis values from 21223. But now i need to plot this dates in xaxis with corresponding yaxis data. How to do this? Please give some suggesions in this regard. regards sid sid writes: > I have x axis as years that is, > for example, > >...

Labelled matrix plot
I'd like to do a matrix plot of a 72x72 matrix with columns/rows labelled. I implemented it by making 72^2 rectangles and arranging them in a Grid, and after some tweaking of Spacings/ItemSize it looks just right on screen, but I can't figure out how to save the result in an image. 1. The expression is too big to fit on screen so "Right Click/Copy As" only copies part of it 2. Exporting the Grid as a PNG file cuts off the part not showing on the screen 3. Graphics[Inset[grid]] changes the color, spacing, and leaves out non-graphical label elements 4. Saving as HT...

plot against date and time
Hi everybody, I have large data output from sensors over several days to months. So far I am just plotting the counts of two columns but I have to plot them against the date and time columns (in the x-axis). Any suggestions? Thanx ==== .m file ==== clear; clf; load data.dat; t=data(:,4); c=data(:,5); figure; subplot(2,1,1); plot(c,'k-'); title('Concentration') xlabel('Count'); ylabel('mol l ^-1'); subplot(2,1,2); plot(t,'r-'); title('Temperature') xlabel('Count'); ylabel('�C'); ================== ==== data.dat ==== 2006-0...

Re: Regression Plot Labeling
Hi Mike - Add an axis statement, then assign it in your plot statement. (I assume this works in plotting within proc reg; if not, you'll have to output your data set and do a proc gplot). Untested: > symbol1 v=dot c=blue height=2.5pct; AXIS1 label=('A11'); > proc reg data=test; > model Var3=Var2; > plot Var3*Var2 / haxis=axis1; > run; > HTH (and hope this works!) Venita > ---------- > From: Mike V[SMTP:mousemo@HOTMAIL.COM] > Reply To: Mike V > Sent: Tuesday, July 13, 2004 12:56 PM > To: SAS-L@LISTSERV.UGA.EDU > Su...

Plot labeled points or vectors??
I have some vectors saved in a directory and I want to plot them with their names. I want them to appear like points with the name or just the name For example I want the name V1 plotted at [4,1] coordinates How can I do this? Please, if it=B4s possible give me an example with a pair of vectors. Thanks On Aug 27, 7:54=A0am, elturco <anuara...@gmail.com> wrote: > I have some vectors saved in a directory and I want to plot them with > their names. > I want them to appear like points with the name or just the name > For example I want the name V1 plotted at [4,1] coordinates &g...

Plotting Date vs. Data
Hello, maybe somebody can help me in plotting dates vs. data? All Data is contained in an array named "dat" in the following format, where the first column represents the date in yyyymmddhhmm followed by the data itself: 200901010015 -99.000 -99.000 .... ... .. If I use the command plot(dat(:,1),dat(:,3)), of course I get in trouble with the days of the month and the plot seems to be discontinous. May be somebody can explain to me how it works or just give a "matlab-newbie" a few hints? "Steffen nil" <hippeldi@gmx.net> wrote in message <hnniv2$ce7$...

Legends on a Date List Plot
Hello Everyone, Does PlotLegend work with DateListPlot? I'm having trouble creating a legend for three time series of stock prices plotted on the same graph. Regards, Gregory= ...

How to label the x-axis with dates
I've got an arrey with values (integers from 0-100), and i try to make a plot out of it. The spacing between the dates are NOT constant, i.e, the observations is every day, exept weekends or something like that. I've red some thread, among thoose: %Example: %plot(dates, y); %datetick('x', 19); %Note1: dates must be a vector of serial dates (obtained with datenum) %Note2: 19 is one of a series of different formats that datetick can print the date into. %Note3: you might want to add 'keepticks' as a third input argument in order to get a good tick repartition. I...

normalizing labels in a 3d plot
Is there an easy way to simply change the values shown on the x,y axes of a 3d plot without changing the z-values or the range. I am showing data varying at 50 different radii in a sphere and the x axis is labeled from 0-50. I used surf(...) to create the plot and just want to normalize the labels on the x axis from 0-1 without changing anything on the plot (and without doing it manually each time I create a new one). Everything I have tried seems to change the actual range of the results from 0-1. Any help would be appreciated, thanks. On 10-12-03 01:27 PM, Joseph wrote: > Is th...

Displaying the date as a string label in Simulink
Hi I wonder if it is possible to display the date when a Simulink subsystem was last modified in the name label of a subsystem. Is this possible? I've tried to just display the date a string label in Simulink but this also does not work. I've tried the following: strcat('Last Update: ', datestr(now, 'dd.mm.yyyy') Any help would be appreciated. Cheers, Jaco ...

how to plot a tree assigning nodes with your own labels
When I use the Funtion TreePlot[] with option VertexLabeling -> True, surely there would be labels displayed. However, if I want to designate different nodes with same label, the tree looks not so nice. How could I do? Thanks a lot! On Mar 14, 3:41 am, Sunt <SunTing...@gmail.com> wrote: > When I use the Funtion TreePlot[] with option VertexLabeling -> True, > surely there would be labels displayed. However, if I want to > designate different nodes with same label, the tree looks not so nice. > How could I do? > Thanks a lot! I'm not sure what you&...

Creating a Scatter Plot with Labeled Points
Hello there. I'm trying to graph a Scatter Plot based on a given list of data and have the coordinates appear near the point. I'm trying to save time and, instead of manually typing the text for the coordinates, I'd like to be able to pull the coordinates from the list to plot them point and list the text. Here's what I have so far: S11Exercise64b = {{0, 120}, {10, 119}, {20, 118}, {30, 117}, {40, 116}, {50, 115}, {60, 114}, {70, 113}, {80, 112}}; ListPlot[S11Exercise64b, AxesLabel -> {x, y}, AxesOrigin -> {0, 0}, Epilog -> {Blue, PointSize[.02], Point...

LaTeX in plot labels not exactly working
Hi Matlab-ers, I'm having a problem when trying to use LaTeX in labels (xlabel, ylabel, zlabel). Namely, when I want a character to be in italics (\itC), the whole label comes out in italics. I tried \it{C}, but still get the whole label in italics. (I'm using Matlab 2008a under Mac OS X 10.5.8). Is this a known feature? If so, is there a work-around? Thank you in advance, Jomar On 1/14/2011 11:24 AM, Jomar Bueyes wrote: > Hi Matlab-ers, > > I'm having a problem when trying to use LaTeX in labels (xlabel, > ylabel, zlabel). Namely, when I want a ch...

plot a graphic and identify each point with a label
Hi, Example: I have 2 vectors (x,y) with size 10. Id like to plot the graphic and identify each point with labels 1,...,10. How can I do that? Regards. Douglas. Douglas <douglas.miranda@gmail.com> wrote in message <1903058366.131769.1290510051858.JavaMail.root@gallium.mathforum.org>... > Hi, > Example: I have 2 vectors (x,y) with size 10. Id like to plot the graphic and identify each point with labels 1,...,10. > How can I do that? > Regards. > Douglas. Hi Douglas: You probably want the "text(...)" function. See here: http://www.mathwor...

Data labels on an x-y plot
I am trying to get data labels onto an x-y map. I have coordinates for thirty locations. Each of the locations is designated a number, 1-30. But I can't seem to get the labels to display properly. The best I have been able to manage is to get data labels 1-9 to show up using the code: ch_idw = ['1' '2' '3' '4' '5' '6' '7' '8' '9' '10']'; % and I've also tried, ch_idw = [1:size(ch_locations,1)]'; for K = 1:size(ch_idw,1) text(x(K), y(K), ch_idw(K)) end But once I reach double digits the...

Convert Date and Time string and plot
Hello I am having problem using datenum function. I have a 'time' cell of array strings like the following : Data has event based time period i.e each log has a timestamp when there has been an event '07/09/2009 22:17:37' '07/09/2009 22:18:00' '07/09/2009 22:18:00' '07/09/2009 22:18:45' '07/09/2009 22:18:54' '07/09/2009 22:19:53' '07/09/2009 22:19:58' '08/09/2009 05:06:00' Data is logged till next day at random intervals. Is there any other way than datenum that I can plot these values?...

Help : in labeling the plots of a 3D graph
hi guys... Got a doubt in graph session of matlab. IS IT POSSIBLE TO LABEL THE PLOTS OF A 3D GRAPH BY MATLAB ?? (i mean were matlab itself will name the plots with its coordinate values or ny other values defined with in t prog). Please do help me out... ...