MATLAB: Changing grid lines to a solid line instead of dashed


I have created the figures exactly how I want them however I cannot seem to find a way to change the grid lines from a dashed(default?) to a solid line, which is far more suitable for the application I am using the figure for. Also if it is possible, to change the color of the gridlines?
Thanks for any help in advance,
Mike Scott

Best Answer

  • Set the gridlinestyle property.
    As Matt Tearle has pointed out, you cannot change the grid lines color independent from the axis color. If you really want that, you should use colored lines instead of grids. For example:
    axis([1 10 1 10]);
    xt = get(gca,'xtick');
    xl = get(gca,'xlim');
    yt = get(gca,'ytick');
    yl = get(gca,'ylim');