4

my tick numbers are overlapping, reducing the fontsize with '\tiny' just change the size of the x but the subindex keeps the same size. How can I reduce the size also of the subindexes in the tick labels?

Sample

\documentclass\[10pt,a4paper\]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,positioning,calc}

\pgfplotsset{compat=1.16,
    integral axis/.style={
        axis lines=middle,
        enlarge y limits=upper,
        axis equal image, width=12cm,
        xlabel=$x$, ylabel=$y$,
        ytick=\empty,
        xticklabel style={font=\small, text height=1.5ex, anchor=north},
        samples=100
    },
    integral/.style={
        domain=2:8,
        samples=7
    },
    integral fill/.style={
        integral,
        draw=none, fill=#1,
    },
    integral fill/.default=cyan!10,
    integral line/.style={
        integral,
        very thick,
        draw=#1
    },
    integral line/.default=black,
  every tick label/.append style={font=\large}
}



\begin{document}    
\begin{figure}
\begin{tikzpicture}\[
                % The function that is used for all the plots
                declare function={f(\x)=\x/5-cos(deg(\x*1.85))/2+2;}
                \]
                \begin{axis}\[
                integral axis,
                ymin=0,
                xmin=0.75, xmax=9.25,
                domain=1.5:8.5,
                xtick={2,2.5,3,3.5,...,8},
                xticklabels={$x_0$, $x_{1/2}$, $x_1$,$x_{3/2}$,$x_2$,$x_{5/2}$,$x_3$,,,,$x_{N-1}$,$x_{N-\frac{1}{2}}$,$x_N$},
                axis on top
                \]
                \addplot \[integral fill=cyan!15\] {f(x)} \closedcycle;
                \addplot \[very thick, cyan!75!blue\] {f(x)} node \[anchor=south\] {$y=f(x)$};
                \addplot \[integral line=black\] {f(x)};
                \addplot \[integral, ycomb\] {f(x)};
                \end{axis}
                \end{tikzpicture}
\end{figure}
\end{document}
  • How about rotating the tick labels instead of making them smaller? – user121799 Dec 13 '18 at 9:07
  • Hi mr. Marmot, nice Idea, how to do it? – Lin Dec 13 '18 at 9:08
  • You could just add xticklabel style={rotate=-45,anchor=north west} to the options of the axis. – user121799 Dec 13 '18 at 9:17
0

You can use the scalerel package and scaleto,

$x_{\scaleto{0}{3pt}}$

Will produce

enter image description here

Where $x_{0}$ produces

enter image description here

3

I'd probably do

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,positioning,calc}

\pgfplotsset{compat=1.16,
    integral axis/.style={
        axis lines=middle,
        enlarge y limits=upper,
        axis equal image, width=12cm,
        xlabel=$x$, ylabel=$y$,
        ytick=\empty,
        xticklabel style={font=\small, text height=1.5ex, anchor=north},
        samples=100
    },
    integral/.style={
        domain=2:8,
        samples=7
    },
    integral fill/.style={
        integral,
        draw=none, fill=#1,
    },
    integral fill/.default=cyan!10,
    integral line/.style={
        integral,
        very thick,
        draw=#1
    },
    integral line/.default=black,
  every tick label/.append style={font=\large}
}



\begin{document}    
\begin{figure}
\begin{tikzpicture}[
                % The function that is used for all the plots
                declare function={f(\x)=\x/5-cos(deg(\x*1.85))/2+2;}
                ]
                \begin{axis}[
                integral axis,
                ymin=0,
                xmin=0.75, xmax=9.25,
                domain=1.5:8.5,
                xtick={2,2.5,3,3.5,...,8},
                xticklabels={$x_0$, $x_{1/2}$, $x_1$,$x_{3/2}$,$x_2$,$x_{5/2}$,$x_3$,,,,$x_{N-1}$,$x_{N-\frac{1}{2}}$,$x_N$},
                axis on top,
                xticklabel style={rotate=-45,anchor=north west,yshift=5pt}
                ]
                \addplot [integral fill=cyan!15] {f(x)} \closedcycle;
                \addplot [very thick, cyan!75!blue] {f(x)} node [anchor=south] {$y=f(x)$};
                \addplot [integral line=black] {f(x)};
                \addplot [integral, ycomb] {f(x)};
                \end{axis}
                \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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