From 792ab47701eef9ed7c77ca44fb642b53189aba33 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 26 Jul 2011 23:26:28 +0000 Subject: numericplots (14jul11) git-svn-id: svn://tug.org/texlive/trunk@23241 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/numericplots/NumericPlots.sty | 267 +++++++++++++++------ 1 file changed, 192 insertions(+), 75 deletions(-) (limited to 'Master/texmf-dist/tex/latex/numericplots') diff --git a/Master/texmf-dist/tex/latex/numericplots/NumericPlots.sty b/Master/texmf-dist/tex/latex/numericplots/NumericPlots.sty index aa0cb63d572..7eb6722b7df 100644 --- a/Master/texmf-dist/tex/latex/numericplots/NumericPlots.sty +++ b/Master/texmf-dist/tex/latex/numericplots/NumericPlots.sty @@ -1,4 +1,4 @@ -% Copyright 2010 Thomas König, Alexander Michel, Michael Baumgart +% Copyright 2010 Thomas Koenig, Alexander Michel, Michael Baumgart % % This file is part of NumericPlots. % @@ -17,7 +17,7 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{NumericPlots}[2010/08/09 LaTeX package to plot numeric data] +\ProvidesPackage{NumericPlots}[2011/01/07 LaTeX package to plot numeric data] % ========================================================== % || TODO @@ -41,6 +41,7 @@ \RequirePackage{xcolor} + % ======================================= % === Definition of keys and commands === % ======================================= @@ -50,6 +51,7 @@ % define all the new commands.. \RequirePackage{xkeyval} +\RequirePackage{xkvview} % keep track of all keys that are defined % globally needed values as newcommands \newcommand{\NumDataPlotxRange}{1} @@ -156,6 +158,8 @@ \fi } +\define@boolkey[NumericDataPlot]{Axis}{yNearlyTight}[false]{} + % xMin and yMin also set xO/yO. It will later be ensured that if the user % provides a value for xO/yO, these values will be used! (in order to do so, it % is always necessary to call the following two commands in the given order: @@ -266,6 +270,11 @@ \PackageWarning{NumericPlots}{LabelOrientation #1 not defined. Use r, l or c} } + +% ------------------------------------------------------------------------------ +% | keys for the put commands +% ------------------------------------------------------------------------------ + \define@key[NumericDataPlot]{put}{x}{ \FPsub{\NumDataPlotBuffer}{#1}{\NumDataPlotxMin} \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotxDataCoordRatio} @@ -324,7 +333,7 @@ \newcommand{\LegendDefinition}[2][nrCols]{% \setkeys[NumericDataPlot]{Legend}{#1}% % - \psframebox[fillcolor=white, fillstyle=solid]{% + \psframebox[style=LegendBoxStyle]{% \ifLegendOrientationLeft \begin{tabular}{*{\nrLegendCols}{p{\LegLineWidth}l}}% #2% @@ -371,7 +380,7 @@ \NumDataPlotyCoordMin\space add){ \begin{tabular}{c} \NumDataPlotyLabelOption{}#1\\ - \vspace{\yLabelSep} + \vspace{\yLabelSep} \end{tabular}} \setlength{\yLabelSep}{\origYLabelSep} } @@ -529,7 +538,7 @@ \rput[#3]{0}(!\NumDataPlotdx \space \NumDataPlotDx \space div \n \space \NumDataPlotxO \space sub mul \xCoordOrig \space add \space #1 \space \NumDataPlotxTickSep \space #2) - {\NumDataPlotxTickLabelOption{}$\LogxAxisLabel{\n}$} + {\NumDataPlotxTickLabelOption{}$\LogxAxisLabel{\n}$} } % plot ticks on left side of the origin \mmultido{\n=\NumDataPlotxO+\NumDataPlotDx}{\NumDataPlotBuffer} @@ -583,7 +592,9 @@ % plot lower axis \ifthenelse{\boolean{PlotLowerAxis}} { - \psline(\NumDataPlotxCoordMin,\NumDataPlotyCoordMin)(\NumDataPlotxCoordMax, \NumDataPlotyCoordMin) + \psline{C-C}% + (\NumDataPlotxCoordMin, \NumDataPlotyCoordMin)% + (\NumDataPlotxCoordMax, \NumDataPlotyCoordMin) \ifNumericDataPlot@xAxis@NoTickLabel \else \plotxTickLabels{\NumDataPlotyCoordMin}{sub}{t} @@ -596,13 +607,17 @@ %plot upper axis (boxed) \ifthenelse{\boolean{PlotUpperAxis}}{ % plot upper axis - \psline(\NumDataPlotxCoordMin,\NumDataPlotyCoordMax)(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) + \psline{C-C}% + (\NumDataPlotxCoordMin,\NumDataPlotyCoordMax)% + (\NumDataPlotxCoordMax,\NumDataPlotyCoordMax) }{} - }{ + }{ % plot upper axis (only upper axis) \ifthenelse{\boolean{PlotUpperAxis}}{ % plot upper axis - \psline(\NumDataPlotxCoordMin,\NumDataPlotyCoordMax)(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) + \psline{C-C}% + (\NumDataPlotxCoordMin,\NumDataPlotyCoordMax)% + (\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) % plot ticklabels \ifNumericDataPlot@xAxis@NoTickLabel \else @@ -654,6 +669,11 @@ [xO, xMin, xMax, xCoordMin, xCoordMax, Dx, dx, xLog]{#1} \setrmkeys[NumericDataPlot]{AxisWait}[xO] + %\ifNumericDataPlot@Axis@yNearlyTight +% \FPifpos{\NumDataPlotyMax} \FPmul{\NumDataPlotyMax}{\NumDataPlotyMax}{1.1} \else \FPmul{\NumDataPlotyMax}{\NumDataPlotyMax}{0.9}\fi +% \FPifpos{\NumDataPlotyMin} \FPmul{\NumDataPlotyMin}{\NumDataPlotyMin}{0.9} \else \FPmul{\NumDataPlotyMin}{\NumDataPlotyMin}{1.1}\fi +% \fi + % for logarithmic axes: calculate log(xMax), log(xMin), Dx=1, xO=ceil(xMin) \ifNumericDataPlot@Axis@yLog \FPln{\NumDataPlotBuffer}{\NumDataPlotyMax} @@ -773,6 +793,27 @@ % } } +\newcommand{\plotyGridBoxed}{ + % plot gridline on right side of the origin + \mmultido{\n=\yCoordOrig+\NumDataPlotdy}{\TicksYRight-1}{ + \plotyGridLine{\n} + \yLogSubGrid{\n} + } + % plot gridline on left side of the origin + \multido{\n=\yCoordOrig+\NumDataPlotdy}{\TicksYLeft-1}{ + \plotyGridLine{\n} + } + \FPsub{\NumDataPlotBuffer}{\TicksYLeft}{1} + \FPround{\NumDataPlotBuffer}{\NumDataPlotBuffer}{0} + \multido{\n=\yCoordOrig+\NumDataPlotdy}{\NumDataPlotBuffer}{ + \yLogSubGrid{\n} + } +% \putS{ +% TicksYLeft: \TicksYLeft +% } +} + + \newcommand{\plotyAxis}[2][]{ \setkeys[NumericDataPlot]{yAxis}{#1} @@ -782,7 +823,9 @@ % plot lower axis \ifthenelse{\boolean{PlotLeftAxis}} { - \psline(\NumDataPlotxCoordMin,\NumDataPlotyCoordMin)(\NumDataPlotxCoordMin, \NumDataPlotyCoordMax) + \psline{C-C}% + (\NumDataPlotxCoordMin,\NumDataPlotyCoordMin)% + (\NumDataPlotxCoordMin, \NumDataPlotyCoordMax) \ifNumericDataPlot@yAxis@NoTickLabel \else \plotyTickLabels{\NumDataPlotxCoordMin}{sub}{r} @@ -790,7 +833,9 @@ % plot upper axis \ifthenelse{\boolean{PlotRightAxis}} { - \psline(\NumDataPlotxCoordMax,\NumDataPlotyCoordMin)(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) + \psline{C-C}% + (\NumDataPlotxCoordMax,\NumDataPlotyCoordMin)% + (\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) }{} % --- label --- \ifNumericDataPlot@yAxis@NoLabel @@ -800,7 +845,9 @@ }{ \ifthenelse{\boolean{PlotRightAxis}} { - \psline(\NumDataPlotxCoordMax,\NumDataPlotyCoordMin)(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) + \psline{C-C}% + (\NumDataPlotxCoordMax,\NumDataPlotyCoordMin)% + (\NumDataPlotxCoordMax, \NumDataPlotyCoordMax) \ifNumericDataPlot@yAxis@NoTickLabel \else \plotyTickLabels{\NumDataPlotxCoordMax}{add}{l} @@ -827,7 +874,7 @@ } \newcommand{\NDPhline}[2][]{ - +% \FPsub{\NumDataPlotBuffer}{#2}{\NumDataPlotyMin} \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotyDataCoordRatio} \FPadd{\NDPputYcoord}{\NumDataPlotBuffer}{\NumDataPlotyCoordMin} @@ -837,17 +884,17 @@ } \newcommand{\NDPvline}[2][]{ - +% \FPsub{\NumDataPlotBuffer}{#2}{\NumDataPlotxMin} \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotxDataCoordRatio} \FPadd{\NDPputXcoord}{\NumDataPlotBuffer}{\NumDataPlotxCoordMin} - +% \psline[#1](\NDPputXcoord, \NumDataPlotyCoordMin) (\NDPputXcoord, \NumDataPlotyCoordMax) } \newcommand{\NDPline}[5][]{ - +% \FPsub{\NumDataPlotBuffer}{#2}{\NumDataPlotxMin} \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotxDataCoordRatio} \FPadd{\NDPputXcoordOne}{\NumDataPlotBuffer}{\NumDataPlotxCoordMin} @@ -858,13 +905,52 @@ \psline[#1] - (!#2 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul + (!#2 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul + \NumDataPlotxCoordMin\space add + #3 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul + \NumDataPlotyCoordMin\space add) + (!#4 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul + \NumDataPlotxCoordMin\space add + #5 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul + \NumDataPlotyCoordMin\space add) +} + +\newcommand{\NDPvbox}[3][]{ + + \psframe[#1] + (!#2 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul \NumDataPlotxCoordMin\space add + \NumDataPlotyCoordMin) + (!#3 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul \NumDataPlotxCoordMin\space add + \NumDataPlotyCoordMax) +} + +\newcommand{\NDPhbox}[3][]{ + + \psframe[#1] + (!\NumDataPlotxCoordMin \space + #2 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul \NumDataPlotyCoordMin\space add) + (!\NumDataPlotxCoordMax \space + #3 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul \NumDataPlotyCoordMin\space add) +} + +\newcommand{\NDPbox}[5][]{ +% \FPsub{\NumDataPlotBuffer}{#2}{\NumDataPlotxMin} +% \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotxDataCoordRatio} +% \FPadd{\NDPputXcoordOne}{\NumDataPlotBuffer}{\NumDataPlotxCoordMin} +% +% \FPsub{\NumDataPlotBuffer}{#2}{\NumDataPlotxMin} +% \FPmul{\NumDataPlotBuffer}{\NumDataPlotBuffer}{\NumDataPlotxDataCoordRatio} +% \FPadd{\NDPputXcoordOne}{\NumDataPlotBuffer}{\NumDataPlotxCoordMin} +% +% + \psframe[#1] + (!#2 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul \NumDataPlotxCoordMin\space add - #3 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul + #3 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul \NumDataPlotyCoordMin\space add) - (!#4 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul + (!#4 \NumDataPlotxMin\space sub \NumDataPlotxDataCoordRatio\space mul \NumDataPlotxCoordMin\space add - #5 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul + #5 \NumDataPlotyMin\space sub \NumDataPlotyDataCoordRatio\space mul \NumDataPlotyCoordMin\space add) } @@ -930,13 +1016,15 @@ \newpsstyle{TickSt}{linecolor=black, linestyle=solid, linewidth=0.5pt} -\definecolor{LineColorA}{cmyk}{1 0.25 0 0} %blue -\definecolor{LineColorB}{cmyk}{1 0 1 0.2} %green +\definecolor{LineColorA}{cmyk}{0.6 0.21 0.0 0.2} %blue +\definecolor{LineColorB}{cmyk}{0.7 0.1 1 0.2} %green \definecolor{LineColorC}{cmyk}{0 1 1 0.2} %red -\definecolor{LineColorD}{cmyk}{0 0.7 1 0} % orange -\definecolor{LineColorE}{cmyk}{0.7 1 0 0} % purple -\definecolor{LineColorF}{cmyk}{1 0 0 0} % light blue -\definecolor{LineColorG}{cmyk}{0 0.25 1 0} % yellow +\definecolor{LineColorD}{cmyk}{0 0.7 1 0.1} % orange +\definecolor{LineColorE}{cmyk}{0.5 1 0 0.1} % purple +\definecolor{LineColorF}{cmyk}{0 1 0 0.2} % magenta +\definecolor{LineColorG}{cmyk}{0 0.25 1 0.1} % yellow +\definecolor{LineColorX}{cmyk}{0.3 0.2 0.0 0.1} %blue +\definecolor{LineColorY}{cmyk}{0 1 1 0.2} %red \newpsstyle{StdLineStyA}{linecolor=LineColorA} \newpsstyle{StdLineStyB}{linecolor=LineColorB} @@ -946,21 +1034,83 @@ \newpsstyle{StdLineStyF}{linecolor=LineColorF} \newpsstyle{StdLineStyG}{linecolor=LineColorG} +\newpsstyle{StdLineStyX}{linecolor=LineColorX,linestyle=solid,linewidth=2pt} +\newpsstyle{StdLineStyY}{linecolor=LineColorY,linestyle=dashed, dash=4pt 3pt 1pt +3pt} +\newpsstyle{BWStdLineStyX}{linecolor=lightgray,linestyle=solid,linewidth=2pt} +\newpsstyle{BWStdLineStyY}{linecolor=black,linestyle=dashed, dash=4pt 3pt 1pt +3pt} + +\newpsstyle{BWStdLineStyA} + {linecolor=lightgray,linestyle=solid,linewidth = 1.5pt} +\newpsstyle{BWStdLineStyB} + {linecolor=gray,linestyle=solid,linewidth = 1.0pt} +\newpsstyle{BWStdLineStyC} + {linecolor=black,linestyle=solid,linewidth = 0.75pt} +\newpsstyle{BWStdLineStyD} + {linecolor=black,linestyle=dashed, dash = 3pt 2pt,linewidth = 0.75pt} +\newpsstyle{BWStdLineStyE} + {linecolor=gray,linestyle=dashed,dash = 3pt 2pt,linewidth = 1.0pt} +\newpsstyle{BWStdLineStyF} + {linecolor=black,linestyle=dotted, dotsep =2pt,linewidth = 1.5pt} +\newpsstyle{BWStdLineStyG} + {linecolor=gray,linestyle=dotted, dotsep =2pt,linewidth = 1.5pt} + +\newpsstyle{LegendBoxStyle} + {fillcolor=white, fillstyle=solid} + +% =========================================================================== +% || +% || commands to put something at a location of the plot +% || +% =========================================================================== + +% put in the NorthWest corner of the plot +\newcommand{\putNW}[1]{ +\rput[lt]{0}(\NumDataPlotxCoordMin, \NumDataPlotyCoordMax){#1}} +% put in the SouthWest corner of the plot +\newcommand{\putSW}[1]{ +\rput[lb]{0}(\NumDataPlotxCoordMin, \NumDataPlotyCoordMin){#1}} +% put in the NorthEast corner of the plot +\newcommand{\putNE}[1]{ +\rput[rt]{0}(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax){#1}} +% put in the SouthEast corner of the plot +\newcommand{\putSE}[1]{ +\rput[rb]{0}(\NumDataPlotxCoordMax, \NumDataPlotyCoordMin){#1}} +% put in the South of the plot +\newcommand{\putS}[1]{ +\rput[b]{0}(!\NumDataPlotxCoordMax\space\NumDataPlotxMin\space sub 2 div +\NumDataPlotxCoordMin\space add \NumDataPlotyCoordMin){#1}} +% put in the North of the plot +\newcommand{\putN}[1]{ +\rput[t]{0}(!\NumDataPlotxCoordMax\space\NumDataPlotxCoordMin\space sub 2 div +\NumDataPlotxCoordMin\space add \NumDataPlotyCoordMax){#1}} +% put in the West of the plot +\newcommand{\putW}[1]{ +\rput[l]{0}(!\NumDataPlotxCoordMin\space +\NumDataPlotyCoordMax\space\NumDataPlotyCoordMin\space sub 2 div \NumDataPlotyCoordMin\space add){#1}} +% put in the East of the plot +\newcommand{\putE}[1]{ +\rput[r]{0}(!\NumDataPlotxCoordMax\space +\NumDataPlotyCoordMax\space\NumDataPlotyCoordMin\space sub 2 div \NumDataPlotyCoordMin\space add){#1}} +% put exponent at y-axis +\newcommand{\putExpY}[1]{ +\rput[lb]{0}(\NumDataPlotxCoordMin, \NumDataPlotyCoordMax){#1} +} +% put exponent at x-axis +\newcommand{\putExpX}[1]{ +\rput[lb]{0}(\NumDataPlotxCoordMax, \NumDataPlotyCoordMin){#1} +} + + \DeclareOptionX{BW}{ - \newpsstyle{StdLineStyA} - {linecolor=lightgray,linestyle=solid,linewidth = 1.5pt} - \newpsstyle{StdLineStyB} - {linecolor=gray,linestyle=solid,linewidth = 1.0pt} - \newpsstyle{StdLineStyC} - {linecolor=black,linestyle=solid,linewidth = 0.75pt} - \newpsstyle{StdLineStyD} - {linecolor=black,linestyle=dashed, dash = 3pt 2pt,linewidth = 0.75pt} - \newpsstyle{StdLineStyE} - {linecolor=gray,linestyle=dashed,dash = 3pt 2pt,linewidth = 1.0pt} - \newpsstyle{StdLineStyF} - {linecolor=black,linestyle=dotted, dotsep =2pt,linewidth = 1.5pt} - \newpsstyle{StdLineStyG} - {linecolor=gray,linestyle=dotted, dotsep =2pt,linewidth = 1.5pt} + \newpsstyle{StdLineStyA}{BWStdLineStyA} + \newpsstyle{StdLineStyB}{BWStdLineStyb} + \newpsstyle{StdLineStyC}{BWStdLineStyC} + \newpsstyle{StdLineStyD}{BWStdLineStyD} + \newpsstyle{StdLineStyE}{BWStdLineStyE} + \newpsstyle{StdLineStyF}{BWStdLineStyF} + \newpsstyle{StdLineStyG}{BWStdLineStyG} } \DeclareOptionX{beamer}{ @@ -995,7 +1145,8 @@ xLog=false, yMax=100, yMin=0, Dy=10, yCoordMax=\NumDataPlotGyPicMax, yCoordMin=\NumDataPlotGyPicMin, - yLog=false, + yLog=false, + yNearlyTight=false, }{} \presetkeys[NumericDataPlot]{xAxis}{ NoGrid=false, NoTicks=false, NoLabel=false, NoTickLabel=false, @@ -1018,37 +1169,3 @@ LabelOrientation=l }{} -% =========================================================================== -% || -% || commands to put something at a location of the plot -% || -% =========================================================================== - -% put in the NorthWest corner of the plot -\newcommand{\putNW}[1]{ -\rput[lt]{0}(\NumDataPlotxCoordMin, \NumDataPlotyCoordMax){#1}} -% put in the SouthWest corner of the plot -\newcommand{\putSW}[1]{ -\rput[lb]{0}(\NumDataPlotxCoordMin, \NumDataPlotyCoordMin){#1}} -% put in the NorthEast corner of the plot -\newcommand{\putNE}[1]{ -\rput[rt]{0}(\NumDataPlotxCoordMax, \NumDataPlotyCoordMax){#1}} -% put in the SouthEast corner of the plot -\newcommand{\putSE}[1]{ -\rput[rb]{0}(\NumDataPlotxCoordMax, \NumDataPlotyCoordMin){#1}} -% put in the South of the plot -\newcommand{\putS}[1]{ -\rput[b]{0}(!\NumDataPlotxCoordMax\space\NumDataPlotxMin\space sub 2 div -\NumDataPlotxCoordMin\space add \NumDataPlotyCoordMin){#1}} -% put in the North of the plot -\newcommand{\putN}[1]{ -\rput[t]{0}(!\NumDataPlotxCoordMax\space\NumDataPlotxCoordMin\space sub 2 div -\NumDataPlotxCoordMin\space add \NumDataPlotyCoordMax){#1}} -% put in the West of the plot -\newcommand{\putW}[1]{ -\rput[l]{0}(!\NumDataPlotxCoordMin\space -\NumDataPlotyCoordMax\space\NumDataPlotyCoordMin\space sub 2 div \NumDataPlotyCoordMin\space add){#1}} -% put in the East of the plot -\newcommand{\putE}[1]{ -\rput[r]{0}(!\NumDataPlotxCoordMax\space -\NumDataPlotyCoordMax\space\NumDataPlotyCoordMin\space sub 2 div \NumDataPlotyCoordMin\space add){#1}} -- cgit v1.2.3