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;
}
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:
I can do it manually by adding
xticklabel style = {xshift=1.9cm,align=center},
but this seems unsatisfying, unreliable, and requires too much trial and error.
pgfplots labels ticks
add a comment |
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:
I can do it manually by adding
xticklabel style = {xshift=1.9cm,align=center},
but this seems unsatisfying, unreliable, and requires too much trial and error.
pgfplots labels ticks
Why not useextra 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
add a comment |
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:
I can do it manually by adding
xticklabel style = {xshift=1.9cm,align=center},
but this seems unsatisfying, unreliable, and requires too much trial and error.
pgfplots labels ticks
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:
I can do it manually by adding
xticklabel style = {xshift=1.9cm,align=center},
but this seems unsatisfying, unreliable, and requires too much trial and error.
pgfplots labels ticks
pgfplots labels ticks
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 useextra 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
add a comment |
Why not useextra 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
add a comment |
1 Answer
1
active
oldest
votes
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}
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 likelabels between ticks
. Anyway, I'll keep my eye out for a more automated solution. Thanks!
– LarrySnyder610
May 18 at 13:44
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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}
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 likelabels between ticks
. Anyway, I'll keep my eye out for a more automated solution. Thanks!
– LarrySnyder610
May 18 at 13:44
add a comment |
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}
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 likelabels between ticks
. Anyway, I'll keep my eye out for a more automated solution. Thanks!
– LarrySnyder610
May 18 at 13:44
add a comment |
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}
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}
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 likelabels between ticks
. Anyway, I'll keep my eye out for a more automated solution. Thanks!
– LarrySnyder610
May 18 at 13:44
add a comment |
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 likelabels 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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