Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\documentclass[11pt]{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=1.8}

\pgfplotscreateplotcyclelist{mylist}{%
{black,mark=square,draw=none},
{black,mark=o,draw=none},
{black,mark=triangle,draw=none},
{black,mark=diamond,draw=none}}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
        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};
    \end{axis}
    \end{tikzpicture}
\end{document}

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]
        {data.txt};

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
share|improve this question
    
Welcome to TeX.SX! –  Adam Liter Jan 29 at 7:06
    
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 Jan 29 at 7:26
    
Also, a tip: you can use backticks ` to mark inline code. So "\addplot" can be \addplot. –  Adam Liter Jan 29 at 7:27

1 Answer 1

up vote 3 down vote accepted

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};
share|improve this answer
1  
Please consider accepting your answer, so that your question be removed from the "unanswered" pile. –  Jubobs Apr 9 at 8:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.