MATLAB: Add y grid only to plot

gcagridplot

I would like to add solid y grid lines to my plot according to the y tick in gca.
so I tried:
ax = gca;
ax.YGrid = 'on';
ax.GridLineStyle = '-';
However, this did not work and there is no grid at all in my plot, please help.

Best Answer

Hello,
I did something like this in my current project : I create my own lines to simulate grid like I want (and set the HitTest property to off to not take care of these lines with matlab cursor for example) through multiple plots. It is not very elegant but it is working very well and permit you to change as you want the position of the grid.