0

I am plotting a graph using pgfplots wherein both axes are on the log scale. I am not able to see minor ticks on y-axis, though there is nothing that should prevent it from appearing.

\documentclass[a4paper, 10pt]{article}
\usepackage[margin = 1in]{geometry}
\usepackage{tikz}
\usepackage{filecontents,pgfplots,pgfplotstable}
%\usepackage{subfigure} % The subfig package replaces the older subfigure package - don't use both of them at the same time.
\usepackage{subfig}
\usepackage{graphicx}
\usepackage[font=normalsize]{caption}  % Float captions.
\usetikzlibrary{backgrounds,automata}
\definecolor{color0}{rgb}{0, 0, 0}
\definecolor{color1}{rgb}{0.82, 0.1, 0.26}
\definecolor{color2}{rgb}{0.6, 0.4, 0.8}
\definecolor{color3}{rgb}{0.2, 0.76, 0.30}
\definecolor{color4}{rgb}{0.90, 0.40, 0.12}
\definecolor{color5}{rgb}{0.0, 0.5, 0.0}
\definecolor{color6}{rgb}{0.23, 0.27, 0.29}
\definecolor{color7}{rgb}{0.53, 0.2, 0.16}
\definecolor{color8}{rgb}{0.15, 0.6, 0.8}
\definecolor{color9}{rgb}{0.32, 0.40, 0.50}
\begin{filecontents}{fig-4-Y50-JAlloy-2013-symb.dat}
    0.016869759 37.76681404 0.171784179 49.91678965 1.796861093 69.29523177 16.11211768 89.71949457
    0.020291403 47.3637568  0.206871669 64.18916607 2.170245764 85.47469296 19.32197383 109.0979367
    0.025325377 65.6656188  0.258560657 88.24304183 2.722088317 117.6182993 24.02869179 126.353978
    0.032197345 86.12064103 0.329227157 115.2805825 3.479324598 143.8253353 30.42976865 155.7292355
    0.042474166 123.3703131 0.435083319 151.9150659 4.618347053 166.802631  39.96197531 175.9689417
\end{filecontents}
\begin{document}
\pgfplotstableread{fig-4-Y50-JAlloy-2013-symb.dat}{\YfiftyJAlloySymb}
\begin{figure}[!h]
\centering
\captionsetup[subfloat]{farskip=2pt,captionskip=2pt}
\subfloat[][]{
    \begin{tikzpicture}[]
    \begin{loglogaxis}[
        xlabel={$t(s)$},
        ylabel={$x(m)$},
        legend style={at={(0.7,0.25)},anchor=west},
        legend columns=1,
        % for log axes, x filter operates on LOGS.
        % and log(x * 1000) = log(x) + log(1000):
        xmin = 0.005,
        tick align=inside,
        minor tick num=7,
        ymin = 30, ymax = 200,
        yticklabels={$10$, $10^1$, $10^2$, $10^3$},
        log basis x=10,
        log base 10 number format code/.code={$-10^{\pgfmathprintnumber{#1}}$},
    ]
    \addplot[only marks, line width=1.5, color = color0] table [x index = {0}, y index = {1}] {\YfiftyJAlloySymb};
    \addplot[only marks, line width=1.5, color = color1] table [x index = {2}, y index = {3}] {\YfiftyJAlloySymb};
    \addplot[only marks, line width=1.5, color = color2] table [x index = {4}, y index = {5}] {\YfiftyJAlloySymb};
    \addplot[only marks, line width=1.5, color = color3] table [x index = {6}, y index = {7}] {\YfiftyJAlloySymb};
    \legend{$\,$ 493 K, $\,$ 533 K, $\,$  573 K, $\,$  613 K, $\,$  653 K}
    \end{loglogaxis}
    \end{tikzpicture}
}
\end{figure}
\end{document}
1

Too long for a comment.

That is because your y range is too narrow with less than a decade. So the easiest solution would be to simply draw the y-axis linearly (instead of logarithmic). If this is not an option you can add the minor ticks "by hand" using minor y tick option (see code below).

(Your code also shows that you override the default yticklabels with "other" values. Of course if you do that it is much harder to add the "right" minor ticks.)

% used PGFPlots v1.17
    \begin{filecontents}{fig-4-Y50-JAlloy-2013-symb.dat}
        0.016869759 37.76681404 0.171784179 49.91678965 1.796861093 69.29523177 16.11211768 89.71949457
        0.020291403 47.3637568  0.206871669 64.18916607 2.170245764 85.47469296 19.32197383 109.0979367
        0.025325377 65.6656188  0.258560657 88.24304183 2.722088317 117.6182993 24.02869179 126.353978
        0.032197345 86.12064103 0.329227157 115.2805825 3.479324598 143.8253353 30.42976865 155.7292355
        0.042474166 123.3703131 0.435083319 151.9150659 4.618347053 166.802631  39.96197531 175.9689417
    \end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \definecolor{color0}{rgb}{0, 0, 0}
    \definecolor{color1}{rgb}{0.82, 0.1, 0.26}
    \definecolor{color2}{rgb}{0.6, 0.4, 0.8}
    \definecolor{color3}{rgb}{0.2, 0.76, 0.30}
\begin{document}
\begin{tikzpicture}
        \pgfplotstableread{fig-4-Y50-JAlloy-2013-symb.dat}{\YfiftyJAlloySymb}
    \begin{loglogaxis}[
        xlabel={$t$ / s},
        ylabel={$x$ / m},
        legend style={at={(0.7,0.25)},anchor=west},
        legend columns=1,
        xmin=0.005,
        ymin=30,
        ymax=200,
%        minor tick num=7,
%        yticklabels={$10$, $10^1$, $10^2$, $10^3$},
%        log basis x=10,
%        log base 10 number format code/.code={$-10^{\pgfmathprintnumber{#1}}$},
        % ---------------------------------------------------------------------
        % added stuff
        % ---------------------------------------------------------------------
        ytick={50,100,150},
        minor ytick={30,40,...,200},
        log ticks with fixed point,
        only marks,
        mark options={mark=*},
        % ---------------------------------------------------------------------
    ]
        \addplot+ [color=color0] table [x index=0,y index=1] {\YfiftyJAlloySymb};
        \addplot+ [color=color1] table [x index=2,y index=3] {\YfiftyJAlloySymb};
        \addplot+ [color=color2] table [x index=4,y index=5] {\YfiftyJAlloySymb};
        \addplot+ [color=color3] table [x index=6,y index=7] {\YfiftyJAlloySymb};
        \legend{493 K, 533 K, 573 K, 613 K, 653 K}
    \end{loglogaxis}
\end{tikzpicture}
\end{document}

image showing the result of above cod

4
  • Thanks, Stefan. What is the role of the option "log ticks with fixed point"? – Parag Nov 6 '20 at 5:02
  • The shortest explanation is: Comment the line and you will find out yourself ;) – Stefan Pinnow Nov 6 '20 at 7:18
  • I guess you did find out what log ticks with fixed point is good for, right? If my answer helped you or even solved your problem, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). Thank you. – Stefan Pinnow Nov 10 '20 at 19:54
  • No, your comment did not solve my problem. I knew that the range is narrow so it is not showing automatically. I still wanted to put minor ticks. Besides, "try yourself" is not an answer. Still, I have clicked "up". Thanks for your efforts. – Parag Dec 8 '20 at 7:27

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.