Paul Smith wrote:
On 2/3/06, Herbert Voss <[EMAIL PROTECTED]> wrote:

tell me the structure of your data file?
Are the values also saved as a matrix?

Thanks to all. An example of a data file is attached. It is a text
file with a matrix. Each column corresponds to x-coordinate, whereas
each row corresponds to y-coordinate. Both x and y have the same
range: [0,1]. From column to column, x increases 0.1. From row to row,
y increases 0.1. First column corresponds to x=0 and first row to y=0.

------------------------------------------------------------------------

0     1       1       0       0       0       0       1       1       1
0     1       1       0       1       1       1       0       1       0

understood. Here an example if you could have your textfile
as

/matrix [
0       1       1       0       0       0       0       1       1     1
0       1       1       0       1       1       1       0       1     0
....
] def


Great, Herbert! That is it. Maybe, a "spy-like" command could be added
to the list of commands of PSTricks. Well, that is just a
suggestion...

let's see ...

However, I was a bit too clever ...
the textfile should be with a first and last line of

/dotmatrix [
0       1       1       0       0       0       0       1       1     1
...
...
] def

I forgot that PSTricks also defines a /matrix array for internal
purposes. It collides with the one from this text matrix. Name it
/dotmatrix [ ... ] def instead and everything will be ok. See
example, which also shows the possibility of printing the dots
as squares without whitespace.

Herbert



\documentclass[a4paper]{article}
\usepackage{pst-plot}

\makeatletter
\def\specialPlot#1{%
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
    (#1) run            % load the data file
    [EMAIL PROTECTED]   % scale dot
    [EMAIL PROTECTED]@[EMAIL PROTECTED] % dotstyle
    /n 0 def            % index for element
    0 0.1 1 {           % the y loop
      /y exch def       % save y
      0 0.1 1 {         % the x loop
        /x exch def     % save x
        dotmatrix n get % get value from matrix
        dup 0 gt {      % test if > 0
          x [EMAIL PROTECTED] mul y [EMAIL PROTECTED] mul Dot%
        } { pop } ifelse
        /n n 1 add def
      } for
    } for
  }%
  [EMAIL PROTECTED]
}
\makeatother

\begin{document}

\psset{unit=10}
\begin{pspicture}(-0.1,-0.1)(1.1,1.1)
  \psaxes[Dx=0.1,Dy=0.1]{->}(1,1)
  \psset{dotscale=3,dotstyle=square*,linecolor=magenta}
  \specialPlot{matrix.txt} % must be of /dotmatrix [ ... ] def
\end{pspicture}

\begin{pspicture}(-0.1,-0.1)(1.1,1.1)
  \psaxes[Dx=0.1,Dy=0.1]{->}(1,1)
  \psset{dotsize=1.1cm,dotstyle=square*,linecolor=magenta}
  \specialPlot{matrix.txt}
\end{pspicture}




Paul



Reply via email to