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