TikZ 3D plot : how to add spaces between tick labels to prevent them from colliding?












2















I have a 3D plot with colliding yticklabels, which I have been unable to fix for now. Here is my minimum working example:



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


Giving for now:



minimum working example initial result, with yticklabels colliding



Would you know a way to relax the yticklabel so that they do not collide ? The only solution I found so far was to delete it in the axis by passing yticklabels = {,,,}, only to define it manually after the end{axis}...



Thank you for your time!



PS: the axis width, height, view and the font size must not be changed ;)










share|improve this question


















  • 1





    your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

    – Zarko
    Mar 6 at 20:35











  • @Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

    – jeannej
    Mar 6 at 21:30











  • as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

    – Zarko
    Mar 6 at 22:37


















2















I have a 3D plot with colliding yticklabels, which I have been unable to fix for now. Here is my minimum working example:



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


Giving for now:



minimum working example initial result, with yticklabels colliding



Would you know a way to relax the yticklabel so that they do not collide ? The only solution I found so far was to delete it in the axis by passing yticklabels = {,,,}, only to define it manually after the end{axis}...



Thank you for your time!



PS: the axis width, height, view and the font size must not be changed ;)










share|improve this question


















  • 1





    your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

    – Zarko
    Mar 6 at 20:35











  • @Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

    – jeannej
    Mar 6 at 21:30











  • as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

    – Zarko
    Mar 6 at 22:37
















2












2








2








I have a 3D plot with colliding yticklabels, which I have been unable to fix for now. Here is my minimum working example:



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


Giving for now:



minimum working example initial result, with yticklabels colliding



Would you know a way to relax the yticklabel so that they do not collide ? The only solution I found so far was to delete it in the axis by passing yticklabels = {,,,}, only to define it manually after the end{axis}...



Thank you for your time!



PS: the axis width, height, view and the font size must not be changed ;)










share|improve this question














I have a 3D plot with colliding yticklabels, which I have been unable to fix for now. Here is my minimum working example:



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


Giving for now:



minimum working example initial result, with yticklabels colliding



Would you know a way to relax the yticklabel so that they do not collide ? The only solution I found so far was to delete it in the axis by passing yticklabels = {,,,}, only to define it manually after the end{axis}...



Thank you for your time!



PS: the axis width, height, view and the font size must not be changed ;)







tikz-pgf tikz-3dplot ticks






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 20:10









jeannejjeannej

1379




1379








  • 1





    your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

    – Zarko
    Mar 6 at 20:35











  • @Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

    – jeannej
    Mar 6 at 21:30











  • as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

    – Zarko
    Mar 6 at 22:37
















  • 1





    your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

    – Zarko
    Mar 6 at 20:35











  • @Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

    – jeannej
    Mar 6 at 21:30











  • as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

    – Zarko
    Mar 6 at 22:37










1




1





your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

– Zarko
Mar 6 at 20:35





your image is small, so there is not enough space for tick labels. try to reduce tick labels' font size, for example with adding ticklabel style={font=tiny}, to axis preamble. after than you can delete zticklabel style = {yshift=0.1cm}.

– Zarko
Mar 6 at 20:35













@Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

– jeannej
Mar 6 at 21:30





@Zarko Thank you for your remark. I know that it is a font size problem, but I would rather move a bit labels from the ticks than change the font size or image size. Is there no way to add a bit of space between labels without positionning them by hand?

– jeannej
Mar 6 at 21:30













as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

– Zarko
Mar 6 at 22:37







as far as i know, only way to add more space around labels is use smaller fonts for labels or increase diagram size.

– Zarko
Mar 6 at 22:37












1 Answer
1






active

oldest

votes


















2














You could rotate them.



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
yticklabel style={rotate=-30},
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


enter image description here






share|improve this answer
























  • thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

    – jeannej
    Mar 8 at 17:59






  • 1





    @jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

    – marmot
    Mar 8 at 18:01











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%2f478089%2ftikz-3d-plot-how-to-add-spaces-between-tick-labels-to-prevent-them-from-collid%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














You could rotate them.



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
yticklabel style={rotate=-30},
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


enter image description here






share|improve this answer
























  • thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

    – jeannej
    Mar 8 at 17:59






  • 1





    @jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

    – marmot
    Mar 8 at 18:01
















2














You could rotate them.



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
yticklabel style={rotate=-30},
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


enter image description here






share|improve this answer
























  • thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

    – jeannej
    Mar 8 at 17:59






  • 1





    @jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

    – marmot
    Mar 8 at 18:01














2












2








2







You could rotate them.



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
yticklabel style={rotate=-30},
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


enter image description here






share|improve this answer













You could rotate them.



documentclass[10pt]{standalone}
%
usepackage[utf8]{inputenc}
usepackage{tikz,pgfplots,amsmath}
%
pgfplotsset{compat=newest}
%

begin{document}
begin{tikzpicture}
%graphique
begin{axis}[
width=4 cm,
height=4 cm,
xmin=3,xmax=6,
ymin=0,ymax=0.023,
zmin=1,zmax=1.8,
xlabel=x,
ylabel=y,
zlabel=z,
zticklabel style = {yshift=0.1cm}, %to prevent it from colliding with xlabels
xtick = {3,4,5,6},
ytick ={0.006,0.012,0.017,0.023},
yticklabels = {0.6,1.2,1.7,2.3},
ztick ={1,1.2,1.4,1.6,1.8},
scaled y ticks = false,
yticklabel style={rotate=-30},
view = {30}{30},
]

addplot3[fill=black!15,opacity=0.35,thick] (4,0,1) -- (4,0.023,1) -- (4,0.023,1.8) -- (4,0,1.8) -- cycle;

end{axis}

end{tikzpicture}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 1:30









marmotmarmot

108k5132250




108k5132250













  • thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

    – jeannej
    Mar 8 at 17:59






  • 1





    @jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

    – marmot
    Mar 8 at 18:01



















  • thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

    – jeannej
    Mar 8 at 17:59






  • 1





    @jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

    – marmot
    Mar 8 at 18:01

















thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

– jeannej
Mar 8 at 17:59





thank you, this is a cunning answer! Any hint as to why "1.2" and "1.7" seem closer to each other ? (they are touching a bit, while there is some space between "1.7" and "2.3")

– jeannej
Mar 8 at 17:59




1




1





@jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

– marmot
Mar 8 at 18:01





@jeannej This is because 1.7-1.2=0.5<0.6=2.3-1.7.

– marmot
Mar 8 at 18:01


















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%2f478089%2ftikz-3d-plot-how-to-add-spaces-between-tick-labels-to-prevent-them-from-collid%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?