3

I have the following chart...the below code won't build without the data files, but an image follows

\documentclass{article}

\usepackage{pgfplots}

    \begin{document}
    \begin{figure}
        \centering
        \begin{tikzpicture}
            \begin{axis}[
                    legend columns=4,
                    legend entries={{\tiny Random},{\tiny +Cost},{\tiny +FTE},{\tiny ++Cost},{\tiny ++FTE},{\tiny ++Resources}, {\tiny ++Cost$_{tri}$}, {\tiny ++FTE$_{tri}$}, {\tiny ++Resources$_{tri}$}, {\tiny ++Cost$_{LN}$}, {\tiny ++FTE$_{expo}$}, {\tiny ++Resources$_{expo}$}},
                    legend to name=DollarsLegend,
                    mark repeat=20,
                    xlabel = Simulation Day,
                    ylabel = Dollars Committed,
                    xmin=0,
                    xmax=260,
                    width=0.9\textwidth,
                    y tick label style={
                      /pgf/number format/.cd,
                      fixed,
                      fixed zerofill,
                      precision=0,
                      /tikz/.cd
                    },
                    x tick label style={
                      /pgf/number format/.cd,
                      fixed,
                      fixed zerofill,
                      precision=0,
                     /tikz/.cd
                    },
                    scaled ticks=false,
                    yticklabel={${\$\pgfmathprintnumber{\tick}}$},
                    ]
                \addplot table[line join=round,col sep=comma, y=Random, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize Random}}
                \addplot table[line join=round,col sep=comma, y=PlusCost, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize +Cost}}
                \addplot table[line join=round,col sep=comma, y=PlusFTE, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize +FTE}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusCost, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusFTE, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusResources, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusCostTri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost$_{tri}$}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusFTETri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE$_{tri}$}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusResourcesTri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources$_{tri}$}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusCostLN, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost$_{LN}$}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusFTEExpo, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE$_{expo}$}}
                \addplot table[line join=round,col sep=comma, y=PlusPlusResourcesExpo, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources$_{expo}$}}
            \end{axis}
        \end{tikzpicture}
            \ref{DollarsLegend}
        \caption{Dollar Commitment versus Time}
        \label{DollarCommitment}
    \end{figure}

    \end{document}

Here's the resulting chart

screen capture1

I need to prepare this for black and white publication, so I need to make sure every series has a marker that is distinguishable without color. But when I modify my \addplot lines to look like this, for example

\addplot table[line join=round,col sep=comma, y=Random, x=Day, mark=triangle]{DollarCommitment.csv};

I get the same chart....as if my mark specification is ignored. What am I doing wrong?

3

You have to add mark= (and line join=round, too, it is exercise for you) to \addplot options not to table options.

\addplot+[black,line join=round,mark=Mercedes star] table[line join=round,col sep=comma, y=PlusPlusFTEExpo, x=Day]{DollarCommitment.csv};

As an alternative, you can also use a cycle list (instead of typing all those marks). There are many built-in ones mentioned in the manual, but you can build your own (see the manual), for example:

cycle list name=black white,

Code:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

    \begin{document}
    \begin{figure}
        \centering
        \begin{tikzpicture}
            \begin{axis}[
                    legend columns=4,
                    %legend entries={{\tiny Random},{\tiny +Cost},{\tiny +FTE},{\tiny ++Cost},{\tiny ++FTE},{\tiny ++Resources}, {\tiny ++Cost$_{tri}$}, {\tiny ++FTE$_{tri}$}, {\tiny ++Resources$_{tri}$}, {\tiny ++Cost$_{LN}$}, {\tiny ++FTE$_{expo}$}, {\tiny ++Resources$_{expo}$}},
                    legend to name=DollarsLegend,
                    %mark repeat=20,    %% uncomment in your data
                    xlabel = Simulation Day,
                    ylabel = Dollars Committed,
                    xmin=0,
                    xmax=260,
                    width=0.9\textwidth,
                    y tick label style={
                      /pgf/number format/.cd,
                      fixed,
                      fixed zerofill,
                      precision=0,
                      /tikz/.cd
                    },
                    x tick label style={
                      /pgf/number format/.cd,
                      fixed,
                      fixed zerofill,
                      precision=0,
                     /tikz/.cd
                    },
                    scaled ticks=false,
                    yticklabel={${\$\pgfmathprintnumber{\tick}}$},
                    %cycle list name=black white,
                    %every mark/.append style={fill=gray!10}
                    ]
                \addplot+[black,mark=o] table[line join=round,col sep=comma, y=Random, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize Random}}
                \addplot+[black,mark=x] table[line join=round,col sep=comma, y=PlusCost, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize +Cost}}
                \addplot+[black,mark=|] table[line join=round,col sep=comma, y=PlusFTE, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize +FTE}}
                \addplot+[black,mark=square] table[line join=round,col sep=comma, y=PlusPlusCost, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost}}
                \addplot+[black,mark=star] table[line join=round,col sep=comma, y=PlusPlusFTE, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE}}
                \addplot+[black,mark=10-pointed star] table[line join=round,col sep=comma, y=PlusPlusResources, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources}}
                \addplot+[black,mark=otimes] table[line join=round,col sep=comma, y=PlusPlusCostTri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost$_{tri}$}}
                \addplot+[black,mark=oplus] table[line join=round,col sep=comma, y=PlusPlusFTETri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE$_{tri}$}}
                \addplot+[black,mark=triangle] table[line join=round,col sep=comma, y=PlusPlusResourcesTri, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources$_{tri}$}}
                \addplot+[black,mark=diamond] table[line join=round,col sep=comma, y=PlusPlusCostLN, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Cost$_{LN}$}}
                \addplot+[black,mark=Mercedes star] table[line join=round,col sep=comma, y=PlusPlusFTEExpo, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++FTE$_{expo}$}}
                \addplot+[black,mark=pentagon] table[line join=round,col sep=comma, y=PlusPlusResourcesExpo, x=Day]{DollarCommitment.csv};
                \addlegendentry{{\scriptsize ++Resources$_{expo}$}}
            \end{axis}
        \end{tikzpicture}
            \ref{DollarsLegend}
        \caption{Dollar Commitment versus Time}
        \label{DollarCommitment}
    \end{figure}

    \end{document}

enter image description here

  • Thanks so much! This is the first paper I've written using pgfplots, so I'm slowly climbing the learning curve. Vastly prefer this to importing picture files though.... – jerH Apr 9 '15 at 0:37
  • @user1922959 You really did a good job by choosing a proper method for plotting and choosing a proper tool for it. All the best. You are in good company here. :-) – user11232 Apr 9 '15 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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