图表不同部分的坐标轴上有不同的刻度

图表不同部分的坐标轴上有不同的刻度

如何使图表不同部分的轴具有不同的缩放比例,例如,如图所示。我有一个类似的图表,但我不喜欢由于 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!您可能想尝试一下,semilogxaxisaxis不是对数缩放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}

在此处输入图片描述

相关内容