参见下面的示例图,刻度线为黑色,而网格线为灰色。
我们怎样才能使它们一样?
这些GridColor
方法都没有帮助:
%set(gca, 'GridColor', [0 0 0]);
ax = gca;
ax.GridColor = [0 0 0];
答案 0 :(得分:4)
更改刻度线
请参阅NumericRuler properties。简而言之:
ax = gca;
ax.XAxis.Color = [.8,.8,.8]; % grey as RGB triplet
ax.YAxis.Color = 'blue'; % blue as option keyword
更改网格线
您使用ax.GridColor
是对的,但默认情况下您有一个半透明网格,因此还需要设置ax.GridAlpha
。
ax = gca;
ax.GridColor = [0 0 0]; % Black as RGB, this is [0.15 0.15 0.15] by default (dark grey)
ax.GridAlpha = 1; % Opaque, this is 0.15 by default (85% transparent)
使它们相同
ax = gca;
% Set the grid to be opaque
ax.GridAlpha = 1;
% Set them to be the same colour
myColour = [0.4, 0.7, 1]; % Any RGB triplet etc.
ax.GridColor = myColour;
ax.XAxis.Color = myColour;
ax.YAxis.Color = myColour;