Quantcast
Channel: MATLAB Central Newsreader - tag:"figure"
Viewing all articles
Browse latest Browse all 117

Tick marks of the same length across all subplots

$
0
0
Dear all,

I am creating a multi-panel figure (i.e. with multiple axes of different size). Now I would like all tick marks to have the same absolute size across all subplots.

According to the MATLAB user guide, the 'TickLength' property of an axis is normalized with respect to the longest visible axis. In order to make all ticks of the same length, I am running the following code:

fixlen = 0.005; % Desired target length
for i = 1:Naxes
    rect = get(h(i),'Position'); % Get the axis position, h is an array of axis handles
    width = rect(3); % Axis width
    height = rect(4); % Axis height
    
    axislen = max([height,width]); % Get longest axis
    ticklen = fixlen/axislen; % Fixed length
    set(h(g),'TickDir','out','TickLength',ticklen*[1 1]);
end

Unfortunately, the above code does not produce a figure in which all tick lengths are equal. Perhaps I am missing something?

Thanks

Viewing all articles
Browse latest Browse all 117

Trending Articles