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 know that you can make a dashed line in pgfplots using the \addplot[dashed] option. However, the line that produces isn't dashed the way I'd like.

I found \pgfsetdash in the documentation for PGF, but I can't figure out how to use it on just one \addplot. If I include it anywhere within the tikzpicture environment, it changes all of the lines, including the axes. I thought that adding a second \pgfsetdash would change the style, but it doesn't seem to have an effect.

Any advice for creating custom dash styles in PGF plots?

share|improve this question

1 Answer 1

up vote 17 down vote accepted

You can use the key dash pattern=<pattern> to define a dash pattern in an \addplot:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}


\begin{tikzpicture}
\begin{axis}
\addplot [dash pattern=on 4pt off 1pt on 4pt off 4pt] {x^2};
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer

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.