I'm trying to plot some data from a text file, and I would like to be able to cycle the styles of the markers using a custom list. I was able to get the cycle list working, but when I added error bars, problems arose. Originally, my code was as follows:





        legend pos=south east,
        legend entries={Trial 1,
                        Trial 2,
                        Trial 3},
        cycle list name=mylist,
        legend image post style = only marks

        \foreach \yindex in {2,4,6}
        \addplot  table[x index = 0, y index = \yindex] {data.txt};

This produced the following image:

Picture of my working plot without error bars

I then made the following change to be able to add the error columns to my plot, which resulted in a plot that didn't contain any of my marker information, but rather made straight lines between points with no markers.

Picture of my plot with improper formatting

\foreach[evaluate=\yindex as \ynext using int(\yindex+1)] \yindex in {2,4,6}
    \addplot [error bars/.cd,y dir=both,y explicit, x dir = both, x explicit] 
        table[x index = 0, x error index = 1, y index = \yindex, y error index = \ynext]

Any ideas that might have caused this problem and/or how to remedy it? I'd really appreciate it, thanks!

EDIT: Forgot to include the data file being loaded. If it is of interest, it is a simple tab delimited file. Alternating columns (1,3,5,7) correspond to plot values, and (2,4,6,8) correspond to the error bars associated. Columns 1 and 2 are the x axis.

23    0.25    1.75    0.0625    1.625    0.0625    1.75     0.0625
25    0.25    1.75    0.0625    1.75     0.0625    1.875    0.0625
27    0.25    2.125   0.0625    2        0.0625    2.25     0.0625
29    0.25    2.5     0.0625    2.5      0.0625    2.5      0.0625
31    0.25    2.5     0.0625    2.5      0.0625    2.5      0.0625
33    0.25    2.5     0.0625    2.5      0.0625    2.5      0.0625
  • We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation.
    – Adam Liter
    Commented Jan 29, 2014 at 7:26
  • Also, a tip: you can use backticks ` to mark inline code. So "\addplot" can be \addplot.
    – Adam Liter
    Commented Jan 29, 2014 at 7:27

1 Answer 1


I was able to fix this by changing the \addplot command to \addplot+ and by adding the cycle list name parameter in the \addplot+ command. Hope this helps someone else!

Here's the final code in my particular issue:

\foreach[evaluate=\yindex as \ynext using int(\yindex+1)] \yindex in {2,4,6}
    \addplot+ [cycle list name=mylist,error bars/.cd,y dir=both,y explicit,x dir = both, x
        explicit] table[x index = 0, x error index = 1, y index = \yindex, y error index = 
        \ynext] {data.txt};
  • 1
    Please consider accepting your answer, so that your question be removed from the "unanswered" pile.
    – jub0bs
    Commented Apr 9, 2014 at 8:09
  • I had a similar problem and was able to solve it, using only \addplot* (only defining cycle list once in the axis environment).
    – Henning
    Commented Feb 21, 2016 at 13:14

You must log in to answer this question.

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