No BSD License  

Highlights from
Datetick with zooming panning and subplots

4.22222

4.2 | 10 ratings Rate this file 32 Downloads (last 30 days) File Size: 4.9 KB File ID: #20422
image thumbnail

Datetick with zooming panning and subplots

by Andrew Bliss

 

24 Jun 2008 (Updated 25 Jun 2008)

Date formatted tick labels, automatically updated when zoomed or panned.

| Watch this File

File Information
Description

Date formatted tick labels, automatically updated when zoomed or panned. Arguments are identical to those of DATETICK. Allows 2 or more subplots, keeps all of them synched using LINKPROP.

For best results with multiple subplots, call datetick2 from the axis that has the widest range of dates. This functionality could be included, but would probably needlessly bloat the code.

  Example:
  figure
  h(1)=subplot(411);
  plot(now:1:now+100,randn(101,1))
  h(2)=subplot(412);
  plot(now:1:now+10,rand(11,1))
  h(3)=subplot(413);
  plot(now+20:1:now+30,rand(11,1))
  h(4)=subplot(414);
  plot(now-5:1:now+5,rand(11,1))
  datetick2

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Datetickzoom - automatically update dateticks
This submission has inspired the following:
Datetick Zoom, Pan & Subplot with Day of Year

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (16)
25 Jun 2008 Carlos Adrian Vargas Aguilera

Andrew, I'd like to know what is the improvement of original Lauwery's datetickzoom.m or my tlabel.m?

07 Aug 2008 Andy Bliss

Carlos - The improvement over Lauwery's is that datetick2 works for multiple subplots. The functionality is simply different from your tlabel. My code is simple (150 lines vs 750) and works with R2007a (yours doesn't b/c of the catch ME syntax).

13 Aug 2008 Carlos Adrian Vargas Aguilera

That's it! You copy/write 150 lines because of a single bug line! (BTW multiple axes is nothing new).

Well, I was hopping... something. I use this kind of functions a lot, thats why my extra lines do this:
- adds ticks when just 3 are displayed.
- you can use any language, not just english (for the months of course)
- you can use any dateformat, not only MATLABs defaults.
- xlabel is linked and is used to print the whole date
- yes, there is a bug which I already fix: ''catch, ME = lasterror;'' but now i'm working in other parts of the code (single axis labels, with the limits, whit a better link function), so, I haven't update it.
- yes, yours searches automatically! for the axes handles of the current plot. Mine does it manually, :( .

Yours, Carlos

22 Dec 2008 Andrew Bliss

You rate my file a 1 simply because you like your own version better? That's not very nice.

30 Jan 2009 Rajesh Rajaram  
26 Jun 2009 Avinash Rude

Great!

Just what I needed.

Works like a charm!

Thanks Andrew Bliss

03 Jul 2009 Daniel Golden

Very useful for correlating multiple data sets.

24 Sep 2009 Nathan

I use this ALL the time - great function!

10 Nov 2009 Grant  
10 Nov 2009 Grant  
10 Nov 2009 Grant

This is a great program and it works well, except when there is a legend on the plot, then it fails. Seems like it is trying to use the axis handle of the legend rather than the x-axis handle.

20 Nov 2009 David

With regard to the program failure when a legend handle is found, I changed the "&&" to "&" on line 60 and changed the "Legend" to "legend" on line 61 and the program properly neglects the legend handle.

24 Nov 2009 Yan

There is one called zoomAdaptiveDateTicks (Pick of the Week)
http://www.mathworks.com/matlabcentral/fileexchange/15342

I have not found anything similar(date ticks adapt to zooming) for in 7.0 or 7.2, any clue?

10 Jan 2011 Pieter  
15 May 2011 Jahanzeb Mian

Wow this function is really helpful, but I lose this behavior if I save a figure and then reopen it again. I have to re-run the datetick2 function. Is there any other way?

11 Jun 2011 Nicolas

hold arrowkey -> matlab crashes

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data exploration Andrew Bliss 22 Oct 2008 10:07:12
datetick Andrew Bliss 22 Oct 2008 10:07:12
zoom Andrew Bliss 22 Oct 2008 10:07:12
pan Andrew Bliss 22 Oct 2008 10:07:12
subplots Andrew Bliss 22 Oct 2008 10:07:12
date Andrew Bliss 22 Oct 2008 10:07:12
time axis Andrew Bliss 22 Oct 2008 10:07:12

Contact us at files@mathworks.com