Thread Subject: all axis tick labels with the same digits

Subject: all axis tick labels with the same digits

From: pietro

Date: 29 Jul, 2009 10:55:04

Message: 1 of 11

How can i have axis tick labels with the same digit? instead [0 0.05 0.1 0.15 0.2] i would like [0.00 0.05 0.10 0.15 0.20]
thank you in advance

Subject: all axis tick labels with the same digits

From: Wayne King

Date: 29 Jul, 2009 11:14:01

Message: 2 of 11

Hi Pietro, How about

x=[0 0.05 0.1 0.15 0.2];
y=3*x;
plot(x,y)
set(gca,'xticklabel',{'0.00' '0.05' '0.10' '0.15' '0.20'});

Wayne

"pietro " <bracardi82@email.it> wrote in message <h4p9q8$bcu$1@fred.mathworks.com>...
> How can i have axis tick labels with the same digit? instead [0 0.05 0.1 0.15 0.2] i would like [0.00 0.05 0.10 0.15 0.20]
> thank you in advance

Subject: all axis tick labels with the same digits

From: pietro

Date: 29 Jul, 2009 12:00:19

Message: 3 of 11

"Wayne King" <wmkingty@gmail.com> wrote in message <h4patp$mu3$1@fred.mathworks.com>...
> Hi Pietro, How about
>
> x=[0 0.05 0.1 0.15 0.2];
> y=3*x;
> plot(x,y)
> set(gca,'xticklabel',{'0.00' '0.05' '0.10' '0.15' '0.20'});
>
> Wayne
>
> "pietro " <bracardi82@email.it> wrote in message <h4p9q8$bcu$1@fred.mathworks.com>...
> > How can i have axis tick labels with the same digit? instead [0 0.05 0.1 0.15 0.2] i would like [0.00 0.05 0.10 0.15 0.20]
> > thank you in advance

i have too many and different graphs to do like this. Isn't there a function or a axis property?

Subject: all axis tick labels with the same digits

From: dpb

Date: 29 Jul, 2009 13:24:26

Message: 4 of 11

pietro wrote:
> "Wayne King" <wmkingty@gmail.com> wrote in message
> <h4patp$mu3$1@fred.mathworks.com>...
...
...
>> set(gca,'xticklabel',{'0.00' '0.05' '0.10' '0.15' '0.20'});
...
> i have too many and different graphs to do like this. Isn't there a
> function or a axis property?

Unfortunately, no. A pet peeve of mine as well; there's no way to set a
format string for the automagically-generated numeric ticklabel values
and the only way to manually set them is as an array of strings.

Seems like they original coders would have at least had the sense to use
a fixed-width format but they didn't and the annoying and ugly "feature"
has never been fixed since the big bang day of handle graphics.... :(

Maybe put in the feature request again--I did 10 years or more ago but
I've no longer a supported version.

--

Subject: all axis tick labels with the same digits

From: Steven Lord

Date: 29 Jul, 2009 13:30:39

Message: 5 of 11


"pietro " <bracardi82@email.it> wrote in message
news:h4pdki$e5b$1@fred.mathworks.com...
> "Wayne King" <wmkingty@gmail.com> wrote in message
> <h4patp$mu3$1@fred.mathworks.com>...
>> Hi Pietro, How about
>>
>> x=[0 0.05 0.1 0.15 0.2];
>> y=3*x;
>> plot(x,y)
>> set(gca,'xticklabel',{'0.00' '0.05' '0.10' '0.15' '0.20'});
>>
>> Wayne
>>
>> "pietro " <bracardi82@email.it> wrote in message
>> <h4p9q8$bcu$1@fred.mathworks.com>...
>> > How can i have axis tick labels with the same digit? instead [0 0.05
>> > 0.1 0.15 0.2] i would like [0.00 0.05 0.10 0.15 0.20]
>> > thank you in advance
>
> i have too many and different graphs to do like this. Isn't there a
> function or a axis property?

Since I'm guessing you're objecting to the manual way Wayne constructed the
tick label cell array, you can automate the formatting of the labels if the
format you want is possible using the formatting specification in SPRINTF:

x=[0 0.05 0.1 0.15 0.2];
y=3*x;
plot(x,y)
set(gca, 'XTick', x, 'XTickLabel', sprintf('%0.2f|', x));

--
Steve Lord
slord@mathworks.com

Subject: all axis tick labels with the same digits

From: dpb

Date: 29 Jul, 2009 13:53:38

Message: 6 of 11

Steven Lord wrote:
...

> Since I'm guessing you're objecting to the manual way Wayne constructed the
> tick label cell array, you can automate the formatting of the labels if the
> format you want is possible using the formatting specification in SPRINTF:
>
> x=[0 0.05 0.1 0.15 0.2];
> y=3*x;
> plot(x,y)
> set(gca, 'XTick', x, 'XTickLabel', sprintf('%0.2f|', x));

Which brings up the "pet peeve #27" noted above (I came back to post
this additional response as above which I intended to do but got too
wrapped up in the moment... :) ) --

Why can't the user have the ability to set that format or at least why
doesn't presentation graphics have enough internal sense to make a
neater-looking choice than the default? Seems (and has always seemed)
so obvious a minor little detail that would be so beneficial...

--

Subject: all axis tick labels with the same digits

From: pietro

Date: 30 Jul, 2009 11:13:01

Message: 7 of 11

"Steven Lord" <slord@mathworks.com> wrote in message <h4pith$kl4$1@fred.mathworks.com>...
>
> "pietro " <bracardi82@email.it> wrote in message
> news:h4pdki$e5b$1@fred.mathworks.com...
> > "Wayne King" <wmkingty@gmail.com> wrote in message
> > <h4patp$mu3$1@fred.mathworks.com>...
> >> Hi Pietro, How about
> >>
> >> x=[0 0.05 0.1 0.15 0.2];
> >> y=3*x;
> >> plot(x,y)
> >> set(gca,'xticklabel',{'0.00' '0.05' '0.10' '0.15' '0.20'});
> >>
> >> Wayne
> >>
> >> "pietro " <bracardi82@email.it> wrote in message
> >> <h4p9q8$bcu$1@fred.mathworks.com>...
> >> > How can i have axis tick labels with the same digit? instead [0 0.05
> >> > 0.1 0.15 0.2] i would like [0.00 0.05 0.10 0.15 0.20]
> >> > thank you in advance
> >
> > i have too many and different graphs to do like this. Isn't there a
> > function or a axis property?
>
> Since I'm guessing you're objecting to the manual way Wayne constructed the
> tick label cell array, you can automate the formatting of the labels if the
> format you want is possible using the formatting specification in SPRINTF:
>
> x=[0 0.05 0.1 0.15 0.2];
> y=3*x;
> plot(x,y)
> set(gca, 'XTick', x, 'XTickLabel', sprintf('%0.2f|', x));
>
> --
> Steve Lord
> slord@mathworks.com
>
thank you very much, i was finding that.
bye

Subject: all axis tick labels with the same digits

From: dpb

Date: 30 Jul, 2009 15:00:09

Message: 8 of 11

pietro wrote:
...
>> Since I'm guessing you're objecting to the manual way Wayne constructed the
>> tick label cell array, you can automate the formatting of the labels if the
>> format you want is possible using the formatting specification in SPRINTF:
...
> thank you very much, i was finding that.

I still think should submit enhancement request. When I've made such
submittals w/o a currently supported license they've pretty much gotten
the brush off afaict...

--

Subject: all axis tick labels with the same digits

From: Kelly Kearney

Date: 30 Jul, 2009 15:39:01

Message: 9 of 11

dpb <none@non.net> wrote in message <h4scpu$4fh$1@news.eternal-september.org>...
> pietro wrote:
> ...
> >> Since I'm guessing you're objecting to the manual way Wayne constructed the
> >> tick label cell array, you can automate the formatting of the labels if the
> >> format you want is possible using the formatting specification in SPRINTF:
> ...
> > thank you very much, i was finding that.
>
> I still think should submit enhancement request. When I've made such
> submittals w/o a currently supported license they've pretty much gotten
> the brush off afaict...
>
> --

I agree that this is a feature I've always wanted. Manually setting labels is a huge pain, especially if you plan to zoom, pan, change axis limits, etc. I've written a function, tick2text, that allows you to assign a formatting string to ticks (and to do more slightly complicated formatting, like adding TeX strings) by changing them to text objects:

http://www.mathworks.com/matlabcentral/fileexchange/16003

However, this method is a bit limited in that I find myself having to work around manual changes to the axis. For example:

plot(rand(1,5));
tick2text(gca, 'xformat', '%.2f');
set(gca, 'xlim', [0 10]); % Ticks are wrong
zoom(1); % Now ticks are good again

Also, as I have it written write now, you have to fudge around with the buffer variables to figure out where ticks should be located with respect to your axes if you're using subplots.

Having built-in support for formatting would be very nice.

-Kelly

Subject: all axis tick labels with the same digits

From: dpb

Date: 30 Jul, 2009 17:43:37

Message: 10 of 11

Kelly Kearney wrote:
...
> I agree that this is a feature I've always wanted. Manually setting
labels is a huge pain, especially if you plan to zoom, pan, change axis
limits, etc. ...
>
> Having built-in support for formatting would be very nice.

Good to have the file exchange workaround.

Did you submit an enhancement request???

I could try again, but I'm virtually positive I'd get same "you're
version is no longer under maintenance agreement, but if you'll spend
several thousand dollars to update, we might consider it" response I've
gotten previously.

--

Subject: all axis tick labels with the same digits

From: Carlos Adrian Vargas Aguilera

Date: 30 Jul, 2009 22:17:01

Message: 11 of 11

I'm totaly agree with all of you. I've just submit a function called ADDAXES, which I would like it to work with

a) LOG scale
b) exponential ticks (like in [1 2 3 4] x 10^3)
c) LATEX TickLabels interpreter
d) minor grid ticks

but it is not possible, because there isn't handle for the axes TICKS, the little exponential text, and there is no way to get the minor-ticks (neither in 'linear' or 'log' scale).

Besides, Kelly Kearney is correct a workaround with the ZOOM and PAN functions should be made to update the ticks with the 'ActionPostCallback' functions, which (as far as I have tried) does not work correctly with the

e) Double-click (for zoom out)

Anyway, you can get the ADDAXES function at
http://www.mathworks.com/matlabcentral/fileexchange/24875

Carlos

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
ticklabels bug Carlos Adrian Vargas Aguilera 30 Jul, 2009 18:19:06
tick labels Sprinceana 30 Jul, 2009 12:16:27
tick Sprinceana 30 Jul, 2009 12:16:27
axis Sprinceana 30 Jul, 2009 12:16:27
rssFeed for this Thread

Contact us at files@mathworks.com