Add y grid only to plot
조회 수: 350 (최근 30일)
이전 댓글 표시
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.
댓글 수: 13
dpb
2016년 7월 14일
"gca.YGrid='on';is not valid syntax to do this."
I debated about that; not having HG2 wasn't able to check; I (unfortunately) let the previous posting influence in making an unwarranted assumption so left it instead of using the old set notation trying to "get with it" for the new stuff... :(
At least finally uncovered the issue; as I suspected it wasn't profound.
채택된 답변
Mathieu
2016년 7월 13일
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.
추가 답변 (1개)
Valerii Abramenko
2019년 7월 23일
Hello,
If someone else needs the grid for only one axis, the answer is here (set(gca, 'YGrid', 'on', 'XGrid', 'off')):
참고 항목
카테고리
Help Center 및 File Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!