Tikz: Transforming axis to skip an interval












3















Two graphs are illustrated in a diagram, with quite a lot of space inbetween, making it rather unsightly. I would like to move them closer together by skipping the space inbetween.



This is the diagram



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
pgfplotsset{
scale only axis}
begin{axis}[tick align=center,xmin=546, xmax=565, ymin=0, ymax=60]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{axis}
end{tikzpicture}
end{document}


And this is how I imagine the x axis:



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
foreach x/y in {0/550, 1/552, 4/556, 5/558}
draw (x,0.25) -- (x,-0.25) node[below]{$y$};
draw (-0.5, 0)--(2,0);
draw (3, 0)--(5.5,0);
draw[dotted] (2,0)--(3,0);
end{tikzpicture}
end{document}









share|improve this question




















  • 2





    So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 13:02













  • Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

    – cheesus
    Mar 10 at 13:24






  • 1





    By setting xmin!?

    – Stefan Pinnow
    Mar 10 at 14:51


















3















Two graphs are illustrated in a diagram, with quite a lot of space inbetween, making it rather unsightly. I would like to move them closer together by skipping the space inbetween.



This is the diagram



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
pgfplotsset{
scale only axis}
begin{axis}[tick align=center,xmin=546, xmax=565, ymin=0, ymax=60]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{axis}
end{tikzpicture}
end{document}


And this is how I imagine the x axis:



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
foreach x/y in {0/550, 1/552, 4/556, 5/558}
draw (x,0.25) -- (x,-0.25) node[below]{$y$};
draw (-0.5, 0)--(2,0);
draw (3, 0)--(5.5,0);
draw[dotted] (2,0)--(3,0);
end{tikzpicture}
end{document}









share|improve this question




















  • 2





    So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 13:02













  • Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

    – cheesus
    Mar 10 at 13:24






  • 1





    By setting xmin!?

    – Stefan Pinnow
    Mar 10 at 14:51
















3












3








3








Two graphs are illustrated in a diagram, with quite a lot of space inbetween, making it rather unsightly. I would like to move them closer together by skipping the space inbetween.



This is the diagram



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
pgfplotsset{
scale only axis}
begin{axis}[tick align=center,xmin=546, xmax=565, ymin=0, ymax=60]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{axis}
end{tikzpicture}
end{document}


And this is how I imagine the x axis:



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
foreach x/y in {0/550, 1/552, 4/556, 5/558}
draw (x,0.25) -- (x,-0.25) node[below]{$y$};
draw (-0.5, 0)--(2,0);
draw (3, 0)--(5.5,0);
draw[dotted] (2,0)--(3,0);
end{tikzpicture}
end{document}









share|improve this question
















Two graphs are illustrated in a diagram, with quite a lot of space inbetween, making it rather unsightly. I would like to move them closer together by skipping the space inbetween.



This is the diagram



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
pgfplotsset{
scale only axis}
begin{axis}[tick align=center,xmin=546, xmax=565, ymin=0, ymax=60]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{axis}
end{tikzpicture}
end{document}


And this is how I imagine the x axis:



documentclass{standalone}
usepackage{tikz,pgfplots}

begin{document}
begin{tikzpicture}
foreach x/y in {0/550, 1/552, 4/556, 5/558}
draw (x,0.25) -- (x,-0.25) node[below]{$y$};
draw (-0.5, 0)--(2,0);
draw (3, 0)--(5.5,0);
draw[dotted] (2,0)--(3,0);
end{tikzpicture}
end{document}






tikz-pgf pgfplots






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 10 at 12:49









JouleV

6,46121750




6,46121750










asked Mar 10 at 12:46









cheesuscheesus

275




275








  • 2





    So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 13:02













  • Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

    – cheesus
    Mar 10 at 13:24






  • 1





    By setting xmin!?

    – Stefan Pinnow
    Mar 10 at 14:51
















  • 2





    So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 13:02













  • Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

    – cheesus
    Mar 10 at 13:24






  • 1





    By setting xmin!?

    – Stefan Pinnow
    Mar 10 at 14:51










2




2





So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

– marmot
Mar 10 at 13:02







So you are looking for an axis x discontinuity? See e.g. tex.stackexchange.com/a/62778/121799.

– marmot
Mar 10 at 13:02















Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

– cheesus
Mar 10 at 13:24





Thx thats it. Having problems setting the position of the discontinuity. Do you know how to specify the interval that is skipped?

– cheesus
Mar 10 at 13:24




1




1





By setting xmin!?

– Stefan Pinnow
Mar 10 at 14:51







By setting xmin!?

– Stefan Pinnow
Mar 10 at 14:51












1 Answer
1






active

oldest

votes


















2














This is almost entirely taken from this answer. Of course one has to exchange the role of x and y, then ymin and ymax become xmin and xmax, as Stefan Pinnow mentions.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16,scale only axis}
usepgfplotslibrary{groupplots}
begin{document}
begin{tikzpicture}
begin{groupplot}[width=6cm,
group style={
group name=my fancy plots,
group size=2 by 1,
%xticklabels at=edge bottom,
horizontal sep=0pt
},
]

nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=empty,
xtick={560,562,564}]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{groupplot}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 1





    good idea to use group plots! +1.

    – Zarko
    Mar 10 at 16:32






  • 1





    @Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 16:33











  • well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

    – Zarko
    Mar 10 at 16:42






  • 1





    @Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

    – marmot
    Mar 10 at 16:51











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478727%2ftikz-transforming-axis-to-skip-an-interval%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














This is almost entirely taken from this answer. Of course one has to exchange the role of x and y, then ymin and ymax become xmin and xmax, as Stefan Pinnow mentions.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16,scale only axis}
usepgfplotslibrary{groupplots}
begin{document}
begin{tikzpicture}
begin{groupplot}[width=6cm,
group style={
group name=my fancy plots,
group size=2 by 1,
%xticklabels at=edge bottom,
horizontal sep=0pt
},
]

nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=empty,
xtick={560,562,564}]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{groupplot}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 1





    good idea to use group plots! +1.

    – Zarko
    Mar 10 at 16:32






  • 1





    @Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 16:33











  • well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

    – Zarko
    Mar 10 at 16:42






  • 1





    @Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

    – marmot
    Mar 10 at 16:51
















2














This is almost entirely taken from this answer. Of course one has to exchange the role of x and y, then ymin and ymax become xmin and xmax, as Stefan Pinnow mentions.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16,scale only axis}
usepgfplotslibrary{groupplots}
begin{document}
begin{tikzpicture}
begin{groupplot}[width=6cm,
group style={
group name=my fancy plots,
group size=2 by 1,
%xticklabels at=edge bottom,
horizontal sep=0pt
},
]

nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=empty,
xtick={560,562,564}]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{groupplot}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 1





    good idea to use group plots! +1.

    – Zarko
    Mar 10 at 16:32






  • 1





    @Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 16:33











  • well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

    – Zarko
    Mar 10 at 16:42






  • 1





    @Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

    – marmot
    Mar 10 at 16:51














2












2








2







This is almost entirely taken from this answer. Of course one has to exchange the role of x and y, then ymin and ymax become xmin and xmax, as Stefan Pinnow mentions.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16,scale only axis}
usepgfplotslibrary{groupplots}
begin{document}
begin{tikzpicture}
begin{groupplot}[width=6cm,
group style={
group name=my fancy plots,
group size=2 by 1,
%xticklabels at=edge bottom,
horizontal sep=0pt
},
]

nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=empty,
xtick={560,562,564}]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{groupplot}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer













This is almost entirely taken from this answer. Of course one has to exchange the role of x and y, then ymin and ymax become xmin and xmax, as Stefan Pinnow mentions.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16,scale only axis}
usepgfplotslibrary{groupplots}
begin{document}
begin{tikzpicture}
begin{groupplot}[width=6cm,
group style={
group name=my fancy plots,
group size=2 by 1,
%xticklabels at=edge bottom,
horizontal sep=0pt
},
]

nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=empty,
xtick={560,562,564}]
addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)};
addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
end{groupplot}
end{tikzpicture}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 10 at 16:10









marmotmarmot

109k5136255




109k5136255








  • 1





    good idea to use group plots! +1.

    – Zarko
    Mar 10 at 16:32






  • 1





    @Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 16:33











  • well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

    – Zarko
    Mar 10 at 16:42






  • 1





    @Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

    – marmot
    Mar 10 at 16:51














  • 1





    good idea to use group plots! +1.

    – Zarko
    Mar 10 at 16:32






  • 1





    @Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

    – marmot
    Mar 10 at 16:33











  • well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

    – Zarko
    Mar 10 at 16:42






  • 1





    @Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

    – marmot
    Mar 10 at 16:51








1




1





good idea to use group plots! +1.

– Zarko
Mar 10 at 16:32





good idea to use group plots! +1.

– Zarko
Mar 10 at 16:32




1




1





@Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

– marmot
Mar 10 at 16:33





@Zarko Thanks but this is definitely not my idea but the idea of the author of tex.stackexchange.com/a/62778/121799.

– marmot
Mar 10 at 16:33













well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

– Zarko
Mar 10 at 16:42





well, i first time see it in your answer :-)! it is useful at using axis ... discontinuity which unfortunately is no possible to define in middle of diagram (as far as i know).

– Zarko
Mar 10 at 16:42




1




1





@Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

– marmot
Mar 10 at 16:51





@Zarko AFAIK you can move the symbol, e.g. the crunch around. But this does not give you a discontinuity for the ticks. Of course, you can add coordinate transformations, see tex.stackexchange.com/a/46651/121799. But the groupplot thingy is IMHO simpler.

– marmot
Mar 10 at 16:51


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478727%2ftikz-transforming-axis-to-skip-an-interval%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?