Property editor grid lines

9 vues (au cours des 30 derniers jours)
John
John le 16 Jan 2013
Commenté : Tiago Dias le 12 Jan 2018
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

Réponse acceptée

Jan
Jan le 16 Jan 2013
Modifié(e) : Jan le 2 Août 2014
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 commentaires
Pouya Jamali
Pouya Jamali le 15 Juil 2014
any reason Mathworks doesn't provide an option to do this easier?
Tiago Dias
Tiago Dias le 12 Jan 2018
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by