Nice page you mention, but i search for an general solution. Arbitrary waveform data in, and axes in si. But now i have an solution:
Code: Select all
\documentclass[
fontsize=12pt,
DIV=14
]{scrreprt}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage[binary-units=true, detect-all]{siunitx}[=v2]
% some pgf settings
\pgfplotsset{compat=1.17}
\pgfplotsset{
grid style={dotted,gray},
major grid style={dashed,gray},
every axis plot/.append style={line width=1.25pt}
}
% Compute e^x
\newcommand{\fpuexp}[1]{\pgfkeys{/pgf/fpu=true, /pgf/fpu/output format=fixed}\pgfmathparse{pow(2.718281828,#1)}\pgfkeys{/pgf/fpu=false}\let\fpuexpresult\pgfmathresult}
% settings for siunitx v2
% http://www.nagel-net.de/Latex/DOKU/siunitx.pdf
% https://latex.org/forum/viewtopic.php?f=45&t=34710
\DeclareSIUnit{\noop}{\relax}
\newcommand{\siSetLogAxes}{\fpuexp{\tick}\SI[round-mode=places,exponent-to-prefix=true,scientific-notation=engineering,zero-decimal-to-integer=true,round-precision=0]{\fpuexpresult}{\noop}}
\newcommand{\siSetLinAxes}{\SI[round-mode=figures,exponent-to-prefix=true,scientific-notation=engineering,zero-decimal-to-integer=true,round-precision=2]{\tick}{\noop}}
% setup pgfplots environment
\pgfplotsset{%
% prepare for convert
scaled ticks=false,
log ticks with fixed point,
% x-lin, y-lin
every linear axis/.append style={xticklabel=\siSetLinAxes},
every linear axis/.append style={yticklabel=\siSetLinAxes},
% x-lin, y-log
every semilogy axis/.append style={xticklabel=\siSetLinAxes},
every semilogy axis/.append style={yticklabel=\siSetLogAxes},
% x-log, y-lin
every semilogx axis/.append style={xticklabel={\siSetLogAxes}},
every semilogx axis/.append style={yticklabel = {\siSetLinAxes}},
% x-log, y-log
every log axis/.append style={xticklabel={\siSetLogAxes}},
every log axis/.append style={yticklabel={\siSetLogAxes}}
}
% Start Document
\begin{document}
\begin{figure}[!htp]
\begin{tikzpicture}
\begin{semilogxaxis}[%
width = \textwidth,
grid = both,
legend style = {at={(0.05,0.95)}, anchor=north west, font=\scriptsize},
filter discard warning = false,
ylabel = {Y-Label},
xlabel = {X-Label},
no markers
]
% Dataset
\addplot table {
1e-3 -100000
1e-1 1
2e1 100000
50e3 200000
};
\addlegendentry{Dataset}
\end{semilogxaxis}
\end{tikzpicture}
\end{figure}
\begin{figure}[!htp]
\begin{tikzpicture}
\begin{axis}[%
width = \textwidth,
grid = both,
legend style = {at={(0.05,0.95)}, anchor=north west, font=\scriptsize},
filter discard warning = false,
ylabel = {Y-Label},
xlabel = {X-Label},
no markers
]
% Dataset
\addplot table {
10000 1
20000 2
30000 3
40000 4
};
\addlegendentry{Dataset}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}