答案1
將以下行加入序言中:
\usepackage{pgfplots}
\usetikzlibrary{math}
\tikzmath{
function asinhinv(\x,\a){
\xa = \x / \a ;
return \a * ln(\xa + sqrt(\xa*\xa + 1)) ;
};
function asinh(\y,\a){
return \a * sinh(\y/\a) ;
};
}
\pgfplotsset{
ymode asinh/.style = {
y coord trafo/.code={\pgfmathparse{asinhinv(##1,#1)}},
y coord inv trafo/.code={\pgfmathparse{asinh(##1,#1)}},
},
ymode asinh/.default = 1
}
若要啟動該模式asinh
,請新增金鑰ymode asinh
(沒有 =
之間)到環境的選項axis
。此鍵將縮放因子作為可選參數,預設值為1
。如果您替換ymode asinh
為 ,ymode asinh=2
周圍的值y=0
會更接近。
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{math}
\tikzmath{
function asinhinv(\x,\a){
\xa = \x / \a ;
return \a * ln(\xa + sqrt(\xa*\xa + 1)) ;
};
function asinh(\y,\a){
return \a * sinh(\y/\a) ;
};
}
\pgfplotsset{
ymode asinh/.style = {
y coord trafo/.code={\pgfmathparse{asinhinv(##1,#1)}},
y coord inv trafo/.code={\pgfmathparse{asinh(##1,#1)}},
},
ymode asinh/.default = 1
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymode asinh,
height=12cm,
legend pos=north west,
scaled ticks = base 10:0,
domain = -5:5.5,
ytick = {-100,-10, -1,0,1,10,100},
minor ytick = {-90,-80,...,-20,-9,-8,...,-2,-.9,-.8,...,.9,2,3,...,9,20,30,...,90},
yticklabel style={/pgf/number format/.cd,int detect,precision=0},
tick label style = {fill=white, fill opacity=.7},
yminorgrids = true,
ymajorgrids = true,
xmajorgrids = true,
samples=200,
axis lines=center,
]
\addplot+ [mark=none] {x} ;
\addplot+ [mark=none] {exp(x)} ;
\addplot+ [mark=none] {-exp(-x)} ;
\legend {$x$,$e^x$,$-e^{-x}$}
\end{axis}
\end{tikzpicture}
\end{document}
資料來源:我從答案開始Symlog 作為 PGFPlots 中的軸縮放。