Tell pgfplots to put tick labels between tick marks





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















Is it possible to tell pgfplots to put tick labels between the tick marks instead of at the tick marks?



MWE:



documentclass[margin=5pt]{standalone}

usepackage{tikz}
usepackage{pgfplots}

begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
extra x ticks={0,1,2,3},
extra x tick labels={low,high,med},
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


Result:



enter image description here



I can do it manually by adding



xticklabel style = {xshift=1.9cm,align=center},


enter image description here



but this seems unsatisfying, unreliable, and requires too much trial and error.










share|improve this question























  • Why not use extra x ticks={0.5,1.5,2.5},?

    – leandriis
    May 18 at 13:25











  • Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

    – LarrySnyder610
    May 18 at 13:27











  • The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

    – LarrySnyder610
    May 18 at 13:28


















1















Is it possible to tell pgfplots to put tick labels between the tick marks instead of at the tick marks?



MWE:



documentclass[margin=5pt]{standalone}

usepackage{tikz}
usepackage{pgfplots}

begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
extra x ticks={0,1,2,3},
extra x tick labels={low,high,med},
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


Result:



enter image description here



I can do it manually by adding



xticklabel style = {xshift=1.9cm,align=center},


enter image description here



but this seems unsatisfying, unreliable, and requires too much trial and error.










share|improve this question























  • Why not use extra x ticks={0.5,1.5,2.5},?

    – leandriis
    May 18 at 13:25











  • Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

    – LarrySnyder610
    May 18 at 13:27











  • The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

    – LarrySnyder610
    May 18 at 13:28














1












1








1








Is it possible to tell pgfplots to put tick labels between the tick marks instead of at the tick marks?



MWE:



documentclass[margin=5pt]{standalone}

usepackage{tikz}
usepackage{pgfplots}

begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
extra x ticks={0,1,2,3},
extra x tick labels={low,high,med},
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


Result:



enter image description here



I can do it manually by adding



xticklabel style = {xshift=1.9cm,align=center},


enter image description here



but this seems unsatisfying, unreliable, and requires too much trial and error.










share|improve this question














Is it possible to tell pgfplots to put tick labels between the tick marks instead of at the tick marks?



MWE:



documentclass[margin=5pt]{standalone}

usepackage{tikz}
usepackage{pgfplots}

begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
extra x ticks={0,1,2,3},
extra x tick labels={low,high,med},
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


Result:



enter image description here



I can do it manually by adding



xticklabel style = {xshift=1.9cm,align=center},


enter image description here



but this seems unsatisfying, unreliable, and requires too much trial and error.







pgfplots labels ticks






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 18 at 13:19









LarrySnyder610LarrySnyder610

1,1471 gold badge9 silver badges26 bronze badges




1,1471 gold badge9 silver badges26 bronze badges













  • Why not use extra x ticks={0.5,1.5,2.5},?

    – leandriis
    May 18 at 13:25











  • Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

    – LarrySnyder610
    May 18 at 13:27











  • The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

    – LarrySnyder610
    May 18 at 13:28



















  • Why not use extra x ticks={0.5,1.5,2.5},?

    – leandriis
    May 18 at 13:25











  • Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

    – LarrySnyder610
    May 18 at 13:27











  • The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

    – LarrySnyder610
    May 18 at 13:28

















Why not use extra x ticks={0.5,1.5,2.5},?

– leandriis
May 18 at 13:25





Why not use extra x ticks={0.5,1.5,2.5},?

– leandriis
May 18 at 13:25













Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

– LarrySnyder610
May 18 at 13:27





Because then the tick marks will appear at 0.5, 1.5, 2.5, which I don't want -- I want the marks at the integers.

– LarrySnyder610
May 18 at 13:27













The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

– LarrySnyder610
May 18 at 13:28





The image is meant to suggest "in between 0 and 1, things are low; in between 1 and 2, things are high; in between 2 and 3, things are medium.

– LarrySnyder610
May 18 at 13:28










1 Answer
1






active

oldest

votes


















3














How about



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
xtick={0,1,2,3},
xticklabel=empty,
extra x ticks={0.5,1.5,2.5},
extra x tick labels={low,high,med},
extra x tick style={major tick length=0pt}
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

    – LarrySnyder610
    May 18 at 13:35











  • @LarrySnyder610 Now there are no more ticks at the extra positions.

    – marmot
    May 18 at 13:36











  • OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

    – LarrySnyder610
    May 18 at 13:44














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%2f491480%2ftell-pgfplots-to-put-tick-labels-between-tick-marks%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









3














How about



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
xtick={0,1,2,3},
xticklabel=empty,
extra x ticks={0.5,1.5,2.5},
extra x tick labels={low,high,med},
extra x tick style={major tick length=0pt}
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

    – LarrySnyder610
    May 18 at 13:35











  • @LarrySnyder610 Now there are no more ticks at the extra positions.

    – marmot
    May 18 at 13:36











  • OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

    – LarrySnyder610
    May 18 at 13:44
















3














How about



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
xtick={0,1,2,3},
xticklabel=empty,
extra x ticks={0.5,1.5,2.5},
extra x tick labels={low,high,med},
extra x tick style={major tick length=0pt}
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

    – LarrySnyder610
    May 18 at 13:35











  • @LarrySnyder610 Now there are no more ticks at the extra positions.

    – marmot
    May 18 at 13:36











  • OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

    – LarrySnyder610
    May 18 at 13:44














3












3








3







How about



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
xtick={0,1,2,3},
xticklabel=empty,
extra x ticks={0.5,1.5,2.5},
extra x tick labels={low,high,med},
extra x tick style={major tick length=0pt}
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer















How about



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}

begin{tikzpicture}

begin{axis}[
width=5in,
height=3in,
axis lines=middle,
scaled ticks=false,
xtick=empty,
xmin=0,
xmax=3,
xtick={0,1,2,3},
xticklabel=empty,
extra x ticks={0.5,1.5,2.5},
extra x tick labels={low,high,med},
extra x tick style={major tick length=0pt}
]

addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};

end{axis}
end{tikzpicture}

end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited May 18 at 13:36

























answered May 18 at 13:32









marmotmarmot

141k6 gold badges184 silver badges341 bronze badges




141k6 gold badges184 silver badges341 bronze badges













  • Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

    – LarrySnyder610
    May 18 at 13:35











  • @LarrySnyder610 Now there are no more ticks at the extra positions.

    – marmot
    May 18 at 13:36











  • OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

    – LarrySnyder610
    May 18 at 13:44



















  • Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

    – LarrySnyder610
    May 18 at 13:35











  • @LarrySnyder610 Now there are no more ticks at the extra positions.

    – marmot
    May 18 at 13:36











  • OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

    – LarrySnyder610
    May 18 at 13:44

















Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

– LarrySnyder610
May 18 at 13:35





Nice, but I don't want the tick marks at the labels -- I want them at the integers (in this MWE).

– LarrySnyder610
May 18 at 13:35













@LarrySnyder610 Now there are no more ticks at the extra positions.

– marmot
May 18 at 13:36





@LarrySnyder610 Now there are no more ticks at the extra positions.

– marmot
May 18 at 13:36













OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

– LarrySnyder610
May 18 at 13:44





OK, that works. It's still a little clunky IMO because there's a lot of manual handling (i.e., I'm still basically doing the x-shifting manually). In my actual figure, there are a lot more intervals on the x-axis, so it's a bit tedious, but workable. I was hoping there was just an option like labels between ticks. Anyway, I'll keep my eye out for a more automated solution. Thanks!

– LarrySnyder610
May 18 at 13:44


















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%2f491480%2ftell-pgfplots-to-put-tick-labels-between-tick-marks%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

He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

Bunad

Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum