1

I'm using matlab2tikz for a plot with horizontal error bars, but the pgfplots file generated doesn't include the error bars, while everything else is fine. I'm plotting my data in matlab like this:

y = [604.40,599.84,602.23,616.96,582.62,575.40,570.14,572.77,574.53];
x =  [4.05  ,4.05  ,4.05  ,4.05  ,4.20  ,4.37  ,4.55  ,4.55  ,4.37  ];
ebars =  [0.0563,0.0563,0.0326,0.0326,0.0350,0.0254,0.0437,0.0437,0.0254];
figure(1)
clf
errorbar(x,y,2*ebars,'horizontal','o')
legend('s1');

Which gives me this:

Original matlab plot

When I then run matlab2tikz, the resulting file is:

\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
%
\begin{tikzpicture}
\begin{axis}[%
width=3.358in,
height=2.309in,
at={(0.563in,0.312in)},
scale only axis,
xmin=3.8,
xmax=4.8,
ymin=570,
ymax=620,
axis background/.style={fill=white},
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=mycolor1, draw=none, mark=o, mark options={solid, mycolor1}]
  table[row sep=crcr]{%
4.05    604.4\\
4.05    599.84\\
4.05    602.23\\
4.05    616.96\\
4.2 582.62\\
4.37    575.4\\
4.55    570.14\\
4.55    572.77\\
4.37    574.53\\
};
\addlegendentry{s1}
\end{axis}
\end{tikzpicture}%

Which gives me this: pgfplots plot

What might be stopping my error bars carrying over?

1 Answer 1

1

Support for horizontal error bars was added to Matlab in version 2016b as I understand it (based on https://se.mathworks.com/matlabcentral/answers/99308-how-can-i-create-horizontal-error-bars-in-matlab?). But looking at the matlab2tikz code, it appears there is only support for vertical error bars.

I don't have Matlab 2016b or newer here, but in 2015b it works as expected with vertical errorbars.

Hence, what's stopping the error bars is likely that they're not implemented in matlab2tikz. Post a feature request at https://github.com/matlab2tikz/matlab2tikz/issues


Addendum: JMJ reported this at https://github.com/matlab2tikz/matlab2tikz/issues/1016

1
  • Thanks, I've posted a feature request, will update if there's anything helpful
    – JMJ
    Oct 12, 2017 at 18:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .