How to hide one of the figure plot borders?
Ältere Kommentare anzeigen
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
am 30 Jul. 2015
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
am 30 Jul. 2015
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
am 30 Jul. 2015
Kelly Kearney
am 31 Jul. 2015
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
am 15 Mai 2020
Many thanks Kelly Kearney. This code set(gca, 'visible', 'off'); works for me.
Sean de Wolski
am 30 Jul. 2015
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.
Kategorien
Mehr zu Grid Lines, Tick Values, and Labels finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!