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 somewhat baffled by my apparent inability to choose a mix of colors in pgfplots. Here's a MWE:

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}[scale=1.0]

\begin{axis}[enlargelimits=false,
    xtick={-3.141,0,3.141},
    xticklabels={$-\pi$,$0$,$\pi$}]
  \addplot[color=red!0.4!black,domain=-pi:pi] {sin(deg(x))};
\end{axis}

\end{tikzpicture}
\end{document} 

I would have expected a color in between red and black, but I get just black. If I choose the color as color=black!0.4!red it turns out to be red. What am I doing wrong?

share|improve this question

2 Answers 2

You need to use percentages rather than fractions. red!40!black works.

I had to remove the \pgfplotsset{compat=1.4} line from your source code because it prevented compilation. Nevertheless, the following code produces a mixture of black and red. Apparently red!0.4!black gives you 0.4% red and 99.6% black (assuming decimal inputs are accepted). Otherwise, it would round to 0% and 100%.

enter image description here

\documentclass[10pt]{article}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.4}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}[scale=1.0]

\begin{axis}[enlargelimits=false,
    xtick={-3.141,0,3.141},
    xticklabels={$-\pi$,$0$,$\pi$}]
  \addplot[color=red!40!black,domain=-pi:pi] {sin(deg(x))};
\end{axis}

\end{tikzpicture}
\end{document}
share|improve this answer
    
You might want to update your packages as I can compile with or without \pgfplotsset{compat=1.4} commented, so wondering if you have a really old version of the packages. –  Peter Grill Feb 17 '12 at 0:54
    
Thanks, Peter. I presumed that was the case. My texlive distribution is certainly out of date because I'm running the version from the debian testing repositories, which I believe is TexLive 2009. I have avoided updating because packages outside the repositories associated with a given version of debian often times cause problems. –  user001 Feb 17 '12 at 0:57

You have to provide the mix in percent. You meant Red 40% on Black, that's color=red!40!black

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.