如何缩小间隔之间的 X 轴比例,而不改变图形其余部分的比例

如何缩小间隔之间的 X 轴比例,而不改变图形其余部分的比例

我有一张图表,其 X 轴上的值10-60 和 700-1100 之间有非零价值观,以及60-700 之间为零。我希望能够使 X 轴范围介于 60-700 个值之间这样我就可以让两个峰值更接近,从而能够更好地绘制图表,不改变 X 轴的刻度. 轴刻度X 轴为对数,并在Y轴是线性的. 图表是根据。TXT格式。下面是带有图表的代码。

\begin{tikzpicture}[trim axis left]
\begin{semilogxaxis}[
             height=3.5cm, 
             width=16cm,
             scale only axis, % makes the internal area of graph equals to= height x widthxmin=1,
             xmin=5,
             xmax=4000,
             ymin=0,
             ymax={1.1},
             axis x line=bottom,
             axis y line=left,
             yticklabel={\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%},
             legend entries={ {CA-LH$_{phy}$} ,{CA-ER$_{phy}$}, {CA-ERLH$_{phy}$},{CA-LH$_{chem}$},{CA-ER$_{chem}$},{CA-ERLH$_{chem}$}},
             legend style={at={(1,0.67)}},
             title={$\theta \times T_g$ \ $\left(T_h=100K\right)$}]

      \addplot[blue,ultra thick] table[x=x, y={CA.LH.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
      \addplot[fill=blue!20,draw=none,opacity=0.5,,forget plot] table[x=x, y={A.CA.LH.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt} \closedcycle;

      %\addplot[orange,ultra thick] table[x=x, y={CA.ER.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[fill=orange!20,draw=none,opacity=0.5,forget plot] table[x=x, y={A.CA.ER.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt}\closedcycle;

      %\addplot[gray,ultra thick] table[x=x, y={CA.LH+ER.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[fill=red!20,draw=none,opacity=0.5,forget plot] table[x=x, y={A.CA.LH+ER.PHY},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt}\closedcycle;

    \addplot[green,ultra thick] table[x=x, y={CA.LH.CHEM},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    \addplot[fill=green!20,draw=none,opacity=0.5,forget plot] table[x=x, y={A.CA.LH.CHEM},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt}\closedcycle;

    %  \addplot[cyan,ultra thick] table[x=x, y={CA.ER.CHEM},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    % %\addplot[fill=cyan!20,draw=none,opacity=0.5,forget plot] table[x=x, y={A.CA.ER.CHEM},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt}\closedcycle;

    %   \addplot[magenta,ultra thick] table[x=x, y={CH4.LH},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[magenta,ultra thick] table[x=x, y={CH4.ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[magenta,ultra thick] table[x=x, y={CH4.LH+ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};

    %   \addplot[teal,ultra thick] table[x=x, y={C2H2.LH},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[teal,ultra thick] table[x=x, y={C2H2.ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[teal,ultra thick] table[x=x, y={C2H2.LH+ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};

    %   \addplot[purple,ultra thick] table[x=x, y={C2H4.LH},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[purple,ultra thick] table[x=x, y={C2H4.ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};
    %  %\addplot[puple,ultra thick] table[x=x, y={C2H4.LH+ER},text special chars={\#}]{./07.04/Th=100K,Tg=variavel/Gr.txt};

     

    \draw   [dashed,ultra thick,red] (25,\pgfkeysvalueof{/pgfplots/ymin}) -- (25,\pgfkeysvalueof{/pgfplots/ymax});
    \draw   [dashed,ultra thick,red] (15,\pgfkeysvalueof{/pgfplots/ymin}) -- (15,\pgfkeysvalueof{/pgfplots/ymax});
    \draw   [dashed,ultra thick,red] (19,\pgfkeysvalueof{/pgfplots/ymin}) -- (19,\pgfkeysvalueof{/pgfplots/ymax});

    \draw   [dashed,ultra thick,red] (1038,\pgfkeysvalueof{/pgfplots/ymin}) -- (1038,\pgfkeysvalueof{/pgfplots/ymax});
    \draw   [dashed,ultra thick,red] (1557,\pgfkeysvalueof{/pgfplots/ymin}) -- (1557,\pgfkeysvalueof{/pgfplots/ymax});
    \draw   [dashed,ultra thick,red] (757,\pgfkeysvalueof{/pgfplots/ymin}) -- (757,\pgfkeysvalueof{/pgfplots/ymax});
    %\draw[ |<->|, thick] (axis cs:1,{2e-4}) -- (axis cs:25,{2e-4});
\end{semilogxaxis}
\end{tikzpicture}

来了图表图像在此处输入图片描述

答案1

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}[
name=plot1,
height=3.5cm, 
scale only axis,
xmin=5, xmax=70,
ymin=0, ymax=1.1,
axis x line=bottom, axis y line=left,
x axis line style={-},
xtick distance=10,
]
\addplot[red, thick, smooth] coordinates {(10,0) (20,0.4) (30,1) (40,1) (50,0.2) (60,0)};
\end{semilogxaxis}
\begin{semilogxaxis}[
name=plot2, at={($ (plot1.east) +(10pt,0)$)}, anchor=west,
height=3.5cm, 
scale only axis,
xmin=650, xmax=1150,
ymin=0, ymax=1.1,
axis x line=bottom, axis y line=none,
xtick distance=10,
]
\addplot[blue, thick, smooth] coordinates {(700,0) (800,0.4) (900,1) (1000,0.2) (1100,0)};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}

具有分裂 x 轴和两个峰的图形

相关内容