Property editor grid lines

조회 수: 10 (최근 30일)
John
John 2013년 1월 16일
댓글: Tiago Dias 2018년 1월 12일
Hello,
Can you make the grid line in a plot thicker in the property editor? I want to make mine more visible but cannot figure how.
Thanks

채택된 답변

Jan
Jan 2013년 1월 16일
편집: Jan 2014년 8월 2일
No, this does not work from the property editor.
But you can draw lines manually also:
% Create a test diagram:
AxesH = axes;
x = linspace(0, 2*pi, 100); % Test data
plot(x, sin(x));
% The modifications start here:
GridStyle.Color = [0.2, 0.4, 0.1];
GridStyle.LineStyle = '-';
GridStyle.LineWidth = 2.5;
GridStyle.HitTest = 'off';
Child = get(AxesH, 'Children');
XTick = get(AxesH, 'XTick');
YTick = get(AxesH, 'YTick');
XLimit = get(AxesH, 'XLim');
YLimit = get(AxesH, 'YLim');
newGrid = cat(1, ...
line([XTick; XTick], YLimit, 'Parent', AxesH, GridStyle), ...
line(XLimit, [YTick; YTick], 'Parent', AxesH, GridStyle));
% New grid on top or bottom of other objects:
set(AxesH, 'Child', [newGrid; Child(:)]);
% Or: set(AxesH, 'Child', [Child(:); newGrid]);
% Disable original dashed grid:
set(AxesH, ...
'XGrid', 'off', ...
'YGrid', 'off', ...
'YTickMode', 'manual', ...
'TickLength', zeros(1, 2));
  댓글 수: 2
Pouya Jamali
Pouya Jamali 2014년 7월 15일
any reason Mathworks doesn't provide an option to do this easier?
Tiago Dias
Tiago Dias 2018년 1월 12일
hello, thanks for your reply, but the code doesn't work 100% for me, I have vertical lines in the grid, that aren't displayed.
Any idea why? my X is datatime, for Apr 2016 no vertical line, for Jul2016 a vertical line appears, for Oct 2016 no line, for jan 2017 i have a line and so on.
This only appears when i maximize the window of the .fig file

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by