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?


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


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


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.