2

The following output under tikz/pgfplots 3.0 is desired:

enter image description here

I would further like:

(i) Text (instead of the gradients) at the end of the arrow-tips (sufficient room for writing +/- 10-15 characters per arrow tip) (ii) Every quadrant to have its own color, that fades into the adjecant quadrants. How to achieve this?

  • MWE partially based on p.200 tikz manual `\documentclass{book} \usepackage{pgfplots} \usepackage{tiki} \uselibrary{arrows.meta} \begin{document} \pagestyle{empty} \tikz[very thick] \draw [-Stealth[] . Stealth[] Stealth[]}] (0,0) -- (2,0); \end{document} – Lingskiwitz Oct 27 '14 at 20:58
4

Do you like to have something like this?

\documentclass[tikz,border=3mm] {standalone}
    \usetikzlibrary{arrows,fadings,positioning}
    \usepackage{siunitx}
\begin{document}
    \begin{tikzpicture}[
    > = angle 45,
       node distance = 0mm,
mynode/.style n args = {3}{name=n#1,
                           fading angle=#2,
                           fill=#3,
                           scope fading=south, minimum size=33mm, text opacity=1}
                        ]
\node[mynode={1}{45}{red}]                  {indeterminate axis};
\node[mynode={2}{315}{teal},right=of n1]    {left  axis deviation};
\node[mynode={3}{135}{cyan}, below=of n1]   {right axis deviation};
\node[mynode={4}{225}{orange},right=of n3]  {normal axis};
\draw[<->]  (n1.south west) node[left]      {+\SI{180}{\degree}} -- 
            (n2.south east) node[right]     { \SI{0}{\degree}};
\draw[<->]  (n3.south east) node[below]     {+\SI{90}{\degree}} --
            (n1.north east) node[above]     {-\SI{90}{\degree}};
    \end{tikzpicture}
\end{document}

enter image description here

edit: After sending my answer I discover that text opacity doesn't has any effect. If you like to have not faded text in quadrants, than you need to wrote them separately, something like this:

mynode/.style n args = {3}{name=n#1,
                           fading angle=#2,
                           fill=#3,
                           scope fading=south, minimum size=33mm,
                           node contents={}}
                        ]
\node[mynode={1}{45}{red}];
\node[mynode={2}{315}{teal},right=of n1];
\node[mynode={3}{135}{cyan},below=of n1];
\node[mynode={4}{225}{orange},right=of n3];
    \node[at=(n1.center)]   {indeterminate axis};
    \node[at=(n2.center)]   {left  axis deviation};
    \node[at=(n3.center)]   {right axis deviation};
    \node[at=(n4.center)]   {normal axis};

Also the axes have better look if they are thicker as suggest 'Enthusiastic Student', tor example:

\draw[thick,<->]  (n1.south west) node[left]      {+\SI{180}{\degree}} --
            (n2.south east) node[right]     { \SI{0}{\degree}};
\draw[thick,<->]  (n3.south east) node[below]     {+\SI{90}{\degree}} --
            (n1.north east) node[above]     {-\SI{90}{\degree}};
  • Very nice colouring. I think making the axis's thicker will make the plot more beautiful... – Enthusiastic Engineer Oct 27 '14 at 21:49
  • Whoohoo!! +1! Excellent work. – Lingskiwitz Oct 27 '14 at 21:59
4

For merging the colors from each quadrant you could try the bilinear interpolation shading although this does not render very well with some PDF viewers:

\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}[>=stealth, x=2.5cm, y=2.5cm]    
\path [shading=bilinear interpolation,
  upper left=red,  upper right=green, 
  lower left=blue, lower right=cyan] (-1,-1) rectangle (1,1);
\draw [<->] (-1,0) -- (1,0);
\draw [<->] (0,-1) -- (0,1);
\foreach \text [count=\i] in {-90,+180,+90,0}
  \node [anchor=\i*90+180] at (\i*90:1) {$\text^\circ$};
\foreach \text [count=\i from 0] in {Indeterminate\\axis,Right axis\\deviation,Normal axis,Left axis\\deviation}
  \node [align=center,font=\footnotesize] at (\i*90+135:.75) {\text};
\end{tikzpicture}

\end{document}

enter image description here

And here is an attempt to get the white "hole" in the middle. I guess this could be done with a fading or something, but I went with a custom postscript shading. I'm not sure the postscript code is quite robust though.

Also the shading has to be stated after the keys for setting the corner colors as these automatically set the shading to bilinear interpolation.

\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{shadings}
\pgfdeclarefunctionalshading[lower left,lower right,upper left,upper right]{bilinear interpolation with white center}
{\pgfpointorigin}
{\pgfpoint{100bp}{100bp}}
{
  \pgfshadecolortorgb{lower left}{\colll}\pgfshadecolortorgb{lower right}{\collr}
  \pgfshadecolortorgb{upper right}{\colur}\pgfshadecolortorgb{upper left}{\colul}
}{
 2 copy
  25 sub 50 div exch 25 sub 50 div 2 copy            
  neg 1 add exch neg 1 add                   
  3 1 roll 2 copy exch 5 2 roll 6 copy 6 copy  
  \colllred mul exch \collrred mul add mul   
  4 1 roll
  \colurred mul exch \colulred mul add mul
  add
  13 1 roll
  \colllgreen mul exch \collrgreen mul add mul   
  4 1 roll
  \colurgreen mul exch \colulgreen mul add mul
  add
  7 1 roll
  \colllblue mul exch \collrblue mul add mul  
  4 1 roll
  \colurblue mul exch \colulblue mul add mul
  add
  5 3 roll
  50 sub 100 div exch 50 sub 100 div  
  dup mul exch dup mul add sqrt 2 sqrt div 5 mul 
  dup neg 1 add exch 2 copy 2 copy 
  9 -1 roll mul add 3 1 roll 7 -1 roll mul add 4 2 roll 5 -1 roll mul add
}

\begin{document}
\begin{tikzpicture}[>=stealth, x=2.5cm, y=2.5cm]    
\path [upper left=red,  upper right=green, 
  lower left=blue, lower right=cyan,
  shading=bilinear interpolation with white center] (-1,-1) rectangle (1,1);

\draw [<->] (-1,0) -- (1,0);
\draw [<->] (0,-1) -- (0,1);
\foreach \text [count=\i] in {-90,+180,+90,0}
  \node [anchor=\i*90+180] at (\i*90:1) {$\text^\circ$};
\foreach \text [count=\i from 0] in {Indeterminate\\axis,Right axis\\deviation,Normal axis,Left axis\\deviation}
  \node [align=center,font=\footnotesize] at (\i*90+135:.75) {\text};
\end{tikzpicture}

\end{document}

enter image description here

And finally, here is a version that allows the center color to be specified:

\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{shadings}
\pgfdeclarefunctionalshading[lower left,lower right,upper left,upper right,center]{bilinear interpolation with center}
{\pgfpointorigin}
{\pgfpoint{100bp}{100bp}}
{
  \pgfshadecolortorgb{lower left}{\colll}\pgfshadecolortorgb{lower right}{\collr}
  \pgfshadecolortorgb{upper right}{\colur}\pgfshadecolortorgb{upper left}{\colul}
  \pgfshadecolortorgb{center}{\colcn}
}{
  2 copy
  % Following is the same as bilinear shading code
  25 sub 50 div exch 25 sub 50 div 2 copy            
  neg 1 add exch neg 1 add                   
  3 1 roll 2 copy exch 5 2 roll 6 copy 6 copy  
  \colllred mul exch \collrred mul add mul   
  4 1 roll
  \colurred mul exch \colulred mul add mul
  add
  13 1 roll
  \colllgreen mul exch \collrgreen mul add mul   
  4 1 roll
  \colurgreen mul exch \colulgreen mul add mul
  add
  7 1 roll
  \colllblue mul exch \collrblue mul add mul  
  4 1 roll
  \colurblue mul exch \colulblue mul add mul
  add
  % Now do the centre...
  5 3 roll
  50 sub 50 div exch 50 sub 50 div  
  dup mul exch dup mul add sqrt 2 mul 
  dup neg 1 add exch 2 copy 2 copy 
  9 -1 roll mul exch \colcnred mul add 
  3  1 roll 
  7 -1 roll mul exch \colcngreen mul add 
  4  2 roll 
  5 -1 roll mul exch \colcnblue mul add
}

\colorlet{center}{white}
\tikzset{center/.code=\colorlet{center}{#1}}
\begin{document}
\begin{tikzpicture}[>=stealth, x=2.5cm, y=2.5cm]
\foreach \c [count=\i from 0] in {black, white, purple, orange}{   
\path [upper left=red,  upper right=green, 
  lower left=blue, lower right=cyan, center=\c,
  shading=bilinear interpolation with center] ({mod(\i,2)*2.5},{int(\i/2)*2.5}) rectangle ++(2,2);
}
\end{tikzpicture}

\end{document}

enter image description here

  • Hi Mark, I like this. Is it also possible to merge your code (keeping the text-break functionality of your example) with the [shading=bilinear interpolation, together with the answer from Zarko. I then have the shadow in the middle of the figure, as well as the blend of the four colors. – Lingskiwitz Oct 28 '14 at 10:38
  • Compliments! The additions are certainly useful. NB In my case I use text at node ends instead of gradients (see i). – Lingskiwitz Oct 28 '14 at 18:30

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.