matlab2tikz / matlab2tikz

This program converts MATLAB®/Octave figures to TikZ/pgfplots figures for smooth integration into LaTeX.
http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
BSD 2-Clause "Simplified" License
1.53k stars 316 forks source link

minor grid style #1134

Open andrevidalsoares opened 7 months ago

andrevidalsoares commented 7 months ago

The minor grid style default in pgfplots is solid line, not dotted as the default in MATLAB, so this change would make it

I changed lines 1007-1011 from this: [minorGridLS, isDefault] = getAndCheckDefault(... 'axes', handle, 'MinorGridLineStyle', ':'); if ~isDefault || m2t.args.strict minorGridOpts = opts_add(minorGridOpts, translateLineStyle(minorGridLS)); end To this: [minorGridLS, ~] = getAndCheckDefault(... 'axes', handle, 'MinorGridLineStyle', ':'); %If statement removed because dotted style is not default in pgfplots minorGridOpts = opts_add(minorGridOpts, translateLineStyle(minorGridLS));

Also, to actually draw the minor grid lines we need to set minor tick num. Usually MATLAB draws three lines between major ticks. My workaround was to create minor ticks without the minor tick labels by adding this after line 1006: matlabDefaultNumMinorTicks = 3; minorGridOpts = opts_add(minorGridOpts, 'minor tick num', num2str(matlabDefaultNumMinorTicks)); minorGridOpts = opts_add(minorGridOpts, 'minor tick style', '{draw=none}'); Of course this will conflict whenever you actually have minor tick labels, specially with the {draw=none} option. Hopefully you guys can come up with something smarter for this problem.

Thanks, Andre