summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pst-2dplot/pst-2dplot.sty
blob: 021412bbc571bfacf0185ca94cb0a0b94c9e9521 (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
150
151
152
153
%%=========================================
%% This is file 'pst-2dplot.sty'
%% It provides the pst-2dplot package.
%% ------------------------------------
%% Author: Farshid Delgosha
%%         326004 Georgia Tech Station
%%         Atlanta, GA 30332-1085
%%         U.S.A.
%% E-mail: delgosha@ieee.org
%%=========================================

\ProvidesPackage{pst-2dplot}[2006/08/20 Version 1.0 by Farshid Delgosha]
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\typeout{%
*****************************************************^^J%
Package `pst-2dplot' (Version 1.0) -- 22 January 2007 --^^J%
Author: Farshid Delgosha (delgosha@ieee.org)^^J%
*****************************************************}

\def\fileversion{1.0}
\def\filedate{2007/01/22}

\csname PSTtwoDPlotLoaded\endcsname
\let\PSTtwoDPlotLoaded\endinput



\RequirePackage{xkeyval,calc}
\RequirePackage{pstricks-add}



%-----------------------------------------------
% PSTAXES local variables
%-----------------------------------------------
\def\@pstaxes@xmin{0}
\def\@pstaxes@ymin{0}
\def\@pstaxes@xmax{1}
\def\@pstaxes@ymax{1}
\def\@pstaxes@xbox{1}
\def\@pstaxes@ybox{1}
\def\@pstaxes@gridwidth{.5pt}
\def\@pstaxes@gridcolor{gray}
\def\@pstaxes@gridstyle{solid}
\def\@pstaxes@xgriddiv{1}
\def\@pstaxes@ygriddiv{1}
\def\@pstaxes@xticksize{.1}
\def\@pstaxes@yticksize{.1}
\def\@pstaxes@xlabel{}
\def\@pstaxes@ylabel{}
\def\@pstaxes@xtagsep{.4}
\def\@pstaxes@ytagsep{.5}
\def\@pstaxes@xlabelsep{.8}
\def\@pstaxes@ylabelsep{1}
%-----------------------------------------------


%-----------------------------------------------
% assign PSTAXES local variables
%-----------------------------------------------
\define@key{pstaxes}{xmin}{\renewcommand\@pstaxes@xmin{#1}}
\define@key{pstaxes}{ymin}{\renewcommand\@pstaxes@ymin{#1}}
\define@key{pstaxes}{xmax}{\renewcommand\@pstaxes@xmax{#1}}
\define@key{pstaxes}{ymax}{\renewcommand\@pstaxes@ymax{#1}}
\define@key{pstaxes}{xbox}{\renewcommand\@pstaxes@xbox{#1}}
\define@key{pstaxes}{ybox}{\renewcommand\@pstaxes@ybox{#1}}
\define@key{pstaxes}{gridwidth}{\renewcommand\@pstaxes@gridwidth{#1}}
\define@key{pstaxes}{gridcolor}{\renewcommand\@pstaxes@gridcolor{#1}}
\define@key{pstaxes}{gridstyle}{\renewcommand\@pstaxes@gridstyle{#1}}
\define@key{pstaxes}{xgriddiv}{\renewcommand\@pstaxes@xgriddiv{#1}}
\define@key{pstaxes}{ygriddiv}{\renewcommand\@pstaxes@ygriddiv{#1}}
\define@key{pstaxes}{xticksize}{\renewcommand\@pstaxes@xticksize{#1}}
\define@key{pstaxes}{yticksize}{\renewcommand\@pstaxes@yticksize{#1}}
\define@key{pstaxes}{xlabel}{\renewcommand\@pstaxes@xlabel{#1}}
\define@key{pstaxes}{ylabel}{\renewcommand\@pstaxes@ylabel{#1}}
\define@key{pstaxes}{xlabelsep}{\renewcommand\@pstaxes@xlabelsep{#1}}
\define@key{pstaxes}{ylabelsep}{\renewcommand\@pstaxes@ylabelsep{#1}}
\define@key{pstaxes}{xtagsep}{\renewcommand\@pstaxes@xtagsep{#1}}
\define@key{pstaxes}{ytagsep}{\renewcommand\@pstaxes@ytagsep{#1}}
%-----------------------------------------------



%-----------------------------------------------
% PSTAXES internal variables
%-----------------------------------------------
\newcounter{@pstaxes@grid}
\def\@pstaxes@dx{1}
\def\@pstaxes@dy{1}
\def\@pstaxes@Dx{1}
\def\@pstaxes@Dy{1}
\def\@pstaxes@pos{1}
\newlength{\@pstaxes@xrange}
\newlength{\@pstaxes@yrange}
\newlength{\@pstaxes@XunitTemp}
\newlength{\@pstaxes@YunitTemp}
%-----------------------------------------------



%-----------------------------------------------
% PSTAXES environment
%-----------------------------------------------
\newenvironment{pstaxes}[1][]{
   \setkeys{pstaxes}{#1}
   \begin{pspicture}(-\@pstaxes@xtagsep,-\@pstaxes@ytagsep)(\@pstaxes@xbox,\@pstaxes@ybox)
      \setlength{\@pstaxes@xrange}{\@pstaxes@xmax pt - \@pstaxes@xmin pt}
      \setlength{\@pstaxes@yrange}{\@pstaxes@ymax pt - \@pstaxes@ymin pt}

      \setcounter{@pstaxes@grid}{\@pstaxes@xgriddiv}
      \addtocounter{@pstaxes@grid}{1}
      \pst@divide{\@pstaxes@xbox pt}{\@pstaxes@xgriddiv pt}\@pstaxes@dx
      \pst@divide{\@pstaxes@xrange}{\@pstaxes@xgriddiv pt}\@pstaxes@Dx
      \multido{\rx=0+\@pstaxes@dx,\rX=\@pstaxes@xmin+\@pstaxes@Dx}{\the@pstaxes@grid}%
              {\psline[linecolor=\@pstaxes@gridcolor,linewidth=\@pstaxes@gridwidth,linestyle=\@pstaxes@gridstyle]
                      (\rx,-\@pstaxes@xticksize)(\rx,\@pstaxes@ybox)
               \rput[t](\rx,-\@pstaxes@xtagsep){$\rX$}}

      \setcounter{@pstaxes@grid}{\@pstaxes@ygriddiv}
      \addtocounter{@pstaxes@grid}{1}
      \pst@divide{\@pstaxes@ybox pt}{\@pstaxes@ygriddiv pt}\@pstaxes@dy
      \pst@divide{\@pstaxes@yrange}{\@pstaxes@ygriddiv pt}\@pstaxes@Dy
      \multido{\ry=0+\@pstaxes@dy,\rY=\@pstaxes@ymin+\@pstaxes@Dy}{\the@pstaxes@grid}%
              {\psline[linecolor=\@pstaxes@gridcolor,linewidth=\@pstaxes@gridwidth,linestyle=\@pstaxes@gridstyle]
                      (-\@pstaxes@yticksize,\ry)(\@pstaxes@xbox,\ry)
               \rput[r](-\@pstaxes@ytagsep,\ry){$\rY$}}

      \setlength{\@pstaxes@XunitTemp}{\psxunit}
      \setlength{\@pstaxes@YunitTemp}{\psyunit}
      \psset{xunit=\@pstaxes@xbox,yunit=\@pstaxes@ybox}
}
{
      \psset{xunit=\@pstaxes@XunitTemp,yunit=\@pstaxes@YunitTemp}
      \psframe[linecolor=black,linestyle=solid](\@pstaxes@xbox,\@pstaxes@ybox)

      \pst@divide{\@pstaxes@xbox pt}{2pt}\@pstaxes@pos
      \rput[t](\@pstaxes@pos,-\@pstaxes@xlabelsep){\@pstaxes@xlabel}

      \pst@divide{\@pstaxes@ybox pt}{2pt}\@pstaxes@pos
      \rput[b]{90}(-\@pstaxes@ylabelsep,\@pstaxes@pos){\@pstaxes@ylabel}
   \end{pspicture}
}
%-----------------------------------------------



%-----------------------------------------------
% Commands
%-----------------------------------------------
\newcommand{\pstaxessetup}[1]{\setkeys{pstaxes}{#1}}
\newcommand{\pstxlabel}[1]{\setkeys{pstaxes}{xlabel=#1}}
\newcommand{\pstylabel}[1]{\setkeys{pstaxes}{ylabel=#1}}
%-----------------------------------------------