summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pst-2dplot/pst-2dplot.sty
blob: 5eb24fd5e0c03d134fc4b7af584a5b895d6ec491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
%%=========================================
%% This is file 'pst-2dplot.sty'
%% It provides the pst-2dplot package.
%% ------------------------------------
%% Author: Farshid Delgosha
%% E-mail: fdelgosha@gmail.com
%%=========================================

\ProvidesPackage{pst-2dplot}[2008/12/26 by Farshid Delgosha]

\csname PSTiidpLoaded\endcsname
\def\fileversion{1.5}
\def\filedate{2008/12/26}
\message{`pst-2dplot' v\fileversion, \filedate\space (Farshid Delgosha)}

\ifx\PSTricksLoaded\endinput\else\input pstricks \fi
\ifx\PSTplotLoaded\endinput\else \input pst-plot \fi
\ifx\MultidoLoaded\endinput\else \input multido  \fi
\ifx\XKeyValLoaded\endinput\else \input xkeyval \fi
%\ifx\PSTricksAddLoaded\endinput\else \input pstricks-add \fi



%--- internal macros -------------------------------------
\newdimen\iidp@SubDiv@dimenA
\newdimen\iidp@SubDiv@dimenB
%
\def\pst@SubDiv#1#2#3#4#5{%
\pssetlength{\iidp@SubDiv@dimenA}{#1 pt}%
\psaddtolength{\iidp@SubDiv@dimenA}{-#2 pt}%
\pssetlength{\iidp@SubDiv@dimenB}{#3 pt}%
\psaddtolength{\iidp@SubDiv@dimenB}{-#4 pt}%
\pst@divide{\iidp@SubDiv@dimenA}{\iidp@SubDiv@dimenB}#5%
}
%--- end internal macros ---------------------------------



%--- keys ------------------------------------------------
\define@key{pstgraph}{xmin}{\def\iidp@graph@xmin{#1}}
\define@key{pstgraph}{xmax}{\def\iidp@graph@xmax{#1}}
\define@key{pstgraph}{ymin}{\def\iidp@graph@ymin{#1}}
\define@key{pstgraph}{ymax}{\def\iidp@graph@ymax{#1}}
\define@key{pstgraph}{xgriddiv}{\def\iidp@graph@xgriddiv{#1}}
\define@key{pstgraph}{ygriddiv}{\def\iidp@graph@ygriddiv{#1}}
\define@key{pstgraph}{gridstyle}{\def\iidp@graph@gridstyle{#1}}
\define@key{pstgraph}{gridcolor}{\def\iidp@graph@gridcolor{#1}}
\define@key{pstgraph}{gridwidth}{\def\iidp@graph@gridwidth{#1}}
\define@key{pstgraph}{xticksize}{\def\iidp@graph@xticksize{#1}}
\define@key{pstgraph}{yticksize}{\def\iidp@graph@yticksize{#1}}
\define@key{pstgraph}{xtagsep}{\def\iidp@graph@xtagsep{#1}}
\define@key{pstgraph}{ytagsep}{\def\iidp@graph@ytagsep{#1}}
\define@key{pstgraph}{xtagformat}{\def\iidp@graph@xtagformat{#1}}
\define@key{pstgraph}{ytagformat}{\def\iidp@graph@ytagformat{#1}}
\define@key{pstgraph}{xlabel}{\def\iidp@graph@xlabel{#1}}
\define@key{pstgraph}{ylabel}{\def\iidp@graph@ylabel{#1}}
\define@key{pstgraph}{xlabelsep}{\def\iidp@graph@xlabelsep{#1}}
\define@key{pstgraph}{ylabelsep}{\def\iidp@graph@ylabelsep{#1}}
\define@key{pstgraph}{framewidth}{\def\iidp@graph@framewidth{#1}}
\define@key{pstgraph}{framecolor}{\def\iidp@graph@framecolor{#1}}
%--- end keys --------------------------------------------


%--- initial key values ----------------------------------
\setkeys{pstgraph}{%
xmin=0,xmax=1,ymin=0,ymax=1,%
xgriddiv=1,ygriddiv=1,gridstyle=solid,gridcolor=gray,gridwidth=.5pt,%
xticksize=.1,yticksize=.1,xtagsep=.2,ytagsep=.2,xtagformat=\scriptstyle,ytagformat=\scriptstyle,%
xlabel={},ylabel={},xlabelsep=.55,ylabelsep=.75,framewidth=1pt,framecolor=black%
}
%--- end initial key values ------------------------------


%--- pstgraph --------------------------------------------
\def\iidp@graph@gridDx{}
\def\iidp@graph@gridDy{}
\newcount\iidp@graph@grid
\def\iidp@graph@Dx{}
\def\iidp@graph@Dy{}
\newdimen\iidp@graph@pstgraph@dimen
\def\iidp@graph@xscale{}
\def\iidp@graph@yscale{}
%%-------------------------------
\def\pstgraph{\@ifnextchar[{\pst@graph}{\pst@graph[]}}
\def\pst@graph[#1](#2,#3){%
\setkeys{pstgraph}{#1}%
\pspicture(-\iidp@graph@xlabelsep,-\iidp@graph@ylabelsep)(#2,#3)%
\def\iidp@graph@xframe{#2}
\def\iidp@graph@yframe{#3}
%
\newpsstyle{grid@style}{linestyle=\iidp@graph@gridstyle,linecolor=\iidp@graph@gridcolor,linewidth=\iidp@graph@gridwidth}
%
\pst@divide{\iidp@graph@xframe pt}{\iidp@graph@xgriddiv pt}\iidp@graph@gridDx
\iidp@graph@grid=\iidp@graph@xgriddiv\relax
\advance\iidp@graph@grid\@ne
\pst@SubDiv{\iidp@graph@xmax}{\iidp@graph@xmin}{\iidp@graph@xgriddiv}{0}\iidp@graph@Dx
\multido{\rx=0+\iidp@graph@gridDx,\rlab=\iidp@graph@xmin+\iidp@graph@Dx}{\the\iidp@graph@grid}{%
\rput(\rx,0){\psline[style=grid@style](0,-\iidp@graph@xticksize)(0,#3)}%
\rput[t](\rx,-\iidp@graph@xtagsep){$\iidp@graph@xtagformat\rlab$}%
}
%
\pst@divide{\iidp@graph@yframe pt}{\iidp@graph@ygriddiv pt}\iidp@graph@gridDy
\iidp@graph@grid=\iidp@graph@ygriddiv\relax
\advance\iidp@graph@grid\@ne
\pst@SubDiv{\iidp@graph@ymax}{\iidp@graph@ymin}{\iidp@graph@ygriddiv}{0}\iidp@graph@Dy
\multido{\ry=0+\iidp@graph@gridDy,\rlab=\iidp@graph@ymin+\iidp@graph@Dy}{\the\iidp@graph@grid}{%
\rput(0,\ry){\psline[style=grid@style](-\iidp@graph@yticksize,0)(#2,0)}%
\rput[r](-\iidp@graph@ytagsep,\ry){$\iidp@graph@ytagformat\rlab$}%
}
%
\pst@SubDiv{\iidp@graph@xframe}{0}{\iidp@graph@xmax}{\iidp@graph@xmin}\iidp@graph@xscale
\pst@SubDiv{\iidp@graph@yframe}{0}{\iidp@graph@ymax}{\iidp@graph@ymin}\iidp@graph@yscale
}
%%-------------------------------
\def\endpstgraph{%
\psframe[framearc=0,linewidth=\iidp@graph@framewidth,linecolor=\iidp@graph@framecolor,linestyle=solid,dimen=middle]%
(0,0)(\iidp@graph@xframe,\iidp@graph@yframe)%
%
\pssetlength{\iidp@graph@pstgraph@dimen}{\iidp@graph@xframe}%
\pssetlength{\iidp@graph@pstgraph@dimen}{.5\iidp@graph@pstgraph@dimen}%
\rput[t](\iidp@graph@pstgraph@dimen,-\iidp@graph@xlabelsep){\iidp@graph@xlabel}%
%
\pssetlength{\iidp@graph@pstgraph@dimen}{\iidp@graph@yframe}%
\pssetlength{\iidp@graph@pstgraph@dimen}{.5\iidp@graph@pstgraph@dimen}%
\rput[b]{90}(-\iidp@graph@ylabelsep,\iidp@graph@pstgraph@dimen){\iidp@graph@ylabel}%
\endpspicture}
%--- end pstgraph ----------------------------------------


%--- setpstgraph -----------------------------------------
\def\setpstgraph#1{\setkeys{pstgraph}{#1}}
%--- end setpstgraph -------------------------------------


%--- pstlabel --------------------------------------------
\def\pstlabel#1#2{\setkeys{pstgraph}{xlabel=#1,ylabel=#2}}
%--- end pstlabel ----------------------------------------


%--- pstfileplot -----------------------------------------
\def\pstfileplot{\@ifnextchar[{\pst@fileplot}{\pst@fileplot[]}}
\def\pst@fileplot[#1]#2{%
\ifx\empty#1\empty%
\fileplot[xunit=\iidp@graph@xscale,yunit=\iidp@graph@yscale]{#2}%
\else%
\fileplot[xunit=\iidp@graph@xscale,yunit=\iidp@graph@yscale,#1]{#2}%
\fi%
}
%--- end pstfileplot -------------------------------------