-
Notifications
You must be signed in to change notification settings - Fork 320
In this page, some frequently asked questions are handled. Please feel free to add content to this page when you run into problems that other people may face as well.
Please also have a look at our Common Problems page.
If you have data plots of a lot of crowded dots, you may find the size of the dots matlab2tikz uses too big, as in here. In order to that to look like this, Use e.g:
h = plot(1:10,'b-o')
m2tcustom(h, 'extraOptions', 'mark size=0.4pt')
matlab2tikz(...)
m2tcustom
can be further used to add special tikz options. You can read more about it in the source code here. This FAQ was added after #1084.
The numbers are formatted using the features provided by pgf/TikZ (as implemented by Christian Feuersänger, the author of pgfplots). In chapter 92 "Number Printing" of the pgf/TikZ manual, the relevant keys are explained in detail.
E.g. if you prefer numbers formatted as "1 234.56", you can just add
\pgfset{number format/1000 sep={\,}}
to your LaTeX document.
If you are passing custom TikZ code to matlab2tikz, please make sure that code is valid. Otherwise, your pgfplots version is likely outdated. It is recommended that you update your LaTeX installation, e.g. with TeXLive manager (tlmgr) or download the latest version of your LaTeX distribution (e.g. MikTeX, MacTeX or TeXLive).
TODO: explain using TEXINPUTS with TDS package
If you compile the following document with LaTeX, the PDF output will show what versions you are using.
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
TikZ: \expandafter\csname ver@tikz.sty\endcsname \\
pgfplots: \expandafter\csname ver@pgfplots.sty\endcsname \\
\end{document}
You can use subplot2plot to place all your subplots in different figure windows which you can export as normal using matlab2tikz
% Depends on: http://www.mathworks.com/matlabcentral/fileexchange/31136-subplot2plot
figs = subplot2plot(gcf);
for iFigure = 1:numel(figs)
matlab2tikz(sprintf('file%d.tikz', iFigure), 'figurehandle', figs{iFigure}, ...);
end
If you export an intraday time-series plot to TikZ, you cannot compile the figure and you get latex error
Dimension too large. \end{axis}
This problem arises if you used Matlab intraday dates like 736470.73 in your plots. The following example reproduces the issue
dt = linspace(now(),now()+0.1,100);
y = cumsum(randn(1,100));
plot(dt,y)
datetick
A workaround is to map the dates into integers and use manual xticks
% Re-map dates and re-plot
[~,~,x] = unique(dt);
plot(x,y)
% Choose number of ticks and format of labels
numticks = 7;
fmt = 'hh:MM';
% Set manually
ticks = linspace(dt(1),dt(end),numticks);
labels = datestr(linspace(min(dt),max(dt),numticks), fmt);
set(gca, 'xtick',ticks, 'XTickLabel',labels)
If you have multiple time series of different lengths, first create a union of all the timestamps, then map each series into that vector
% Sample data with two time-series
dta = linspace(now(),now()+0.1,100);
dtb = linspace(now()+0.07,now()+0.09,10);
a = cumsum(randn(100,1));
b = cumsum(randn(10,1));
% Map to unique time-vector
dt = union(dta,dtb);
[~,posa] = ismember(dta,dt);
[~,posb] = ismember(dtb,dt);
plot(posa',a, posb',b)
After the plot, set ticks and labels as in the previous example.