diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex | 202 |
1 files changed, 197 insertions, 5 deletions
diff --git a/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex b/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex index 88c43ec9e10..4f0ede49b5b 100644 --- a/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex +++ b/Master/texmf-dist/doc/generic/pstricks-add/pstricks-add-doc.tex @@ -1,4 +1,4 @@ -%% $Id: pstricks-add-doc.tex 445 2011-01-18 18:43:16Z herbert $ +%% $Id: pstricks-add-doc.tex 454 2011-01-29 15:42:34Z herbert $ \documentclass[11pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,smallheadings headexclude,footexclude,oneside]{pst-doc} \listfiles @@ -3362,7 +3362,7 @@ as starting values for another equation. %-------------------------------------------------------------------------------------- \clearpage -\section{\nxLcs{psMatrixPlot}} +\section{\nxLcs{psMatrixPlot}}\label{sec:psMatrix} %-------------------------------------------------------------------------------------- \begin{filecontents}{matrix.data} /dotmatrix [ % @@ -3421,7 +3421,7 @@ is the first plotted line ($y=1$). With the option \end{pspicture}}\quad \psscalebox{0.6}{% \begin{pspicture}(-0.5,-0.75)(11,11) - \psaxes{->}(11,11) + \psaxes[ticksize=-5pt 0]{->}(11,11) \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta,XYoffset=-0.5]% {10}{10}{matrix.data} \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder,XYoffset=-0.5]{10}{10}{matrix.data} @@ -3431,7 +3431,7 @@ is the first plotted line ($y=1$). With the option \begin{lstlisting} \psscalebox{0.6}{% \begin{pspicture}(-0.5,-0.75)(11,11) - \psaxes{->}(11,11) + \psaxes[ticksize=-5pt 0]{->}(11,11) \psMatrixPlot[dotsize=1.1cm,dotstyle=square*,linecolor=magenta]% {10}{10}{matrix.data} \psMatrixPlot[dotsize=.5cm,dotstyle=o,ChangeOrder]{10}{10}{matrix.data} @@ -3447,7 +3447,7 @@ is the first plotted line ($y=1$). With the option \begin{LTXexample}[pos=t,preset=\centering] \begin{pspicture}(-0.5,-0.75)(11,11) - \psaxes{->}(11,11) + \psaxes[ticksize=-5pt 0]{->}(11,11) \psMatrixPlot[dotscale=3,dotstyle=*,linecolor=blue]{10}{8}{matrix.data} \end{pspicture} \end{LTXexample} @@ -3490,6 +3490,187 @@ matrix data, which is saved as /dotmatrix [...] in the file \LFile{pstricks-add- \egroup \clearpage +With the \Lkeyword{colorType}=5 the color setting can be user defined by the +optional argument \Lkeyword{colorTypeDef}. On the stack is the current value +which can be used for the setting but must be left on the stack when everything +is finished. The following example prints the 0 as color white, the value 1 as +black and all other values depending to the corresponding gray value. + +\begin{filecontents*}{matrix1.data} +/dotmatrix [ % <------------ important line +3 0 0 0 0 0 0 0 1 2 +0 0 0 0 0 0 0 1 2 1 +8 0 0 0 0 0 1 2 1 0 +0 0 0 0 0 1 2 1 0 0 +0 0 0 0 1 2 1 0 0 0 +9 0 0 1 2 1 3 0 0 0 +0 0 1 2 1 4 0 0 0 0 +0 1 2 1 5 0 0 0 0 0 +1 2 1 6 0 0 0 0 0 0 +2 1 7 0 0 0 0 0 0 3 +] def % <------------ important line +\end{filecontents*} + +\begin{center} +\psscalebox{0.7}{% +\begin{pspicture}(-0.5,-0.75)(11,11) +\psaxes[ticksize=-5pt 0]{->}(11,11) +\psMatrixPlot[ + colorType=5, + colorTypeDef={ + dup /value exch def % save value and leave one on the stack + value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY + value 0 eq \pslbrace 1 \psrbrace if % + value 1 eq \pslbrace 0 \psrbrace if + setgray + }, + dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{matrix1.data} +\end{pspicture}} +\end{center} + + +\begin{lstlisting} +\begin{filecontents}{matrix1.data} +/dotmatrix [ % <------------ important line +3 0 0 0 0 0 0 0 1 2 +0 0 0 0 0 0 0 1 2 1 +8 0 0 0 0 0 1 2 1 0 +0 0 0 0 0 1 2 1 0 0 +0 0 0 0 1 2 1 0 0 0 +9 0 0 1 2 1 3 0 0 0 +0 0 1 2 1 4 0 0 0 0 +0 1 2 1 5 0 0 0 0 0 +1 2 1 6 0 0 0 0 0 0 +2 1 7 0 0 0 0 0 0 3 +] def % <------------ important line +\end{filecontents} +\psscalebox{0.7}{% +\begin{pspicture}(-0.5,-0.75)(11,11) +\psaxes[ticksize=-5pt 0]{->}(11,11) +\psMatrixPlot[ + colorType=5, + colorTypeDef={ + dup /value exch def % save value and leave one on the stack + value Min sub dMaxMin div neg 1 add 300 mul 400 add \pswavelengthToGRAY + value 0 eq \pslbrace 1 \psrbrace if % + value 1 eq \pslbrace 0 \psrbrace if + setgray + }, + dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{matrix1.data} +\end{pspicture}} +\end{lstlisting} + + +\Lps{if} statements in the color definition must be enclosed with \Lcs{pslbrace} and \Lcs{psrbrace} +when they are parentheses used in PostScript. In the above example the color definition should be +modified when the matrix is a real big one, in such a case a nested \Lps{ifelse} makes more sense: + +\begin{lstlisting} + colorTypeDef={ + dup /value exch def + value 0 eq + \pslbrace 1 setgray \psrbrace + \pslbrace value 1 eq + \pslbrace 0 setgray \psrbrace + \pslbrace Min sub dMaxMin div neg 1 add 300 mul 400 add + \pswavelengthToGRAY setgray \psrbrace ifelse + \psrbrace ifelse + }, +\end{lstlisting} + +Replace the \Lcs{pslbrace} and \Lcs{psrbrace} with \{ and \} if it maybe confusing to read: + +\begin{lstlisting} + dup /value exch def + value 0 eq + { 1 setgray } + { value 1 eq + { 0 setgray } + { Min sub dMaxMin div neg 1 add 300 mul 400 add + \pswavelengthToGRAY setgray } ifelse + } ifelse +\end{lstlisting} + +Another possibility is to define the color procedure onside the data file, where +it \emph{must} be named \Lps{colorTypeDef}. If such a definition exists, the one from +the optional argument \Lkeyword{colorTypeDef} will be ignored. There can be no +\TeX-specific code inside this definition because it is read on PostScript level, +the reason why \Lcs{pswavelengthToGRAY} cannot be used. + +\begin{center} +\begin{filecontents}{matrix1.data} +/colorTypeDef { + dup /value exch def + value 0 eq + { 1 setgray } + { value 1 eq + { 0 setgray } + { Min sub dMaxMin div neg 1 add 300 mul 400 add +% \pswavelengthToGRAY not possible + tx@addDict begin wavelengthToRGB Red Green Blue end + setrgbcolor + } ifelse + } ifelse +} def +/dotmatrix [ % <------------ important line +3 0 0 0 0 0 0 0 1 2 +0 0 0 0 0 0 0 1 2 1 +8 0 0 0 0 0 1 2 1 0 +0 0 0 0 0 1 2 1 0 0 +0 0 0 0 1 2 1 0 0 0 +9 0 0 1 2 1 3 0 0 0 +0 0 1 2 1 4 0 0 0 0 +0 1 2 1 5 0 0 0 0 0 +1 2 1 6 0 0 0 0 0 0 +2 1 7 0 0 0 0 0 0 3 +] def % <------------ important line +\end{filecontents} +\psscalebox{0.7}{% +\begin{pspicture}(-0.5,-0.75)(11,11) +\psaxes[ticksize=-5pt 0]{->}(11,11) +\psMatrixPlot[ + colorType=5,dotsize=1.1cm,xStep=1,yStep=1,dotstyle=square*]{10}{10}{matrix1.data} +\end{pspicture}} +\end{center} + +\begin{lstlisting} +\begin{filecontents}{matrix1.data} +/colorTypeDef { + dup /value exch def + value 0 eq + { 1 setgray } + { value 1 eq + { 0 setgray } + { Min sub dMaxMin div neg 1 add 300 mul 400 add +% \pswavelengthToRGB not possible + tx@addDict begin wavelengthToRGB Red Green Blue end + setrgbcolor + } ifelse + } ifelse +} def +/dotmatrix [ % <------------ important line +3 0 0 0 0 0 0 0 1 2 +0 0 0 0 0 0 0 1 2 1 +8 0 0 0 0 0 1 2 1 0 +0 0 0 0 0 1 2 1 0 0 +0 0 0 0 1 2 1 0 0 0 +9 0 0 1 2 1 3 0 0 0 +0 0 1 2 1 4 0 0 0 0 +0 1 2 1 5 0 0 0 0 0 +1 2 1 6 0 0 0 0 0 0 +2 1 7 0 0 0 0 0 0 3 +] def % <------------ important line +\end{filecontents} +\psscalebox{0.7}{% +\begin{pspicture}(-0.5,-0.75)(11,11) +\psaxes[ticksize=-5pt 0]{->}(11,11) +\psMatrixPlot[colorType=5,dotsize=1.1cm,xStep=1,yStep=1, + dotstyle=square*]{10}{10}{matrix1.data} +\end{pspicture}} +\end{lstlisting} + + + %-------------------------------------------------------------------------------------- \section{Dashed Lines} %-------------------------------------------------------------------------------------- @@ -4852,7 +5033,18 @@ be seen with Acroread 7 or later. The syntax is easy: \end{pspicture} \end{LTXexample} +\section{Internal color macros} +The internal macros \Lcs{pswavelengthToRGB} and \Lcs{pswavelengthToRGB} can be used for own purposed. +They are defines as follows: + +\begin{lstlisting} +\def\pswavelengthToGRAY{ tx@addDict begin wavelengthToGRAY end } +\def\pswavelengthToRGB{ tx@addDict begin wavelengthToRGB Red Green Blue end } +\end{lstlisting} +both macros leave the value(s) on the stack which then can be used for further +manipulating or setting the color with \Lps{setgray} or \Lps{setrgbcolor}. +For an example see Section~\ref{sec:psMatrix}. \appendix |