Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

datetick string in two lines?

650 views
Skip to first unread message

Dave Jackson

unread,
Feb 29, 2008, 9:01:01 AM2/29/08
to
Hi,

I want to make a plot, the xaxis is date, for example, one
value may be:
11:25 02/29/2008

But I want to split the string into two rows because it is
too long in one row and the plot looks very crowded.

So, the xaxis will be like this:

11:25 13:25 14:25
02/29/2008 03/01/2008 03/02/2008


Is there any way to do this in matlab?

Thanks.

Dave


Pekka

unread,
Feb 29, 2008, 12:24:02 PM2/29/08
to
"Dave Jackson" <wlm...@mathworks.com> wrote in message
<fq936t$du8$1...@fred.mathworks.com>...

One way to do it is to replace the xticklabels with regular
text objects.
Here is a link to a function I posted last week, that could
help
http://www.mathworks.com/matlabcentral/newsreader/
view_thread/163920#416254

ticks = get(gca,'XTick');
TL = get(gca,'XTickLabel');
%% split the ticklabels to two line cells or sprintf with \n
h = my_xticklabels(ticks,newlabels);


Dave Jackson

unread,
Feb 29, 2008, 2:18:02 PM2/29/08
to
Thanks, it works!

emamm

unread,
Mar 7, 2008, 4:26:47 AM3/7/08
to
> > h = my_xticklabels(ticks,newlabels);- Hide quoted text -
>
> - Show quoted text -

it worked for me too, but the xticks won't change when zooming. Can
this fixed?

Many thanks

Ed

Pekka

unread,
Mar 7, 2008, 5:32:02 AM3/7/08
to
emamm <emamm...@gmail.com> wrote in message <c01d943c-
5cf8-48a5-ad3...@o77g2000hsf.googlegroups.com>...
> On Feb 29, 4:18=A0pm, "Dave
Jackson" <wlmd...@mathworks.com> wrote:
> > Thanks, it works!
> >
> >
> >
> >
> >
> > > One way to do it is to replace the xticklabels with
regular
> > > text objects.
> > > Here is a link to a function I posted last week, that
could
> > > help
> > >http://www.mathworks.com/matlabcentral/newsreader/
> > > view_thread/163920#416254
> >
> > > ticks =3D get(gca,'XTick');
> > > TL =3D get(gca,'XTickLabel');

> > > %% split the ticklabels to two line cells or sprintf
with \n
> > > h =3D my_xticklabels(ticks,newlabels);- Hide quoted
text -
> >
> > - Show quoted text -
>
> it worked for me too, but the xticks won't change when
zooming. Can
> this fixed?
>
> Many thanks
>
> Ed

It _could_ be fixed, but no time for that at the moment,
sorry. As I wrote in the earlier posts, this is a very
quick simple function I wrote to a colleaque to get a nice
printout. Intended to be used as the last one (after
zooming to the desired level and fixing the window size
etc.) before exporting the graphics.
I myself have never even needed that kind of thing in my
19 years of using MATLAB.

Anyway, I'll take a look at the zoom issue later on.

This functionality should actually be built in. Everybody,
post an enhancement request! Maybe it will happen some day.
Haven't installed 2008a yet, don't know if it is already
there...

0 new messages