listplot 和 postscript

listplot 和 postscript

是否有可能使用 listplot 从定义的点绘制线条?

例子...

文件输入:

-0.013,0.471
0.044,-0.294
-0.069,0.446
0.025,-0.385
0.038,-0.448
0.073,-0.365
0.375,0.045
....

我想找到执行以下操作的代码....

\psline(1,1)(-0.013,0.471)
\psline(1,1)(0.044,-0.294)
......

有没有办法可以轻松地做到这一点?

更新代码:

\documentclass{scrreprt}

\usepackage{scrpage2}
\usepackage[ansinew]{inputenc}
%\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[full]{textcomp} % Euro-Zeichen etc...

\usepackage{datatool}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{array}
\usepackage{ragged2e}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\usepackage{pstricks}
\usepackage{pst-plot} %27.07.2012 testweise
\usepackage{etoolbox}

\makeatletter
\def\ifinstr#1#2{%
  \def\@ifinstr##1#2##2\@nil{%
    \ifstrempty{##2}{\@secondoftwo}{\@firstoftwo}}%
  \@ifinstr#1\@@nil#2\@nil
}

\def\popleft#1#2{%
  \edef\@tmpa{#1}%
  \expandafter\@popleft\expandafter{\@tmpa}{#1}{#2}}
\def\@popleft#1#2#3{%
  \ifinstr{#1}{|}
    {\@@popleft{#2}{#3}\q@nil#1\q@stop}
    {\@@popleft{#2}{#3}\q@nil#1|\q@stop}}
\def\@@popleft#1#2\q@nil#3|#4\q@stop{\edef#1{#4}\edef#2{#3}}

\newcommand*\assignvalues[2]{\@assignvalues{#1}{#2}}
\def\@assignvalues#1#2{%
  \edef\@tmpb{#1}\edef\@tmpc{#2}%
  \popleft\@tmpb\currentvalueA
  \popleft\@tmpc\currentvalueB
  \csedef{\currentvalueA}{\currentvalueB}%
  \ifdefempty\@tmpb{}{\assignvalues\@tmpb\@tmpc}%
}
\makeatother

\FPset\tsize{0.75} % Schriftgröße
\FPset\schriftgr{0.75}
\FPset\schriftgrad{0.4} % Anderson Darling Schriftgröße
\FPset\digitz{5}


\begin{document}   

\assignvalues{xstart|xend|ystart|yend|yistart|nhlines|nvlines|nvunit|hilfsgitternetzlinien|alternativskalierung|inputf|altscale|rgg}{0|9|-0.8|4.6|0|14|10|2|5|0.35|Messdaten/statistik/rohstoffextruder.dat|1|0}
\assignvalues{dart}{loading}
\assignvalues{mbstartx|mbstepx|mbstarty|mbstepy}{1|1|1|1}
\assignvalues{bottomdesc|leftdesc|topdesc|rightdesc|lab|bcaption}{Unten|Links|Oben|Rechts|label|Bezeichnung}
\assignvalues{nvlines|nhlines|lab|mbstartx|mbstepx|hilfsgitterlinien|mbstarty|mbstepy|bcaption|bottomdesc|leftdesc}{5|4|fig:LoadingPlot|-0.1|0.1|15|-0.50|0.25|Loading Plot Rohstoff Extruder|Erste Komponente|Zweite Komponente}
\assignvalues{scalex|scaley|scaler}{1|1|1}

\assignvalues{dummyj|dummyba|dummyh|xendn|dummyq|altscale|miny|dummyu|dummybb|dummyr|dummyl|dummym|dummyb|minstarty|dummyu|dummyt|schriftgrad|gesamthl|messb|dummyd|nhlinesn|minstart|dummyr|dummybb|distmove}
{-0.600000000000000000|-0.069|-0.1|9|0.5|1|-0.448|-0.50|4.6|1.15000|1.80000|0.12000|1.8|0.25|-0.50|0|0.4|75|1|6|5|0.1|1.15000|4.6|1.000000000000000000}

\readdata{\dataA}{Messdaten/statistik/rohstoffextruder.dat}

\ifthenelse{\equal{\messb}{1}}{\message{^^JLade Datenquelle(n) für Diagramm \bcaption\space^^J}}{}
\DTLsetseparator{,}
\DTLifdbexists{table4441}{\DTLdeletedb{table4441}}{ }
\DTLloaddb[noheader,keys={wertx,werty}]{table4441}{\inputf}
\readdata{\dataA}{\inputf}
\ifthenelse{\equal{\messb}{1}}{\message{^^JEinige FP rechnungen, die durch Assignvalues ersetz worden sind..... \bcaption\space^^J}}{}

\begin{figure}[htbp]
%\begin{center}
\centering
\psset{xunit=\scalex cm,yunit=\scaley cm, runit=\scaler cm}

\pstScalePoints(1,1){\dummyba\space \dummyh\space neg \dummyba\space sub add add  \xendn\space mul \dummyq\space\altscale\space mul \space div}{\miny\space neg \dummyu\space neg \miny\space neg sub add add  \dummybb\space mul}
%
\ifthenelse{\equal{\messb}{1}}{\message{^^JZeichne Bildbereich}}{}
%
\begin{pspicture}(\xstart,\ystart)(\xend,\yend)
%
\ifthenelse{\equal{\messb}{1}}{\message{Zeichne die Gitternetzlinien für Diagramm \bcaption\space ^^J}}{}
%
\multiput(\xstart,\dummyr)(\xstart,\dummyr){\nhlines}{\psline[linecolor=black,linestyle=dashed,linewidth=0.4pt](\xstart,\yistart)(\xend,\yistart)}
\multiput(\xstart,\dummyr)(\xstart,\dummyr){\nhlines}{\psline[linecolor=black,linewidth=0.8pt](-0.1,0)(0,0.0)}
%
\multiput(\dummyl,\yistart)(\dummyl,\yistart){\nvlines}{\psline[linecolor=black,linestyle=dashed,linewidth=0.4pt](\xstart,\yistart)(\xstart,\yend)}
\multiput(\dummym,\yistart)(\dummym,\yistart){\gesamthl}{\psline[linecolor=black,linestyle=dotted,linewidth=0.4pt](\xstart,\yistart)(\xstart,\yend)}
\multiput(\dummyl,\yistart)(\dummyl,\yistart){\nvlines}{\psline[linecolor=black,linewidth=0.8pt](0,-0.1)(0,0.0)}
%
\ifthenelse{\equal{\messb}{1}}{\message{Die Gitternetzlinien für Diagramm \bcaption\space wurden fertiggestellt^^J}}{}
\ifthenelse{\equal{\messb}{1}}{\message{Beginne die Beschriftung für Diagramm \bcaption\space ^^J}}{}
%
\multido{\na=\dummyh+\minstart,\nb=0+\dummyb}{\dummyd}{\rput{0}(\nb,-0.3){\FPclip\na\na \scalebox{\schriftgrad}{\na}}}
\multido{\na=\dummyt+\dummyr,\nb=\dummyu+\minstarty}{\nhlinesn}{\rput{0}(-0.5,\na){\FPclip\nb\nb
\scalebox{\schriftgrad}{\nb}}}
\uput[0](\dummyj,-0.7){%
\scalebox{\scalex}{
\begin{tabular}{C{\xend cm}}
 \scalebox{\tsize}{\bottomdesc}  \\ 
\end{tabular}
}}
%
\uput[90](-1.3,-0.7){\rotateleft {%
\scalebox{\scaley}{
\begin{tabular}{C{\yend cm}}
 \scalebox{\tsize}{\leftdesc}  \\ 
\end{tabular}
}}} % Achsenbeschriftung y
\ifthenelse{\equal{\messb}{1}}{\message{Die Beschriftung für Diagramm \bcaption\space wurde fertig gestellt^^J}}{}
\ifthenelse{\equal{\messb}{1}}{\message{^^JZeichne die Daten von \bcaption\space ^^J}}{}


% Alter Code....
%\ifthenelse{\equal{\dart}{loading}}{
% \DTLforeach{table4441}{%
%  \wertx=wertx,\werty=werty}{
%  \FPupn{X}{\wertx}
%  \FPupn{X}{X \dummyba\space \dummyh\space neg \dummyba\space sub add add  \xendn\space mul \dummyq\space\altscale\space mul \space div}
%  \FPround\X\X\digitz
%  \FPupn{Y}{\werty}
%   \FPupn{Y}{Y \miny\space neg \dummyu\space neg \miny\space neg sub add add  \dummybb\space mul}
%   \FPupn{Xs}{\minstart\space \distmove\space mul \xendn\space mul \dummyq\space\altscale\space mul \space div}
%   \FPupn{Ys}{\dummyu\space neg \dummybb\space mul}   \psline[linecolor=blued,linestyle=dashed,linewidth=0.4pt](\Xs,\Ys)(\X,\Y)
% }
%}{}
%

% ersetzt durch Herberts neuen Code
\FPupn{Xs}{\minstart\space \distmove\space mul \xendn\space mul \dummyq\space\altscale\space mul \space div}
\FPupn{Ys}{\dummyu\space neg \dummybb\space mul}  
\makeatletter
\pslistplot[linecolor=red!50]{
   /startpoint { \Xs\space \Ys\space \tx@ScreenCoor\space moveto } def
   mark \dataA \space counttomark 2 div cvi /nData exch def 
   nData {
     startpoint \tx@ScreenCoor\space lineto
   } repeat
}
\pslistplot[plotstyle=dots]{\dataA}
% Herberts neuer Code

\ifthenelse{\equal{\dart}{screen}}{
\listplot[plotstyle=line, linewidth=1.73pt, linecolor=black,showpoints=false,dotstyle=*,dotsize=4pt]{\dataA}  % Punkte Blau 200 Grad
\listplot[plotstyle=dots, linewidth=1.73pt, linecolor=white,showpoints=true,dotstyle=*,dotsize=6pt]{\dataA}  % Punkte Blau 200 Grad
\listplot[plotstyle=dots, linewidth=1.73pt, linecolor=black,showpoints=true,dotstyle=*,dotsize=4pt]{\dataA}  % Punkte Blau 200 Grad
}{}

\ifthenelse{\equal{\dart}{loading}}{
\listplot[plotstyle=dots, linewidth=1.73pt, linecolor=black,showpoints=true,dotstyle=*,dotsize=6pt]{\dataA}  % Punkte Blau 200 Grad
\listplot[plotstyle=dots, linewidth=1.73pt, linecolor=black,showpoints=true,dotstyle=*,dotsize=4pt]{\dataA}  % Punkte Blau 200 Grad
}{}

\psline(\xstart,\yistart)(\xend,\yistart)
\psline(\xstart,\yistart)(\xstart,\yend)
\psline(\xend,\yistart)(\xend,\yend)
\psline(\xstart,\yend)(\xend,\yend)
\end{pspicture}
\caption[\bcaption]{\bcaption} 
\label{\lab}
\end{figure}
\end{document}

代码,几乎达到目标....

\assignvalues{xstart|xend|ystart|yend|yistart|nhlines|nvlines|nvunit|hilfsgitternetzlinien|alternativskalierung|inputf|altscale|rgg}{0|9|-0.8|4.6|0|14|10|2|5|0.35|Messdaten/statistik/rohstoffextruder.dat|1|0}
\assignvalues{dart}{loading}
\assignvalues{mbstartx|mbstepx|mbstarty|mbstepy}{1|1|1|1}
\assignvalues{bottomdesc|leftdesc|topdesc|rightdesc|lab|bcaption}{Unten|Links|Oben|Rechts|label|Bezeichnung}
\assignvalues{nvlines|nhlines|lab|mbstartx|mbstepx|hilfsgitterlinien|mbstarty|mbstepy|bcaption|bottomdesc|leftdesc}{5|4|fig:LoadingPlot|-0.1|0.1|15|-0.50|0.25|Loading Plot Rohstoff Extruder|Erste Komponente|Zweite Komponente}
\assignvalues{scalex|scaley|scaler}{1|1|1}

    \assignvalues{dummyj|dummyba|dummyh|xendn|dummyq|altscale|miny|dummyu|dummybb|dummyr|dummyl|dummym|dummyb|minstarty|dummyu|dummyt|schriftgrad|gesamthl|messb|dummyd|nhlinesn|minstart|dummyr|dummybb|distmove}{-0.600000000000000000|-0.069|-0.1|9|0.5|1|-0.448|-0.50|4.6|1.15000|1.80000|0.12000|1.8|0.25|-0.50|0|0.4|75|1|6|5|0.1|1.15000|4.6|1.000000000000000000}

\FPupn{Xs}{\minstart\space \distmove\space mul \xendn\space mul \dummyq\space\altscale\space mul \space div}
\FPupn{Ys}{\dummyu\space neg \dummybb\space mul}  
\makeatletter
\pslistplot[linecolor=red!50]{
   /startpoint { \Xs\space \Ys\space \tx@ScreenCoor\space moveto } def
   mark \dataA \space counttomark 2 div cvi /nData exch def 
   nData {
     \tx@ScreenCoor\space \miny\space neg \dummyu\space neg \miny\space neg sub add add  \dummybb\space mul
     exch \tx@ScreenCoor\space \dummyba\space \dummyh\space neg \dummyba\space sub add add  \xendn\space mul \dummyq\space\altscale\space mul \space div exch
     startpoint \tx@ScreenCoor\space lineto
   } repeat
}
%\makeatother
\pslistplot[plotstyle=dots]{\dataA}

答案1

\pslistplot可以处理任何类型的 PostScript 函数:

\documentclass{article}
\usepackage{pst-plot}
\def\data{
-0.013 0.471
0.044 -0.294
-0.069 0.446
0.025 -0.385
0.038 -0.448
0.073 -0.365
0.375 0.045}
\begin{document}
\begin{psgraph}(0,0)(-0.5,-1)(1,1){5cm}{5cm}
\makeatletter
\pslistplot[linecolor=red!50]{
   /startpoint { 1 1 \tx@ScreenCoor\space moveto } def % define a function for moving to 1 1 in screen coordinates
   mark \data \space counttomark 2 div cvi /nData exch def % count the number of data pairs and save it in nData
   nData { % repeat loop over nData
     startpoint % move to startpoint (1,1)
     \tx@ScreenCoor\space % transform the last two x y values into screen coordinates
     lineto % draw a line to these corrdinates
   } repeat % end of repeat
}
\pslistplot[plotstyle=dots]{\data}
\end{psgraph}

\end{document}

在此处输入图片描述

相关内容