| 1 |
% numodel-plot.dtx |
| 2 |
% |
| 3 |
% Docstrip source for numodel-plot.sty. |
| 4 |
% Run |
| 5 |
% tex numodel-plot.ins |
| 6 |
% to extract the derived file. User-facing documentation lives |
| 7 |
% in numodel-plot-manual.tex (a stand-alone LaTeX file). |
| 8 |
% |
| 9 |
% Copyright (C) 2026 Paul Zuurbier <[email protected]> |
| 10 |
% |
| 11 |
% This work may be distributed and/or modified under the conditions |
| 12 |
% of the LaTeX Project Public License, either version 1.3c of this |
| 13 |
% license or (at your option) any later version. The latest version |
| 14 |
% of this license is in https://www.latex-project.org/lppl.txt |
| 15 |
% |
| 16 |
% This work has the LPPL maintenance status 'maintained'. |
| 17 |
% The Current Maintainer of this work is Paul Zuurbier. |
| 18 |
% |
| 19 |
% This work consists of the files numodel-plot.dtx and numodel-plot.ins, |
| 20 |
% and the derived file numodel-plot.sty. |
| 21 |
% \section{Implementation} |
| 22 |
% |
| 23 |
% All internal helper macros use the \texttt{\textbackslash nmp@\ldots} |
| 24 |
% prefix (standard LaTeX internal convention). Because the package |
| 25 |
% may be loaded through |\input| as well as |\usepackage|, an |
| 26 |
% explicit |\makeatletter| wraps the body so that |@| is a letter |
| 27 |
% regardless of caller. |
| 28 |
% |
| 29 |
% \begin{macrocode} |
| 30 |
\NeedsTeXFormat{LaTeX2e} |
| 31 |
\ProvidesPackage{numodel-plot}[2026/05/26 v0.6.0 Auto-sizing PGFPlots engine] |
| 32 |
|
| 33 |
\makeatletter |
| 34 |
|
| 35 |
\RequirePackage{expl3} |
| 36 |
\RequirePackage{xparse} |
| 37 |
\RequirePackage{l3keys2e} |
| 38 |
\RequirePackage{siunitx} |
| 39 |
\RequirePackage{pgfplots} |
| 40 |
\usepgfplotslibrary{fillbetween} |
| 41 |
|
| 42 |
\pgfplotsset{ |
| 43 |
compat=1.18, |
| 44 |
numodel/grid/.style={ |
| 45 |
grid=both, |
| 46 |
grid style={ |
| 47 |
line width=0.5pt, |
| 48 |
draw=black, |
| 49 |
line cap=round, |
| 50 |
dash pattern=on 0pt off 1mm |
| 51 |
}, |
| 52 |
major grid style={ |
| 53 |
line width=0.5pt, |
| 54 |
draw=black, |
| 55 |
line cap=round, |
| 56 |
dash pattern=on 0pt off 1mm} |
| 57 |
}, |
| 58 |
numodel/ticks/.style={ |
| 59 |
tick style={black} |
| 60 |
}, |
| 61 |
numodel/axis/.style={ |
| 62 |
xticklabel style={/pgf/number format/.cd, fixed, precision=6, fixed zerofill=false, use comma, 1000 sep={\,}, /tikz/.cd, text depth=0.3ex}, |
| 63 |
yticklabel style={/pgf/number format/.cd, fixed, precision=6, fixed zerofill=false, use comma, 1000 sep={\,}, /tikz/.cd, text depth=0.3ex}, |
| 64 |
axis lines=left, |
| 65 |
xlabel near ticks, |
| 66 |
ylabel near ticks, |
| 67 |
ylabel style={rotate=-90}, |
| 68 |
axis line style={-} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
\ExplSyntaxOn |
| 73 |
|
| 74 |
\tl_new:N \g__numodelplot_axislabel_tl |
| 75 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {ieee} |
| 76 |
|
| 77 |
\providecommand{\xcmmax}{12} |
| 78 |
\providecommand{\ycmmax}{10} |
| 79 |
|
| 80 |
\keys_define:nn { numodel-plot } |
| 81 |
{ |
| 82 |
axis-label-format .choice:, |
| 83 |
axis-label-format / iso .code:n = |
| 84 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {iso}, |
| 85 |
axis-label-format / ieee .code:n = |
| 86 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {ieee}, |
| 87 |
axis-label-format / brackets .code:n = |
| 88 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {brackets}, |
| 89 |
axis-label-format / qty-only .code:n = |
| 90 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {qty-only}, |
| 91 |
axis-label-format / unit-only .code:n = |
| 92 |
\tl_gset:Nn \g__numodelplot_axislabel_tl {unit-only}, |
| 93 |
|
| 94 |
grid .choice:, |
| 95 |
grid / mm-dots .code:n = |
| 96 |
\pgfplotsset{ numodel/grid/.style={ |
| 97 |
grid=both, |
| 98 |
grid~style={line~width=0.5pt, draw=black, line~cap=round, |
| 99 |
dash~pattern=on~0pt~off~1mm}, |
| 100 |
major~grid~style={line~width=0.5pt, draw=black, line~cap=round, |
| 101 |
dash~pattern=on~0pt~off~1mm} |
| 102 |
} }, |
| 103 |
grid / none .code:n = |
| 104 |
\pgfplotsset{ numodel/grid/.style={grid=none} }, |
| 105 |
grid / unknown .code:n = |
| 106 |
\pgfplotsset{ numodel/grid/.style={#1} }, |
| 107 |
|
| 108 |
xcmmax .code:n = \def\xcmmax{#1}, |
| 109 |
ycmmax .code:n = \def\ycmmax{#1}, |
| 110 |
} |
| 111 |
|
| 112 |
\NewDocumentCommand{\numodelplotsetup}{m} |
| 113 |
{ \keys_set:nn { numodel-plot } {#1} } |
| 114 |
|
| 115 |
\ExplSyntaxOff |
| 116 |
|
| 117 |
\ExplSyntaxOn |
| 118 |
\bool_new:N \g__pzu_suppress_qp_bool |
| 119 |
\cs_new_eq:NN \__pzu_orig_int_output:nnn \__siunitx_number_output_integer:nnn |
| 120 |
\cs_new_eq:NN \__pzu_orig_qty_print_unit:n \__siunitx_quantity_print_unit:n |
| 121 |
\NewDocumentCommand{\qtyPlain}{O{} m m}{% |
| 122 |
\group_begin: |
| 123 |
\bool_gset_false:N \g__pzu_suppress_qp_bool |
| 124 |
\cs_set:Npn \__siunitx_number_output_integer:nnn ##1##2##3 { |
| 125 |
\bool_lazy_all:nTF |
| 126 |
{ |
| 127 |
{ \str_if_eq_p:nn { ##1 . ##2 } { 1. } } |
| 128 |
{ \str_if_eq_p:nn {##3} { 0 } } |
| 129 |
{ ! \l__siunitx_number_zero_exponent_bool } |
| 130 |
{ ! \l__siunitx_number_unity_mantissa_bool } |
| 131 |
} |
| 132 |
{ \bool_gset_true:N \g__pzu_suppress_qp_bool } |
| 133 |
{ \__pzu_orig_int_output:nnn {##1} {##2} {##3} } |
| 134 |
} |
| 135 |
\cs_set_protected:Npn \__siunitx_quantity_print_unit:n ##1 { |
| 136 |
\bool_if:NTF \l__siunitx_quantity_break_bool |
| 137 |
{ \penalty \binoppenalty } |
| 138 |
{ \nobreak } |
| 139 |
\bool_if:NF \g__pzu_suppress_qp_bool |
| 140 |
{ \tl_use:N \l__siunitx_quantity_product_tl } |
| 141 |
\siunitx_print_unit:n {##1} |
| 142 |
} |
| 143 |
\qty[#1]{#2}{#3}% |
| 144 |
\group_end: |
| 145 |
} |
| 146 |
\ExplSyntaxOff |
| 147 |
|
| 148 |
\ExplSyntaxOn |
| 149 |
\bool_new:N \l__pzu_noneng_bool |
| 150 |
\tl_const:Nn \c__pzu_noneng_tokens_tl { |
| 151 |
\centi \deci \deca \hecto |
| 152 |
\cm \cg \cL |
| 153 |
\dm \dg \dL |
| 154 |
\dam \dag \daL |
| 155 |
\hm \hg \hL \hPa |
| 156 |
} |
| 157 |
\prg_new_protected_conditional:Npnn \__pzu_unit_has_noneng:n #1 { TF } { |
| 158 |
\bool_set_false:N \l__pzu_noneng_bool |
| 159 |
\tl_map_inline:Nn \c__pzu_noneng_tokens_tl { |
| 160 |
\tl_if_in:nnT {#1} {##1} |
| 161 |
{ \bool_set_true:N \l__pzu_noneng_bool \tl_map_break: } |
| 162 |
} |
| 163 |
\bool_if:NTF \l__pzu_noneng_bool |
| 164 |
{ \prg_return_true: } |
| 165 |
{ \prg_return_false: } |
| 166 |
} |
| 167 |
\prg_generate_conditional_variant:Nnn \__pzu_unit_has_noneng:n { o } { TF } |
| 168 |
\NewDocumentCommand{\pzuIfUnitNonEngTF}{m m m}{% |
| 169 |
\__pzu_unit_has_noneng:oTF {#1} {#2} {#3}% |
| 170 |
} |
| 171 |
\ExplSyntaxOff |
| 172 |
|
| 173 |
\ExplSyntaxOn |
| 174 |
|
| 175 |
\cs_new_protected:Npn \__numodelplot_xlabel_emit_unscaled: |
| 176 |
{ |
| 177 |
\str_case:Vn \g__numodelplot_axislabel_tl |
| 178 |
{ |
| 179 |
{iso} |
| 180 |
{ \def \xlabel { $\nmp@savedxlabelqty \, /\, ( \si{\nmp@savedxlabelunit} )$ } } |
| 181 |
{ieee} |
| 182 |
{ \def \xlabel { $\nmp@savedxlabelqty \,( \si{\nmp@savedxlabelunit} )$ } } |
| 183 |
{brackets} |
| 184 |
{ \def \xlabel { $\nmp@savedxlabelqty \,[ \si{\nmp@savedxlabelunit} ]$ } } |
| 185 |
{qty-only} |
| 186 |
{ \def \xlabel { $\nmp@savedxlabelqty$ } } |
| 187 |
{unit-only} |
| 188 |
{ \def \xlabel { $\si{\nmp@savedxlabelunit}$ } } |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
\cs_new_protected:Npn \__numodelplot_xlabel_emit_scaled: |
| 193 |
{ |
| 194 |
\str_case:Vn \g__numodelplot_axislabel_tl |
| 195 |
{ |
| 196 |
{iso} |
| 197 |
{ |
| 198 |
\edef\xlabel{\noexpand$\noexpand\nmp@savedxlabelqty |
| 199 |
\noexpand\,/\noexpand\,(\noexpand\qtyPlain |
| 200 |
[evaluate-expression=false, round-mode=none, |
| 201 |
prefix-mode=extract-exponent, |
| 202 |
extract-mass-in-kilograms=true, |
| 203 |
print-zero-exponent=false, |
| 204 |
print-unity-mantissa=false]% |
| 205 |
{1e\nmp@xlabelexpuse}{\noexpand\nmp@savedxlabelunit})\noexpand$}% |
| 206 |
} |
| 207 |
{ieee} |
| 208 |
{ |
| 209 |
\edef\xlabel{\noexpand$\noexpand\nmp@savedxlabelqty |
| 210 |
\noexpand\,(\noexpand\qtyPlain |
| 211 |
[evaluate-expression=false, round-mode=none, |
| 212 |
prefix-mode=extract-exponent, |
| 213 |
extract-mass-in-kilograms=true, |
| 214 |
print-zero-exponent=false, |
| 215 |
print-unity-mantissa=false]% |
| 216 |
{1e\nmp@xlabelexpuse}{\noexpand\nmp@savedxlabelunit})\noexpand$}% |
| 217 |
} |
| 218 |
{brackets} |
| 219 |
{ |
| 220 |
\edef\xlabel{\noexpand$\noexpand\nmp@savedxlabelqty |
| 221 |
\noexpand\,[\noexpand\qtyPlain |
| 222 |
[evaluate-expression=false, round-mode=none, |
| 223 |
prefix-mode=extract-exponent, |
| 224 |
extract-mass-in-kilograms=true, |
| 225 |
print-zero-exponent=false, |
| 226 |
print-unity-mantissa=false]% |
| 227 |
{1e\nmp@xlabelexpuse}{\noexpand\nmp@savedxlabelunit}]\noexpand$}% |
| 228 |
} |
| 229 |
{qty-only} |
| 230 |
{ \def \xlabel { $\nmp@savedxlabelqty$ } } |
| 231 |
{unit-only} |
| 232 |
{ |
| 233 |
\edef\xlabel{\noexpand$\noexpand\qtyPlain |
| 234 |
[evaluate-expression=false, round-mode=none, |
| 235 |
prefix-mode=extract-exponent, |
| 236 |
extract-mass-in-kilograms=true, |
| 237 |
print-zero-exponent=false, |
| 238 |
print-unity-mantissa=false]% |
| 239 |
{1e\nmp@xlabelexpuse}{\noexpand\nmp@savedxlabelunit}\noexpand$}% |
| 240 |
} |
| 241 |
} |
| 242 |
} |
| 243 |
|
| 244 |
\cs_new_protected:Npn \__numodelplot_ylabel_emit_unscaled: |
| 245 |
{ |
| 246 |
\str_case:Vn \g__numodelplot_axislabel_tl |
| 247 |
{ |
| 248 |
{iso} |
| 249 |
{ \def \ylabel { $\nmp@savedylabelqty \, /\, ( \si{\nmp@savedylabelunit} )$ } } |
| 250 |
{ieee} |
| 251 |
{ \def \ylabel { $\nmp@savedylabelqty \,( \si{\nmp@savedylabelunit} )$ } } |
| 252 |
{brackets} |
| 253 |
{ \def \ylabel { $\nmp@savedylabelqty \,[ \si{\nmp@savedylabelunit} ]$ } } |
| 254 |
{qty-only} |
| 255 |
{ \def \ylabel { $\nmp@savedylabelqty$ } } |
| 256 |
{unit-only} |
| 257 |
{ \def \ylabel { $\si{\nmp@savedylabelunit}$ } } |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
\cs_new_protected:Npn \__numodelplot_ylabel_emit_scaled: |
| 262 |
{ |
| 263 |
\str_case:Vn \g__numodelplot_axislabel_tl |
| 264 |
{ |
| 265 |
{iso} |
| 266 |
{ |
| 267 |
\edef\ylabel{\noexpand$\noexpand\nmp@savedylabelqty |
| 268 |
\noexpand\,/\noexpand\,(\noexpand\qtyPlain |
| 269 |
[evaluate-expression=false, round-mode=none, |
| 270 |
prefix-mode=extract-exponent, |
| 271 |
extract-mass-in-kilograms=true, |
| 272 |
print-zero-exponent=false, |
| 273 |
print-unity-mantissa=false]% |
| 274 |
{1e\nmp@ylabelexpuse}{\noexpand\nmp@savedylabelunit})\noexpand$}% |
| 275 |
} |
| 276 |
{ieee} |
| 277 |
{ |
| 278 |
\edef\ylabel{\noexpand$\noexpand\nmp@savedylabelqty |
| 279 |
\noexpand\,(\noexpand\qtyPlain |
| 280 |
[evaluate-expression=false, round-mode=none, |
| 281 |
prefix-mode=extract-exponent, |
| 282 |
extract-mass-in-kilograms=true, |
| 283 |
print-zero-exponent=false, |
| 284 |
print-unity-mantissa=false]% |
| 285 |
{1e\nmp@ylabelexpuse}{\noexpand\nmp@savedylabelunit})\noexpand$}% |
| 286 |
} |
| 287 |
{brackets} |
| 288 |
{ |
| 289 |
\edef\ylabel{\noexpand$\noexpand\nmp@savedylabelqty |
| 290 |
\noexpand\,[\noexpand\qtyPlain |
| 291 |
[evaluate-expression=false, round-mode=none, |
| 292 |
prefix-mode=extract-exponent, |
| 293 |
extract-mass-in-kilograms=true, |
| 294 |
print-zero-exponent=false, |
| 295 |
print-unity-mantissa=false]% |
| 296 |
{1e\nmp@ylabelexpuse}{\noexpand\nmp@savedylabelunit}]\noexpand$}% |
| 297 |
} |
| 298 |
{qty-only} |
| 299 |
{ \def \ylabel { $\nmp@savedylabelqty$ } } |
| 300 |
{unit-only} |
| 301 |
{ |
| 302 |
\edef\ylabel{\noexpand$\noexpand\qtyPlain |
| 303 |
[evaluate-expression=false, round-mode=none, |
| 304 |
prefix-mode=extract-exponent, |
| 305 |
extract-mass-in-kilograms=true, |
| 306 |
print-zero-exponent=false, |
| 307 |
print-unity-mantissa=false]% |
| 308 |
{1e\nmp@ylabelexpuse}{\noexpand\nmp@savedylabelunit}\noexpand$}% |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
\ExplSyntaxOff |
| 314 |
|
| 315 |
\newcommand{\pznmpAppendXScaleTicks}[1]{% |
| 316 |
\pgfplotsset{numodel/axis/.append style={scaled x ticks=base 10:#1}}% |
| 317 |
} |
| 318 |
\newcommand{\pznmpAppendYScaleTicks}[1]{% |
| 319 |
\pgfplotsset{numodel/axis/.append style={scaled y ticks=base 10:#1}}% |
| 320 |
} |
| 321 |
\newcommand{\pznmpSuppressXScaleLabel}{% |
| 322 |
\pgfplotsset{numodel/axis/.append style={every x tick scale label/.style={opacity=0, inner sep=0pt, at={(0,0)}}}}% |
| 323 |
} |
| 324 |
\newcommand{\pznmpSuppressYScaleLabel}{% |
| 325 |
\pgfplotsset{numodel/axis/.append style={every y tick scale label/.style={opacity=0, inner sep=0pt, at={(0,0)}}}}% |
| 326 |
} |
| 327 |
|
| 328 |
\ExplSyntaxOn |
| 329 |
|
| 330 |
\cs_new_protected:Npn \__numodelplot_suppress_xscale_label: |
| 331 |
{ |
| 332 |
\str_if_eq:VnF \g__numodelplot_axislabel_tl {qty-only} |
| 333 |
{ \pznmpSuppressXScaleLabel } |
| 334 |
} |
| 335 |
\cs_new_protected:Npn \__numodelplot_suppress_yscale_label: |
| 336 |
{ |
| 337 |
\str_if_eq:VnF \g__numodelplot_axislabel_tl {qty-only} |
| 338 |
{ \pznmpSuppressYScaleLabel } |
| 339 |
} |
| 340 |
|
| 341 |
\ExplSyntaxOff |
| 342 |
|
| 343 |
\ExplSyntaxOn |
| 344 |
\NewDocumentCommand{\xlabelbuild}{}{ |
| 345 |
\let\nmp@savedxlabelqty\xlabelqty |
| 346 |
\let\nmp@savedxlabelunit\xlabelunit |
| 347 |
\pzuIfUnitNonEngTF{\xlabelunit}{ |
| 348 |
\__numodelplot_xlabel_emit_unscaled: |
| 349 |
\def\nmp@xlabelexp{0} |
| 350 |
}{ |
| 351 |
\edef\nmp@xmag{\fpeval{max(abs(\xmin),abs(\xmax))}} |
| 352 |
\edef\nmp@xlabelexp{\fpeval{ |
| 353 |
\nmp@xmag > 0 ? 3*floor(ln(\nmp@xmag)/ln(10)/3) : 0 |
| 354 |
}} |
| 355 |
\ifnum\nmp@xlabelexp=0\relax |
| 356 |
\__numodelplot_xlabel_emit_unscaled: |
| 357 |
\else |
| 358 |
\edef\nmp@xlabelexpuse{\nmp@xlabelexp} |
| 359 |
\__numodelplot_xlabel_emit_scaled: |
| 360 |
\edef\nmp@xlabelexpneg{\fpeval{-\nmp@xlabelexp}} |
| 361 |
\pznmpAppendXScaleTicks{\nmp@xlabelexpneg} |
| 362 |
\__numodelplot_suppress_xscale_label: |
| 363 |
\fi |
| 364 |
} |
| 365 |
\global\let\xlabelqty\undefined |
| 366 |
\global\let\xlabelunit\undefined |
| 367 |
} |
| 368 |
|
| 369 |
\NewDocumentCommand{\ylabelbuild}{}{ |
| 370 |
\let\nmp@savedylabelqty\ylabelqty |
| 371 |
\let\nmp@savedylabelunit\ylabelunit |
| 372 |
\pzuIfUnitNonEngTF{\ylabelunit}{ |
| 373 |
\__numodelplot_ylabel_emit_unscaled: |
| 374 |
\def\nmp@ylabelexp{0} |
| 375 |
}{ |
| 376 |
\edef\nmp@ymag{\fpeval{max(abs(\ymin),abs(\ymax))}} |
| 377 |
\edef\nmp@ylabelexp{\fpeval{ |
| 378 |
\nmp@ymag > 0 ? 3*floor(ln(\nmp@ymag)/ln(10)/3) : 0 |
| 379 |
}} |
| 380 |
\ifnum\nmp@ylabelexp=0\relax |
| 381 |
\__numodelplot_ylabel_emit_unscaled: |
| 382 |
\else |
| 383 |
\edef\nmp@ylabelexpuse{\nmp@ylabelexp} |
| 384 |
\__numodelplot_ylabel_emit_scaled: |
| 385 |
\edef\nmp@ylabelexpneg{\fpeval{-\nmp@ylabelexp}} |
| 386 |
\pznmpAppendYScaleTicks{\nmp@ylabelexpneg} |
| 387 |
\__numodelplot_suppress_yscale_label: |
| 388 |
\fi |
| 389 |
} |
| 390 |
\global\let\ylabelqty\undefined |
| 391 |
\global\let\ylabelunit\undefined |
| 392 |
} |
| 393 |
\ExplSyntaxOff |
| 394 |
|
| 395 |
\newcommand{\calcplotdims}{% |
| 396 |
\edef\nmp@xlog{\fpeval{floor(ln(\xmax-\xmin)/ln(10))}}% |
| 397 |
\edef\nmp@ylog{\fpeval{floor(ln(\ymax-\ymin)/ln(10))}}% |
| 398 |
\edef\nmp@xS{\fpeval{(\xmax-\xmin) / (10^\nmp@xlog)}}% |
| 399 |
\edef\nmp@yS{\fpeval{(\ymax-\ymin) / (10^\nmp@ylog)}}% |
| 400 |
\edef\xcm{\fpeval{% |
| 401 |
\nmp@xS <= \xcmmax/10 ? 10 * \nmp@xS :% |
| 402 |
\nmp@xS <= \xcmmax/5 ? 5 * \nmp@xS :% |
| 403 |
\nmp@xS <= \xcmmax/4 ? 4 * \nmp@xS :% |
| 404 |
\nmp@xS <= \xcmmax/2 ? 2 * \nmp@xS :% |
| 405 |
\nmp@xS <= \xcmmax ? \nmp@xS :% |
| 406 |
\nmp@xS / 2% |
| 407 |
}}% |
| 408 |
\edef\ycm{\fpeval{% |
| 409 |
\nmp@yS <= \ycmmax/10 ? 10 * \nmp@yS :% |
| 410 |
\nmp@yS <= \ycmmax/5 ? 5 * \nmp@yS :% |
| 411 |
\nmp@yS <= \ycmmax/4 ? 4 * \nmp@yS :% |
| 412 |
\nmp@yS <= \ycmmax/2 ? 2 * \nmp@yS :% |
| 413 |
\nmp@yS <= \ycmmax ? \nmp@yS :% |
| 414 |
\nmp@yS / 2% |
| 415 |
}}% |
| 416 |
\edef\nmp@xtickdiv{\fpeval{\nmp@xS / \xcm}}% |
| 417 |
\edef\nmp@ytickdiv{\fpeval{\nmp@yS / \ycm}}% |
| 418 |
\edef\xtickdistance{\fpeval{\nmp@xtickdiv * 10^\nmp@xlog}}% |
| 419 |
\edef\ytickdistance{\fpeval{\nmp@ytickdiv * 10^\nmp@ylog}}% |
| 420 |
\edef\xmax{\fpeval{ceil(\xmax / \xtickdistance) * \xtickdistance}}% |
| 421 |
\edef\ymax{\fpeval{ceil(\ymax / \ytickdistance) * \ytickdistance}}% |
| 422 |
\edef\xmin{\fpeval{floor(\xmin / \xtickdistance) * \xtickdistance}}% |
| 423 |
\edef\ymin{\fpeval{floor(\ymin / \ytickdistance) * \ytickdistance}}% |
| 424 |
\edef\xcm{\fpeval{(\xmax - \xmin) / \xtickdistance}}% |
| 425 |
\edef\ycm{\fpeval{(\ymax - \ymin) / \ytickdistance}}% |
| 426 |
\edef\nmp@yStraddles{\fpeval{(\ymin<0 && \ymax>0) ? 1 : 0}}% |
| 427 |
\edef\nmp@yAllNonPos{\fpeval{\ymax<=0 ? 1 : 0}}% |
| 428 |
\edef\nmp@xStraddles{\fpeval{(\xmin<0 && \xmax>0) ? 1 : 0}}% |
| 429 |
\edef\nmp@xAllNonPos{\fpeval{\xmax<=0 ? 1 : 0}}% |
| 430 |
\ifnum\nmp@yStraddles=1 |
| 431 |
\pgfplotsset{numodel/axis/.append style={axis x line*=middle}}% |
| 432 |
\else |
| 433 |
\ifnum\nmp@yAllNonPos=1 |
| 434 |
\pgfplotsset{numodel/axis/.append style={axis x line*=top}}% |
| 435 |
\fi |
| 436 |
\fi |
| 437 |
\ifnum\nmp@xStraddles=1 |
| 438 |
\pgfplotsset{numodel/axis/.append style={axis y line*=middle}}% |
| 439 |
\else |
| 440 |
\ifnum\nmp@xAllNonPos=1 |
| 441 |
\pgfplotsset{numodel/axis/.append style={axis y line*=right}}% |
| 442 |
\fi |
| 443 |
\fi |
| 444 |
\edef\nmp@axisMoved{\fpeval{(\nmp@yStraddles || \nmp@yAllNonPos || \nmp@xStraddles || \nmp@xAllNonPos) ? 1 : 0}}% |
| 445 |
\ifnum\nmp@axisMoved=1 |
| 446 |
\pgfplotsset{numodel/axis/.append style={% |
| 447 |
every x tick scale label/.style={at={(xticklabel cs:1.05)}, anchor=south west},% |
| 448 |
every y tick scale label/.style={at={(yticklabel cs:1.05)}, anchor=south east}% |
| 449 |
}}% |
| 450 |
\fi |
| 451 |
\edef\nmp@fourQuad{\fpeval{(\nmp@xStraddles && \nmp@yStraddles) ? 1 : 0}}% |
| 452 |
\ifnum\nmp@fourQuad=1 |
| 453 |
\pgfplotsset{numodel/axis/.append style={% |
| 454 |
xlabel style={at={(xticklabel cs:1.05)}, anchor=west},% |
| 455 |
ylabel style={at={(yticklabel cs:1.05)}, anchor=south, rotate=0}% |
| 456 |
}}% |
| 457 |
\fi |
| 458 |
\edef\nmp@qIandII{\fpeval{(\nmp@xStraddles && \ymin>=0) ? 1 : 0}}% |
| 459 |
\ifnum\nmp@qIandII=1 |
| 460 |
\pgfplotsset{numodel/axis/.append style={% |
| 461 |
ylabel style={at={(yticklabel cs:1.05)}, anchor=south, rotate=0}% |
| 462 |
}}% |
| 463 |
\fi |
| 464 |
\edef\nmp@qIIandIII{\fpeval{(\nmp@yStraddles && \nmp@xAllNonPos) ? 1 : 0}}% |
| 465 |
\ifnum\nmp@qIIandIII=1 |
| 466 |
\pgfplotsset{numodel/axis/.append style={% |
| 467 |
xlabel style={at={(xticklabel cs:-0.05)}, anchor=east}% |
| 468 |
}}% |
| 469 |
\fi |
| 470 |
\edef\nmp@qIIIandIV{\fpeval{(\nmp@xStraddles && \nmp@yAllNonPos) ? 1 : 0}}% |
| 471 |
\ifnum\nmp@qIIIandIV=1 |
| 472 |
\pgfplotsset{numodel/axis/.append style={% |
| 473 |
ylabel style={at={(yticklabel cs:-0.05)}, anchor=north, rotate=0}% |
| 474 |
}}% |
| 475 |
\fi |
| 476 |
\edef\nmp@qIVandI{\fpeval{(\nmp@yStraddles && \xmin>=0) ? 1 : 0}}% |
| 477 |
\ifnum\nmp@qIVandI=1 |
| 478 |
\pgfplotsset{numodel/axis/.append style={% |
| 479 |
xlabel style={at={(xticklabel cs:1.05)}, anchor=west}% |
| 480 |
}}% |
| 481 |
\fi |
| 482 |
\ifdefined\xlabelqty\ifdefined\xlabelunit\xlabelbuild\fi\fi |
| 483 |
\ifdefined\ylabelqty\ifdefined\ylabelunit\ylabelbuild\fi\fi |
| 484 |
} |
| 485 |
|
| 486 |
\newcommand{\drawplot}[1]{ |
| 487 |
\calcplotdims |
| 488 |
\begin{tikzpicture} |
| 489 |
\begin{axis}[ |
| 490 |
numodel/grid, |
| 491 |
numodel/ticks, |
| 492 |
numodel/axis, |
| 493 |
xlabel=\xlabel, |
| 494 |
ylabel=\ylabel, |
| 495 |
xmin=\xmin, xmax=\xmax, |
| 496 |
ymin=\ymin, ymax=\ymax, |
| 497 |
xtick distance=\xtickdistance, |
| 498 |
ytick distance=\ytickdistance, |
| 499 |
width=\xcm cm, |
| 500 |
height=\ycm cm, |
| 501 |
scale only axis |
| 502 |
] |
| 503 |
#1 |
| 504 |
\end{axis} |
| 505 |
\end{tikzpicture} |
| 506 |
} |
| 507 |
|
| 508 |
\makeatother |
| 509 |
% \end{macrocode} |
| 510 |
% |
| 511 |
% \Finale |
| 512 |
\endinput |