How to hide one of the figure plot borders?

I have three subplots in a figure, and I want to overlap portions of them to save space. My question is how do I hide one of the borders of any of the subplots?
Thank you.

Antworten (2)

Kelly Kearney
Kelly Kearney am 30 Jul. 2015

4 Stimmen

More programmatically...
If you don't need any of the axis details, you can just set do
set(gca, 'visible', 'off');
The contents of the axis will still be visible, just not the box, ticks, tick labels, etc. If you want to just get rid of one axis (i.e. just x or just y), you can sort of do it via
col = get(gcf, 'color');
set(gca, 'box', 'off', 'xtick', [], 'xcolor', col, 'color', 'none');
But that works best if your axes and figure have the same background color, since you can't hide a single x/y axis completely, just blend it into the background.

5 Kommentare

Leon
Leon am 30 Jul. 2015
Thank you, but how do I turn off the axis on the top (the one parallel to the x-axis?
Kelly Kearney
Kelly Kearney am 30 Jul. 2015
Setting 'box' to 'off' turns off the upper and right axis lines and ticks. If you want something more complicated than that you might have to play around with layering axes. An example might us answer more precisely.
Leon
Leon am 30 Jul. 2015
Thank you! I only want to turn off the one on the top, not the one to the right. What is layering axes?
By layering, I mean creating two (or more) axes on top of each other to get a combination of properties you can't get with a single axis, similar to the way plotyy works. Useful to have different ticks on left/right or top/bottom, to use multiple colormaps in a plot, etc.
In your case:
ax(1) = axes('position', [0.1 0.1 0.8 0.8], 'box', 'off');
ax(2) = axes('position', [0.1 0.1 0.8 0.8], 'box', 'off', ...
'yaxisloc', 'right', 'color', 'none', 'xtick', []);
You may want to add a
linkaxes(ax)
to make sure the two stay in sync.
Aliyuda Ali
Aliyuda Ali am 15 Mai 2020
Many thanks Kelly Kearney. This code set(gca, 'visible', 'off'); works for me.

Melden Sie sich an, um zu kommentieren.

Sean de Wolski
Sean de Wolski am 30 Jul. 2015

0 Stimmen

Just use plottools to make whatever changes you want (including adjusting the size)
plottools on
Or click the icon on the right hand side of the figure toolbar.

Tags

Gefragt:

am 30 Jul. 2015

Kommentiert:

am 15 Mai 2020

Community Treasure Hunt

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

Start Hunting!

Translated by