On the bottom right part of the added picture you see that the x and y tick labels are almost touching each other. Which isn't really beautiful in my opinion.

Are there any good solutions of this problem you can think of?

An unsatisfying solution of mine was to avoid writing the number 1.2 in the figure. Don't really like this solution as you should see the boundaries in a figure of a scientific thesis.

Any other solutions?

I've got many diagrams, but not all of them show this problem. It's depending on the length of the last x tick label. So if i set the distance of e. g. The y tick labels on the second y axis on a greater distance to the axis, I have to do this on any other figure too... Which might not be beautiful on other figures as there will be too much space in between? Just a thought.

Thanks a lot in advance

Cheers Jakob

%------------------------
% Preamble

\usepackage{pgfplots}           
\usetikzlibrary{plotmarks}  
\usepackage{pgfplotstable}  
\pgfplotsset{
            cycle list name=mylist BW,
            invoke before crossref tikzpicture={\tikzexternaldisable},
            invoke after crossref tikzpicture={\tikzexternalenable},
            compat=1.12,
            }
\usepgfplotslibrary{external}
\tikzexternalize[prefix=3-diagrams/]


%------------------------
% code of figure attached

\begin{figure}[h]
\centering
\tikzsetnextfilename{particle_linescan_Sulfur}%
    \begin{tikzpicture}
    \begin{axis}[
                xlabel={Particle diameter / mm},
                ylabel={Sulfur content / \wt},
                xmin=0, xmax=1.2,
                ymin=0, ymax=3,
                minor y tick num=1,
                minor x tick num=1,
    %           xtick={0, 0.2, 0.4, 0.6, 0.8, 1.0}, % unsatisfying solution
                height=7.06cm,
                width=10.1cm,
                yticklabel pos = right, % yes, I do need them on the right side
                ]
                \addplot+[no markers,solid] table[x=line,y=sulfur]{3-data/others/particle_linescan_Sulfur.dat};
                \label{particle_linescan_Sulfur}
    \end{axis}
    \end{tikzpicture}%
\caption[...]{\ref{particle_linescan_Sulfur}...}
\label{fig:particle_linescan}
\end{figure}%   fig:particle_linescan_Sulfur

image shows the unsatisfying visualization of the tick labels almost touching each other on the right bottom of the pic.

  • 1
    I think you don't need that 1.2 there anyways, ticks make it obvious so as 0 and 3 – percusse Mar 12 '16 at 13:36
  • It would be better to have some sort of idea of how this was made. Please post a minimum working example. – A Feldman Mar 12 '16 at 13:46
  • I edited my question and posted the code which results in the attached figure.. – Jakob Mar 12 '16 at 15:23
  • @Jakob that code will not produce the attached figure at all. You are missing a document class, the document environment, and we do not have the definition of mylist BW, \wt, nor the data file (these are not really relevant to the question anyway). Further, all of the externalization stuff is not relevant to the question. Please take the time to produce a minimal working example (MWE) that shows the issue and that helpers here can compile without extra steps. – Paul Gessler Mar 12 '16 at 15:48
  • @PaulGessler, thanks for the advice. As esdd has answered the question already I'm not gonna do it with that code. But I'm going to publish a MWE next time. – Jakob Mar 13 '16 at 19:55
up vote 2 down vote accepted

You could shift the first ytick:

yticklabel={\ifnum \ticknum=1 
  \raisebox{1ex}{\pgfmathprintnumber{\tick}}
  \else\pgfmathprintnumber{\tick}\fi
},

enter image description here

Code:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
            xlabel={Particle diameter / mm},
            ylabel={Sulfur content},
            xmin=0, xmax=1.2,
            ymin=0, ymax=3,
            minor y tick num=1,
            minor x tick num=1,
            yticklabel={\ifnum \ticknum=1 
              \raisebox{1ex}{\pgfmathprintnumber{\tick}}
              \else\pgfmathprintnumber{\tick}\fi
            },
            height=7.06cm,
            width=10.1cm,
            yticklabel pos = right,
            ]
\end{axis}
\end{tikzpicture}%
\end{document}
  • Oh that's a nice solution, thanks a lot! I didn't know that there is a way to shift single ticks.. nice! Is there a way to include this via an 'if' command in the whole tikzpicutre environment. Something like: if there is a second y axis (on the right side), then shift the first label on the left and on the right side 1ex up? – Jakob Mar 13 '16 at 19:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.