代码之家  ›  专栏  ›  技术社区  ›  Dims

如何使网格线与刻度线颜色相同

  •  2
  • Dims  · 技术社区  · 8 年前

    请参见下面的示例图,刻度线为黑色,网格线为灰色。

    plot

    我们怎样才能使它们相同?

    这两个都不是 GridColor 帮助的方法:

    %set(gca, 'GridColor', [0 0 0]);
    ax = gca;
    ax.GridColor = [0 0 0];
    
    1 回复  |  直到 8 年前
        1
  •  4
  •   Wolfie Radu Stefan    8 年前

    更改记号的步骤

    请参见 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;