Axis appearance: avoid tick mark labels to overlap

  • Follow


Hi guys,

do you pls know a way to improve the axis appearance in the event tick mark labels overlap? I set the limits to axis by axis([xmin,xmax,ymin,ymax]) and would like to restrict the number of ticks to just two or three. The resulting graphs (subplots) should have rather large labels relative to the plot area (font size) and scarce in number.

Trying out set(gca,'XTick', min : increment : max) resulted in a desired number of ticks, however, instead of displaying 2 digits after the decimal point, each mark label now ended up with 4, which looks even much worse. I am looking for a way to adjust the code so as I don't need to "correct" each graph manually. Thanks for ideas!
0
Reply sscnekro 5/30/2010 6:22:05 PM

sscnekro wrote:
....

> do you pls know a way to improve the axis appearance in the event tick 
> mark labels overlap? I set the limits to axis by 
> axis([xmin,xmax,ymin,ymax]) and would like to restrict the number of 
> ticks to just two or three. The resulting graphs (subplots) should have 
> rather large labels relative to the plot area (font size) and scarce in 
> number.
> 
> Trying out set(gca,'XTick', min : increment : max) resulted in a desired 
> number of ticks, however, instead of displaying 2 digits after the 
> decimal point, each mark label now ended up with 4, which looks even 
> much worse. I am looking for a way to adjust the code so as I don't need 
> to "correct" each graph manually. Thanks for ideas!

You can label them however you wish using the 'X|Y|ZTickLabel' property.

--
0
Reply dpb 5/30/2010 6:23:17 PM


Re: dpb [> You can label them however you wish using the 'X|Y|ZTickLabel' property. ]

Thanks, dpb, for the reference. Yes, I was thinking about using this set(gca,'XTickLabel',{ }) together with the set(gca, 'XTick', ...) in the code, however, it is not obvious to me how to make the code to come up with well-behaved ticks. Should I do it for each graph case-to-case, that would be no problem. But I would like to create a large set of good looking graphs (subplots) just by running the code.

I also checked out the possibility to round numbers, but I only found the possibility to round to nearest integer or zero, thus no control over no. of digits. More ideas? Thanks.
0
Reply sscnekro 5/30/2010 6:39:07 PM

sscnekro wrote:
> Re: dpb [> You can label them however you wish using the 
> 'X|Y|ZTickLabel' property. ]
> 
> Thanks, dpb, for the reference. Yes, I was thinking about using this 
> set(gca,'XTickLabel',{ }) together with the set(gca, 'XTick', ...) in 
> the code, however, it is not obvious to me how to make the code to come 
> up with well-behaved ticks. Should I do it for each graph case-to-case, 
> that would be no problem. But I would like to create a large set of good 
> looking graphs (subplots) just by running the code.

That's a problem that's been addressed quite a lot -- algorithms to 
select "pretty" axis ranges.  I don't have a particular one at hand in 
Matlab code, I suspect one could look at the plot() routine m-file and 
get a feel for what they do in it and salt to suit.  There may be code 
on the file exchange (I know there are several other plotting tools 
there; you might also see if some of them have a more pleasing view to 
your eye) as well.  And, of course, there's always the resort of 
searching for code snippets online...

> I also checked out the possibility to round numbers, but I only found 
> the possibility to round to nearest integer or zero, thus no control 
> over no. of digits. More ideas? Thanks.

doc num2str() % note the optional argument

You can also use

sprintf() to write any format you choose as well...

--
0
Reply dpb 5/30/2010 6:56:34 PM

Re: dpb [> You can also use sprintf() to write any format you choose as well... ]

For now, for my purpose suffices to use
axis([xmin,xmax,ymin,ymax])
set(gca,'XTick', xmin : increment : xmax)
set(gca,'XTickLabel',{sprintf('%.2f', xmin), ... })

A big thank you!
0
Reply sscnekro 5/30/2010 8:23:05 PM

4 Replies
789 Views

(page loaded in 0.111 seconds)

Similiar Articles:













7/20/2012 10:26:58 PM


Reply: