如何在圖表的不同部分對軸進行不同的縮放,例如,如圖所示。我有一個類似的圖表,但由於 X 座標很小,我不喜歡開始時的點太靠近 Y 軸,我該如何修復它?
\pgfplotsset{compat=newest}
\begin{figure} [H]
\centering
{
\begin{tikzpicture}
\begin{axis}
[ scale only axis, % The height and width argument only apply to the actual axis
height=8cm,
width=15cm,
enlargelimits=true,
axis lines = middle, % привычные оси со стрелочками с пересечением в нуле
% возможные значения: box, left, middle, center, right, none
xlabel = {$f$, кГц}, % подпись оси x
ylabel = {$K(f)$}, % подпись оси y
xlabel style={below right},
ylabel style={above left},
grid=major, % м.б. еще both - и там и там
grid style={dotted, cyan},
]
\addplot coordinates {
(0.02,0.8)
(0.1,0.8)
(0.2,0.75)
(0.5,0.7)
(1,0.6)
(2,0.4)
(5,0.25)
(10,0.15)
(15,0.1)
(20,0.07)
(50,0.034)
(100,0.016)
(200,0.008)
};
\end{axis}
\end{tikzpicture}
}
\caption{График }
\end{figure}
答案1
歡迎來到 TeX.SX!您可能想嘗試semilogxaxis
而不是axis
對數縮放X軸:
\documentclass[border=10pt]{standalone}
\usepackage[T2A]{fontenc}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}[
scale only axis, % The height and width argument only apply to the actual axis
height=8cm,
width=15cm,
axis lines=left, % привычные оси со стрелочками с пересечением в нуле
% возможные значения: box, left, middle, center, right, none
axis line shift=10pt,
xlabel={$f$, кГц}, % подпись оси x
ylabel={$K(f)$}, % подпись оси y
grid=major, % м.б. еще both - и там и там
grid style={dotted, cyan},
log ticks with fixed point,
xtick={0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200},
]
\addplot coordinates {
(0.02,0.8)
(0.1,0.8)
(0.2,0.75)
(0.5,0.7)
(1,0.6)
(2,0.4)
(5,0.25)
(10,0.15)
(15,0.1)
(20,0.07)
(50,0.034)
(100,0.016)
(200,0.008)
};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}