How to reduce the scale of the X axis between an interval, without changing the scale of the rest of the graph

I have a graph whose values on the X axis between 10-60 and 700-1100 have non-zero values, and between 60-700 it is zero. I want to be able to make the X-axis range between 60-700 values smaller so that I can bring the two peaks closer together, and thus be able to graph better, without changing the scale of X axis. The axis scale on the X axis is in logarithm, and on the Y axis it is linear. The graphs are made from a data table in .txt format. Below is the code with the graph.

\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}


Here comes the image of the Graph

1 Answer

\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}


• Question : Is there a command to make the distance between the graphs equal to zero, to make it seam that they are one ? Question 2 : Is it possible to select a domain for the graph when the points are loaded from an txt. file ? Example on the file data1.txt the x values go from 0-4000 on the table, but I want to draw the graph from the table between the interval 0-60 ? Commented Oct 2, 2023 at 17:36
• A solution that I tough It my work, was: 1) shift all the values of the table from the second peak to make it closer to fist peak, 2) use the command xtick={0,10,20,50,60, 700,800,1000,1100,4000} so that it would wright this ticks, even if the x-axis scale does not pass through these points . Is it possible to make the ticks on the X axis to wright the values I want spaced the way I want? Commented Oct 2, 2023 at 17:37
• at={($(plot1.east) +(10pt,0)$)} purposefully makes 10pt between the axis, to show the discontinuity. You can change it to name=plot2, at=(plot1.east) and drop the calc package. You can plot some data from a file with e.g. skip coords between index={⟨begin⟩}{⟨end⟩} -see p. 396 in the manual. Commented Oct 3, 2023 at 3:07
• You can make ticks where you want with xtick={⟨coordinate list⟩} and label them with what you want with xticklabels={⟨label list⟩} - but I would strongly advise against it. It is useful for named labels as xtick={2.72, 3.14} xticklabels={$e$, $\pi$}` - it is not meant for making fake axis. Commented Oct 3, 2023 at 3:14
• It would be really useful if your question included a precise description and e.g. a drawing of what you need. -edit your question, if you need further help. Commented Oct 3, 2023 at 3:18