# How to plot subplots with zero gaps and x and y labels at the sides?

4 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Nidhi Jain
on 1 Oct 2015

Edited: Nidhi Jain
on 1 Oct 2015

Hi,

One way could be to plot all the histograms using "subplot". You can then remove the X and Y ticks using command:

set(gca,'xtick',[])

set(gca,'ytick',[])

Then click on Tools -> Edit Plot and modify the location of the plot by dragging them. You can also add titles and labels using Insert option. Then generate code from the File option.

If this is not feasible, you can try to modify the location of the subplots manually using "pos" property of subplot.

Suppose, we have a subplot like this:

figure

h1 = subplot(2,2,1)

hist(4)

set(gca,'xtick',[])

set(gca,'ytick',[])

You can now modify the position of the subplot using:

p1 = get(h1, 'pos');

p1(3) = p1(3) + 0.05;

p1(2) = p1(2) - 0.06;

set(h1, 'pos', p1);

This can be done for all the subplots till the gap between each of them reduces.

HTH

##### 4 Comments

Mike Garrity
on 5 Oct 2015

However I want to ask, what is the purpose of 'LooseInset', because without that, I get the same result!

Oops, I should have deleted that. You're right, it's not required.

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!