如何在 pgfplot 中做破碎尺度

如何在 pgfplot 中做破碎尺度

我正在尝试使用 tikzpicture 对二维散点图进行破碎比例绘制,但我不知道如何操作。

在此处输入图片描述

编辑:我找到了一种方法来修复损坏的秤。以下是我目前所得到的:

\begin{center}
\begin{tikzpicture}
\begin{axis}[
    axis line style = thick,
    axis lines = middle,
    xmin = 30, xmax = 250,
    ymin = 950, ymax = 1400,
    xtick distance = 50,
    ytick distance = 100,
    axis x discontinuity = crunch,
    axis y discontinuity = crunch,
    grid = both,
    minor tick num = 4,
    major tick style = {thick, black},
    major grid style = {gray},
    minor grid style = {lightgray},
    xlabel = {$x$},
    ylabel = {$y$},
    axis line style={shorten >=-10pt, shorten <=-10pt},
    x label style={anchor=west, at={(ticklabel* cs:1.0)}, xshift=10pt},
    ylabel style={anchor=south, at={(ticklabel* cs:1.0)}, yshift=10pt},    
    width = 0.7\textwidth,
    height = 0.7\textwidth]  

\end{axis}
\end{tikzpicture}
\end{center}

它看起来是这样的: 在此处输入图片描述

现在我想知道是否可以让网格从最小边界开始,即从 50 开始X1000 为,就像我上面的图片一样。

答案1

的默认选项axis x/y discontinuity不提供斜线。但您始终可以手动将东西绘制到轴上。对于您的情况,我可能会先使用axis x/y line shift将轴向外移动的选项:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis line style = thick,
    axis lines = middle,
    xmin = 50, xmax = 250,
    ymin = 1000, ymax = 1400,
    xtick distance = 50,
    ytick distance = 100,
    grid = both,
    axis x line shift=0.75cm,
    axis y line shift=0.75cm,
    minor tick num = 4,
    major tick style = {thick, black},
    major grid style = {gray},
    minor grid style = {lightgray},
    xlabel = {$x$},
    ylabel = {$y$},
    axis line style = {shorten > = -10pt},
    x label style = {anchor = west, at = {(ticklabel* cs:1)}, xshift = 10pt},
    y label style = {anchor = south, at = {(ticklabel* cs:1)}, yshift = 10pt},    
    width = 0.7\textwidth,
    height = 0.7\textwidth,
    clip=false]  

\draw[thick] 
    (xticklabel* cs:0) -- (xticklabel* cs:-0.05) coordinate (x gap right)
    (xticklabel* cs:-0.075) coordinate (x gap left) -- (xticklabel* cs:-0.175);
\draw[thick] 
    (yticklabel* cs:0) -- (yticklabel* cs:-0.05) coordinate (y gap right)
    (yticklabel* cs:-0.075) coordinate (y gap left) -- (yticklabel* cs:-0.175);
\draw[thick] 
    ([shift={(2.5pt,2.5pt)}]x gap right) -- ([shift={(-2.5pt,-2.5pt)}]x gap right)
    ([shift={(2.5pt,2.5pt)}]x gap left) -- ([shift={(-2.5pt,-2.5pt)}]x gap left);
\draw[thick] 
    ([shift={(2.5pt,2.5pt)}]y gap right) -- ([shift={(-2.5pt,-2.5pt)}]y gap right)
    ([shift={(2.5pt,2.5pt)}]y gap left) -- ([shift={(-2.5pt,-2.5pt)}]y gap left);
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述


\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis line style = thick,
    axis lines = middle,
    xmin = 50, xmax = 250,
    ymin = 1000, ymax = 1400,
    xtick distance = 50,
    ytick distance = 100,
    grid = both,
    axis x line shift=0.75cm,
    axis y line shift=0.75cm,
    minor tick num = 4,
    major tick style = {thick, black},
    major grid style = {gray},
    minor grid style = {lightgray},
    xlabel = {$x$},
    ylabel = {$y$},
    axis line style = {shorten > = -10pt},
    x label style = {anchor = west, at = {(ticklabel* cs:1)}, xshift = 10pt},
    y label style = {anchor = south, at = {(ticklabel* cs:1)}, yshift = 10pt},    
    width = 0.7\textwidth,
    height = 0.7\textwidth,
    clip=false]  

\draw[thick, decoration={zigzag}] 
    (xticklabel* cs:0) -- (xticklabel* cs:-0.025) decorate { -- (xticklabel* cs:-0.1) } -- (xticklabel* cs:-0.175);
\draw[thick, decoration={zigzag}] 
    (yticklabel* cs:0) -- (yticklabel* cs:-0.025) decorate { -- (yticklabel* cs:-0.1) } -- (yticklabel* cs:-0.175);
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容