# axis ticks labels are unreadable too close

I have been working on a special drawing for a considerable amount of time - fortunately, it's almost done. The whole thing is based on plotting magnitude of a complex function over the complex plane. I would like to avoid using an external dat file.

Since the function has not its poles in infinity, I had to set high samples to plot steep poles correctly in details.

Now, this higher samples numbers often led to an TeX capacity error and manual increasing (for MiKTeX) was not very effective.

For that reason, I divided area: samplings around the poles are finer and for the rest of the plot, which is not so interesting and basically smooth, coarser number of samples is used. Only then compilation has been successful.

When view={50}{45} is used in axis environment (which fits original purposes of drawing perfectly), ugly discontinuities are hidden! So this similar view setup is preferred.

I have already solved out some issues that have arisen, but one more problem remains.

I would like to have ticks labels on x axis, but you you can the result I got:

x ticks labels are too close so they overlap each other.

When default view is used, x ticks labels are ok, BUT:

a) view is not good for didactic purposes, because the thick red line is deformed too much and is not acceptable b) diffeerent sampled areas and their boundaries are clearly visible

From this point, I tried extra ticks in this manner how to move extra x tick label vertically down to take away tick labels from the x axis, but it only gave weird "crosses" on x axis. But this is the way I suggest - make these \Re x ticks further away from the axis, which is still nice looking solution.

Then, I was labouring with Adjusting the distance between label and axis in pgfplots, but I simply don't understand it properly and I wasn't able to make it work for me.

Finally, I also tried make some sort of "quasi-extra ticks" manually using draw command, but it turned out the worst of all because these quasi-ticks disappeared... what a shame :)

So, what I would like to get is x ticks labels which are not overlaping each other and similar position of graph. Of course, I can discuss the view option if it would lead to a good result.

Good result means: no visible sampling discontinuities, thick red line should be (just a bit) recognisible recognizable as function from my elder, previous post Piecewise-defined function badly colored and clear axis tick labels.

Any help is welcome :)

Here is the code

\documentclass[border=1cm]{standalone}
\usetikzlibrary{calc}
%%%%%%%
\pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
\pgfkeys{/pgf/declare function={argcosh(\x) = ln(\x + sqrt(-1 + \x)*sqrt(1 + \x));}}
%%4th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((\x^4-6*\x^2*\y^2+\y^4+.581580*\x^3-1.744740*\x*\y^2+1.169118*\x^2-1.169118*\y^2+.404768*\x+.176987)^2+(4*\x^3*\y-4*\x*\y^3+1.744740*\x^2*\y-.581580*\y^3+2.338236*\x*\y+.404768*\y)^2));}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, axis on top,
axis equal image,
width=40cm, %%ridi velikost grafu!
view={50}{45},
xmin=-0.5,
xmax=0.5,
ymin=0,
ymax=2,
zmin=0,
zmax=2,
miter limit=1,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xlabel=$\Sigma$,
xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}},% <- position the x label
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ylabel=$j\Omega$,
zlabel=$\mathopen| H(j\Omega)\mathclose|$,
zlabel style={anchor=north east},% <- position the z label
xtick = {0,-.205619531335967,-.851703985681571e-1},
hide obscured x ticks=false,% <- added
xticklabels = {0,$\Re(s_4)$,$\Re(s_3)$},
hide obscured y ticks=false,% <- added
ytick = {.392046688799926,.946484433184241},
yticklabels = {$\Im(s_4)$,$\Im(s_3)$},
ztick = \empty,
]

%%pole position as projection
(0,.946484433184241,0)
(-.851703985681571e-1,.946484433184241,0)
(-.851703985681571e-1,0,0)
};
%%standard circle symbol for pole

%%pole position as projection
(0,.392046688799926,0)
(-.205619531335967,.392046688799926,0)
(-.205619531335967,0,0)
};
%%standard circle symbol for pole

%%pole position as projection / vertical lines
(-.205619531335967,.392046688799926,0)
(-.205619531335967,.392046688799926,1.5)
};

smooth,
surf,
faceted color=black,
line width=0.01pt,
fill=white,
domain=-0.75:0,
y domain = 0:1.5,
samples = 50,
samples y = 50,
restrict z to domain*=0:1.5]
{H(\x,\y)};

smooth,
surf,
faceted color=black,
line width=0.01pt,
fill=white,
domain=-0.4:0,
y domain = 0:1.2,
samples = 40,
samples y = 60,
restrict z to domain*=0:1.5]
{H(\x,\y)};

%%pole position as projection / vertical lines
(-.851703985681571e-1,.946484433184241,0)
(-.851703985681571e-1,.946484433184241,0.85)
};

%%red characteristics
\addplot3[domain=0:1.5,samples=70, samples y = 0, red, thick] ({0},{x},{H(0,x)});

%%ellipse for poles: order 4, eps=1 (3dB]
\pgfmathsetmacro{\elipseA}{sinh((1/4)*argsinh(1/1))}
\pgfmathsetmacro{\elipseB}{cosh((1/4)*argsinh(1/1))}
\draw[thin,dashed,blue] (0,\elipseB,0) arc (90:270:{\elipseA} and {\elipseB});
\end{axis}

%%manually added extra-like x ticks (in case of different view)

\end{tikzpicture}
\end{document}

• Nitpick: I would start by stopping using those symbols for Re and Im for didactic purposes. Jul 27, 2017 at 17:40

I would reorder the xtick and the xticklabels and shift the xticklabels manuelly depending on the \ticknum:

xtick = {0,-.851703985681571e-1,-.205619531335967},
xticklabels = {0,$\Re(s_3)$,$\Re(s_4)$},
xticklabel style={
yshift=6pt*(\ticknum>0?1:0)+3pt*(\ticknum>1?1:0),
xshift=-4pt*(\ticknum>0?1:0)-2pt*(\ticknum>1?1:0)
}


Code:

\documentclass[border=1cm]{standalone}
\usetikzlibrary{calc}
%%%%%%%
\pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
\pgfkeys{/pgf/declare function={argcosh(\x) = ln(\x + sqrt(-1 + \x)*sqrt(1 + \x));}}
%%4th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((\x^4-6*\x^2*\y^2+\y^4+.581580*\x^3-1.744740*\x*\y^2+1.169118*\x^2-1.169118*\y^2+.404768*\x+.176987)^2+(4*\x^3*\y-4*\x*\y^3+1.744740*\x^2*\y-.581580*\y^3+2.338236*\x*\y+.404768*\y)^2));}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, axis on top,
axis equal image,
width=40cm, %%ridi velikost grafu!
view={50}{45},
xmin=-0.5,
xmax=0.5,
ymin=0,
ymax=2,
zmin=0,
zmax=2,
miter limit=1,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xlabel=$\Sigma$,
xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}},% <- position the x label
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ylabel=$j\Omega$,
zlabel=$\mathopen| H(j\Omega)\mathclose|$,
zlabel style={anchor=north east},% <- position the z label
xtick = {0,-.851703985681571e-1,-.205619531335967},
xticklabels = {0,$\Re(s_3)$,$\Re(s_4)$},
xticklabel style={
yshift=6pt*(\ticknum>0?1:0)+3pt*(\ticknum>1?1:0),
xshift=-4pt*(\ticknum>0?1:0)-2pt*(\ticknum>1?1:0)
},
hide obscured x ticks=false,% <- added
%hide obscured y ticks=false,% <- added
ytick = {.392046688799926,.946484433184241},
yticklabels = {$\Im(s_4)$,$\Im(s_3)$},
ztick = \empty,
]

%%pole position as projection
(0,.946484433184241,0)
(-.851703985681571e-1,.946484433184241,0)
(-.851703985681571e-1,0,0)
};
%%standard circle symbol for pole

%%pole position as projection
(0,.392046688799926,0)
(-.205619531335967,.392046688799926,0)
(-.205619531335967,0,0)
};
%%standard circle symbol for pole

%%pole position as projection / vertical lines
(-.205619531335967,.392046688799926,0)
(-.205619531335967,.392046688799926,1.5)
};

smooth,
surf,
faceted color=black,
line width=0.01pt,
fill=white,
domain=-0.75:0,
y domain = 0:1.5,
samples = 50,
samples y = 50,
restrict z to domain*=0:1.5]
{H(\x,\y)};

smooth,
surf,
faceted color=black,
line width=0.01pt,
fill=white,
domain=-0.4:0,
y domain = 0:1.2,
samples = 40,
samples y = 60,
restrict z to domain*=0:1.5]
{H(\x,\y)};

%%pole position as projection / vertical lines
(-.851703985681571e-1,.946484433184241,0)
(-.851703985681571e-1,.946484433184241,0.85)
};

%%red characteristics
\addplot3[domain=0:1.5,samples=70, samples y = 0, red, thick] ({0},{x},{H(0,x)});

%%ellipse for poles: order 4, eps=1 (3dB]
\pgfmathsetmacro{\elipseA}{sinh((1/4)*argsinh(1/1))}
\pgfmathsetmacro{\elipseB}{cosh((1/4)*argsinh(1/1))}
\draw[thin,dashed,blue] (0,\elipseB,0) arc (90:270:{\elipseA} and {\elipseB});
\end{axis}

\end{tikzpicture}
\end{document}

• Thank you. I didn't know these shifts and its acceptable.Anyway, do you know how to make extra ticks in 3d case? Jul 28, 2017 at 6:21
• Ok, I marked it as solved. I really like your solution, this is the first time I saw such usage :) Nice Jul 28, 2017 at 14:25