summaryrefslogtreecommitdiff
path: root/graphics/pstricks/contrib/pst-func/tex/pst-func.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pstricks/contrib/pst-func/tex/pst-func.tex')
-rw-r--r--graphics/pstricks/contrib/pst-func/tex/pst-func.tex209
1 files changed, 73 insertions, 136 deletions
diff --git a/graphics/pstricks/contrib/pst-func/tex/pst-func.tex b/graphics/pstricks/contrib/pst-func/tex/pst-func.tex
index abd00a74c1..3e67c926f9 100644
--- a/graphics/pstricks/contrib/pst-func/tex/pst-func.tex
+++ b/graphics/pstricks/contrib/pst-func/tex/pst-func.tex
@@ -1,4 +1,4 @@
-%% $Id: pst-func.tex 1184 2020-06-06 18:36:57Z herbert $
+%% $Id: pst-func.tex 306 2021-10-29 14:48:08Z herbert $
%%
%% This is file `pst-func.tex',
%%
@@ -31,8 +31,8 @@
% interface to the `xkeyval' package
\pst@addfams{pst-func}
%
-\def\fileversion{0.96}
-\def\filedate{2021/04/05}
+\def\fileversion{0.97}
+\def\filedate{2021/10/29}
\message{`PST-func' v\fileversion, \filedate\space (hv)}
%
\pstheader{pst-func.pro}
@@ -58,20 +58,20 @@
\pst@killglue
\psset{#1}
\psplot[algebraic=false]{#2}{#3}{%
- /type (cos) def
+ /psFtype (cos) def
/Fourier {
aload length /n exch def
n -1 roll 2 div n 1 roll % a0/2
n 1 sub -1 0 {
/i exch def
i x mul 180 mul 3.141592 div
- type (sin) eq {sin}{cos} ifelse
+ psFtype (sin) eq {sin}{cos} ifelse
mul n 1 roll
} for
n 1 sub -1 1 { pop add } for
} def
[\psk@cosCoeff] Fourier
- /type (sin) def
+ /psFtype (sin) def
[0 \psk@sinCoeff] Fourier add
}%
}\ignorespaces}
@@ -185,10 +185,10 @@
xy moveto
}%
\if@pst% lines and dots
- \psPolynomial@iii%
+ \psPolynomial@iii
\else% curves
- \psPolynomial@ii%
- \fi%
+ \psPolynomial@ii
+ \fi
\endgroup
\ignorespaces}
%
@@ -698,10 +698,10 @@ grestore
}
%
\define@key[psset]{pst-func}{PSfont}[NimbusRomNo9L-Regu]{\def\psk@PSfont{/#1 }}
-\define@key[psset]{pst-func}{valuewidth}[10]{\pst@getint{#1}\psk@valuewidth }
+\define@key[psset]{pst-func}{valuewidth}[20]{\pst@getint{#1}\psk@valuewidth }
\define@key[psset]{pst-func}{fontscale}[10]{\pst@checknum{#1}\psk@fontscale }
\define@key[psset]{pst-func}{decimals}[-1]{\pst@getint{#1}\psk@decimals }
-\psset[pst-func]{PSfont=NimbusRomNo9L-Regu,fontscale=10,valuewidth=10,decimals=-1}
+\psset[pst-func]{PSfont=NimbusRomNo9L-Regu,fontscale=10,valuewidth=20,decimals=-1}
%
\def\psPrintValue{\pst@object{psPrintValue}}
\def\psPrintValue@i#1{\expandafter\psPrintValue@ii#1,,\@nil}
@@ -715,7 +715,8 @@ grestore
Func
\else #1 \fi
\psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
- \psk@valuewidth string cvs %/Output exch def % save output
+ %\psk@valuewidth
+ 100 string cvs %/Output exch def % save output
\ifPst@comma dot2comma \fi % do we have to change dot to comma
\psk@xShift\space 0 moveto %Output
show grestore
@@ -1596,134 +1597,70 @@ grestore
\define@boolkey[psset]{pst-func}[Pst@]{Gini}[true]{}
\psset[pst-func]{Gini=false}
%
-\def\psLorenz{\pst@object{psLorenz}}
-\def\psLorenz@i#1{{%
-% \readdata{\L@Data}{#1}%
+\def\psLorenz{\def\pst@par{}\pst@object{psLorenz}}
+\def\psLorenz@i{\@ifnextchar<\psLorenz@ii{\psLorenz@ii<>}}
+\def\psLorenz@ii<#1>#2{%
\if@star\addto@par{fillstyle=solid,fillcolor=\pslinecolor}\fi
- \use@par%
-\iffalse
- \def\Lorenz@code{
- /D {} def
- [ \L@Data\space counttomark dup
- 1 sub /m ED 2 div cvi /n ED % m=0..n-1 n=number of pairs
- ] /xyValues ED
- /Xval [] def /Yval [] def /Xmax 0 def
- /Xsum 0 def /Ysum 0 def /XYsum 0 def
- xyValues aload pop % [ x y x y x y ... ]
- n { 2 copy mul XYsum add /XYsum ED
- dup
- Yval aload length 1 add array astore /Yval ED
- Ysum add /Ysum ED
- dup
- Xval aload length 1 add array astore /Xval ED
- dup Xsum add /Xsum ED
- dup Xmax gt { /Xmax ED }{ pop } ifelse
- } repeat
- Xval bubblesort /Xval ED
- Yval bubblesort /Yval ED
- Xval { Xmax div } forall n array astore /XvalRelMax ED
- Xval { Xsum div } forall n array astore /XvalRel ED
- Yval { Ysum div } forall n array astore /YvalRel ED
- 0 1 n 1 sub {
- cvi /Index ED
- Xval Index get
- Yval Index get
- mul } for
- n array astore /XmulY ED
- XmulY aload length 1 sub { add } repeat
- /XmulYsum ED
- XmulY { XmulYsum div } forall
- n array astore /XmulYdivXmulYsum ED
- /X [0] def
- /Y [0] def
- /Xsum 0 def /Ysum 0 def
- 0 1 n 1 sub {
- /Index ED
-% XvalRel Index get Xsum add /Xsum ED
-% X aload length 1 add Xsum exch array astore /X ED
- X aload length 1 add XvalRelMax Index get exch array astore /X ED %%
- XmulYdivXmulYsum Index get Ysum add /Ysum ED
- Y aload length 1 add Ysum exch array astore /Y ED
- } for
- \ifPst@Gini
- 0 % start value for Gini
- 0 1 X length 2 sub {
- /Index ED
- Y Index get Y Index 1 add get add 2 div % yHeight=(y0+y1)/2
- X Index 1 add get X Index get sub abs % xWidth=x1-x0
- mul % x*y
- add
- } for
- 2 mul 1 sub neg % triangle area divided by the area under the polygon
- \psk@PSfont\space findfont \psk@fontscale scalefont setfont
- \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
- \psk@valuewidth string cvs %/Output exch def % save output
- \ifPst@comma dot2comma \fi % do we have to change dot to comma
- /Output ED
- \psk@xShift\space -30 moveto (Gini: ) show
- Output show
- \fi
- 0 1 n { dup X exch get exch Y exch get } for
- \if@star 1 0 0 0 \fi % add values for the closed curve
- }% filling the area under the curve.
-\fi
-%%%%%%%%%%%%%%%%%%%%%%5
+ \begingroup
+ \use@par
\def\Lorenz@code{
- [ #1 ] dup length /n ED
- bubblesort /Yval ED
- [ 1 1 n { } for ] /Xval ED
- /Xsum n dup 1 add mul 2 div cvi def
- /Ysum 0 def /XYsum 0 def
- 0 Yval { add } forall /Ysum ED
- Xval { n div } forall n array astore /XvalRelMax ED
- Xval { Xsum div } forall n array astore /XvalRel ED
- Yval { Ysum div } forall n array astore /YvalRel ED
- 0 1 n 1 sub {
- /Index ED
- Xval Index get
- Yval Index get
- mul } for
- n array astore /XmulY ED
- XmulY aload length 1 sub { add } repeat
- /XmulYsum ED
- XmulY { XmulYsum div } forall
- n array astore /XmulYdivXmulYsum ED
- /X [0] def
- /Y [0] def
- /Xsum 0 def /Ysum 0 def
- 0 1 n 1 sub {
- /Index ED
-% XvalRel Index get Xsum add /Xsum ED
-% X aload length 1 add Xsum exch array astore /X ED
- X aload length 1 add XvalRelMax Index get exch array astore /X ED %%
- XmulYdivXmulYsum Index get Ysum add /Ysum ED
- Y aload length 1 add Ysum exch array astore /Y ED
- } for
- \ifPst@Gini
- 0 % start value for Gini
- 0 1 X length 2 sub {
- /Index ED
- Y Index get Y Index 1 add get add 2 div % yHeight=(y0+y1)/2
- X Index 1 add get X Index get sub abs % xWidth=x1-x0
- mul % x*y
- add
- } for
- 2 mul 1 sub neg % triangle area divided by the area under the polygon
- \psk@PSfont\space findfont \psk@fontscale scalefont setfont
- \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
- \psk@valuewidth string cvs %/Output exch def % save output
- \ifPst@comma dot2comma \fi % do we have to change dot to comma
- /Output ED
- \psk@xShift\space -30 moveto (Gini: ) show
- Output show
- \fi
- 0 1 n { dup X exch get exch Y exch get } for
- \if@star 1 0 0 0 \fi % add values for the closed curve
+ 25 dict begin
+ [ #2 ] dup length /nVal ED
+ /Yval ED
+ Yval arraySum /Ysum ED
+ Yval { Ysum div } forall nVal array astore /YvalRel ED % Pred dist
+ \if$#1$
+ [ 1 1 nVal { nVal div } for ] dup /XvalRel ED /XvalRelCum ED
+ YvalRel bubblesort /YvalRel ED
+ \else
+ [ #1 ] /Xval ED
+ Xval arraySum /Xsum ED
+ Xval { Xsum div } forall nVal array astore /XvalRel ED % Freq dist
+ /CumFreq 0 def
+ [
+ 0 1 nVal 1 sub {
+ XvalRel exch get CumFreq add dup /CumFreq ED
+ } for
+ ] /XvalRelCum ED
+% XvalRelCum ==
+ \fi
+ /CumPred 0 def
+ [
+ 0 1 nVal 1 sub {
+ YvalRel exch get CumPred add dup /CumPred ED
+ } for
+ ] /YvalRelCum ED
+% YvalRelCum ==
+% Xsum == Ysum ==
+ \ifPst@Gini
+ [ 0 1 nVal 1 sub {
+ /Index ED
+ YvalRelCum Index get
+ Index 0 eq { 0 }{ YvalRelCum Index 1 sub get } ifelse
+ add 0.5 mul XvalRel Index get mul
+ } for
+ ] /Area ED
+% Area ==
+ Area arraySum /B ED
+ 0.5 B sub dup B add div
+ \psk@PSfont\space findfont \psk@fontscale scalefont setfont
+ \psk@decimals -1 gt { 10 \psk@decimals exp dup 3 1 roll mul cvi exch div } if
+ \psk@valuewidth string cvs %/Output exch def % save output
+ \ifPst@comma dot2comma \fi % do we have to change dot to comma
+ /Output ED
+ \psk@xShift\space -30 moveto (Gini: ) show
+ Output show
+ \fi
+ 0 0 % the start point
+ 0 1 nVal 1 sub { dup XvalRelCum exch get exch YvalRelCum exch get } for
+ \if@star 1 0 0 0 \fi % add values for the closed curve
+ end
}% filling the area under the curve.
\if@star\listplot*{\Lorenz@code}\else\listplot{\Lorenz@code}%
-% \listplot[plotstyle=bezier,linecolor=red]{\Lorenz@code}
- \fi%
-}\ignorespaces}
+% \listplot[plotstyle=bezier,linecolor=red]{\Lorenz@code}
+ \fi
+ \endgroup
+ \ignorespaces}
%
% Superellipese / Lamefunction
\define@key[psset]{pst-func}{radiusA}[1]{\pst@getlength{#1}\pst@radiusA}