如何在 Latex 中绘制这种复杂的图形?

如何在 Latex 中绘制这种复杂的图形?

我想画一个图表。我不知道怎么画。谁能告诉我怎么做?

答案1

这是我的方法。我尝试使用以下方法获取线条的数据点这个在线工具并使用 Excel 进行潜在拟合以获取函数。然后,我将线条添加到 -plot loglog。对于标签,您可以\draw结合使用(axis cs:x,y)以使用绘图坐标对齐它们。

对数对数图

\documentclass[border=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{
    compat=newest,
    log ticks with fixed point,
}

\begin{document}
    \begin{tikzpicture}
        \begin{loglogaxis}[
            name=plot,
            height=9cm,
            width=16cm,
            xmin=0.001,
            xmax=1000,
            ymin=0.001,
            ymax=100,
            tick style={draw=none},
            grid=both,
            clip=false,
            ]
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{0.1624*\x^0.6348});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{1.4294*\x^0.4895});
            \addplot[
            samples=500,
            domain=0.01:1000,
            ] 
            (\x,{0.5615*\x^0.5189});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{5.7747*\x^0.3595});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{20.062*\x^0.2214});
            
            \draw (axis cs:0.001,100) rectangle node {1} (axis cs:0.01,400);
            \draw (axis cs:0.01,100) rectangle node {2} (axis cs:0.1,400);
            \draw (axis cs:0.1,100) rectangle node {3} (axis cs:1,400);
            \draw (axis cs:1,100) rectangle node {4} (axis cs:4,400);
            \draw (axis cs:4,100) rectangle node {5} (axis cs:10,400);
            \draw (axis cs:10,100) rectangle node {6} (axis cs:40,400);
            \draw (axis cs:40,100) rectangle node {7} (axis cs:100,400);
            \draw (axis cs:100,100) rectangle node {8} (axis cs:400,400);
            \draw (axis cs:400,100) rectangle node {9} (axis cs:1000,400);
            
            \draw (axis cs:40,1) rectangle node {10} (axis cs:400,2);
        \end{loglogaxis}    
    \end{tikzpicture}
\end{document}

编辑

我稍微修改了代码以满足您的需要。

日志日志 v2

\documentclass[border=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{
    compat=newest,
    log ticks with fixed point,
}

\usepackage{contour}

\begin{document}
    \begin{tikzpicture}
        \begin{loglogaxis}[
            name=plot,
            height=10cm,
            width=20cm,
            xmin=0.001,
            xmax=1000,
            ymin=0.001,
            ymax=100,
            tick style={draw=none},
            xticklabel=\empty,
            yticklabel=\empty,
            yticklabel pos=left,
            extra x ticks={0.001,0.002,0.004,0.01,0.02,0.04,0.1,0.2,0.4,1,2,4,10,20,40,100,200,400,1000},
            extra x tick labels={0.001,0.002,0.004,0.01,0.02,0.04,0.1,0.2,0.4,1,2,4,10,20,40,100,200,400,1000},
            extra y ticks={1,2,3,5,10,20,30,50,100},
            extra y tick labels={1,2,3,5,10,20,30,50,100},
            grid=both,
            clip=false,
            ]
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{0.1624*\x^0.6348});
            \addplot[
            samples=500,
            domain=0.01:1000,
            ]
            (\x,{0.5615*\x^0.5189});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{1.4294*\x^0.4895});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{5.7747*\x^0.3595});
            \addplot[
            samples=500,
            domain=0.001:1000,
            ] 
            (\x,{20.062*\x^0.2214});
            
            \foreach \xa/\xb/\lab in {0.001/0.01/Lab1, 0.01/0.1/Lab2, 0.1/1/Lab3, 1/4/Lab4, 4/10/Lab5, 10/40/Lab6, 40/100/Lab7, 100/400/Lab8, 400/1000/Lab9}{%
                \edef\temp{%
                    \noexpand \draw (axis cs:\xa,100) rectangle node {\noexpand\contour{white}{\lab}} (axis cs:\xb,400);
                }\temp
            }
            
            \draw[lightgray] (axis cs:40,1) rectangle node[black] {\contour{white}{Lab10}} (axis cs:400,2);
            
            \foreach \y [count=\i from 1] in {30,40,60,90}{%
                \edef\temp{%
                    \noexpand \node[black,below right,font=\noexpand\tiny] at (axis cs:400,\y) {\noexpand\contour{white}{\i}};
                }\temp
            }
        \end{loglogaxis}
        
        \begin{loglogaxis}[
            height=10cm,
            width=20cm,
            xmin=0.001,
            xmax=1000,
            ymin=0.001,
            ymax=100,
            tick style={draw=none},
            xticklabel=\empty,
            yticklabel=\empty,
            yticklabel pos=right,
            extra y ticks={1,2,3,5,10,20,30,50,100},
            extra y tick labels={1,2,3,5,10,20,30,50,100},
            yticklabel pos=right
            ]
        \end{loglogaxis}    
    \end{tikzpicture}
\end{document}

你的问题:

问题 1 x 轴和 y 轴的数字应该如何增加?我的意思是,在原始图中我有 1、2、3、5、10.....,而实际上我们有 0.01、0.1、1、10、100。我想输入 1、2、3、5、10....我该怎么做?x 轴数字在两边。如何将数字放在两边?

我添加了一些extra y ticksextra tick labels并删除了其他标签。第二个轴可以用虚拟图和来生成ylabel pos=right

第二季度 原始图中斜线之间有数字,我应该如何输入这些数字?

您只需使用 向图表添加带有标签的节点即可添加这些数字(axis cs:x pos,y pos)。我想到了一种循环方法,使用

\foreach \y [count=\i from 1] in {30,40,60,90}{%
                \edef\temp{%
                    \noexpand \node[black,below right,font=\noexpand\tiny] at (axis cs:400,\y) {\noexpand\contour{white}{\i}};
                }\temp
            }

\y是标签的 y 位置,\i是标签。您可以通过复制循环、将 y 值、x 值和命令更改count from为特定数字来更改此设置。

答案2

像您图片中那样完成的基本对数对数轴\pgfplots(按照@Zarko 的建议):

\documentclass[border=1cm]{standalone}

\usepackage{pgfplots}

\pgfplotsset{log ticks with fixed point,}

\begin{document}
    
    \begin{tikzpicture}
        \begin{loglogaxis}[
            xlabel=A,ylabel=K,
            log basis x=10,
            log basis  y = 10,
            xmin=0.001, xmax=1000,
            ymin=0.001, ymax=100,           
            grid=both,
            x post scale=2, %switch this off if you do not want your x axis scaled
            ]

        \end{loglogaxis}
    \end{tikzpicture}
    
\end{document}

在此处输入图片描述

相关内容