Clear Filters
Clear Filters

address a subplot without using the subplot command

3 views (last 30 days)
Hi All, I'm looking for an alternative way of addressing a subplot without using the subplot command. I have a figure with 40 panels that I create in Matlab 2014a/Linux. When I open it in Matlab 2017a/OSX, the axes change color from black to gray (bug #1). To change them back, I tried the obvious:
for i=1:40
subplot(4,10,i)
set(gca,'Xcolor',[0 0 0],'Ycolor',[0 0 0])
end
Unfortunately, every time the loop executes "subplot(4,10,i)" it deletes the contents of the panel (bug #2). So, I'm trying to figure out how to switch between panels without using "subplot" or alternatively how to get the list of axis handles for all the panels. Any help would be much appreciated!

Accepted Answer

Jan
Jan on 4 Oct 2017
Edited: Jan on 4 Oct 2017
AxesHList = findobj(FigureH, 'Type', 'axes');
set(AxesHList, 'Xcolor', [0 0 0], 'Ycolor', [0 0 0]);
The behavior of subplot is not a "bug", but intended.
I set the color of the axes to black in my startup.m file:
% Get handle of the graphics root object:
if ([100, 1] * sscanf(version, '%d.', 2) >= 804) % HG2 graphics:
RootH = groot;
else % HG1 graphics:
RootH = 0;
end
set(RootH, 'defaultAxesXColor', [0,0,0], ...
'defaultAxesYColor', [0,0,0], ...
'defaultAxesZColor', [0,0,0]);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!