1

I am using Texpad on Mac. I made a figure with 3 plots using pgfplots. It worked a few days ago but when I opened the file today, it failed to produce the pdf. It showed no error during the compiling. Does anyone know what the reason could be?

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[sc]{mathpazo}
\usepackage{amsmath,amssymb,amsfonts,mathrsfs}
\usepackage[amsmath,thmmarks]{ntheorem}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{geometry}
\usepackage{booktabs,makecell,longtable}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage{balance} 
\usepackage{lastpage}
\usepackage{amsmath,bm}
\usepackage{textcomp}
\usepackage{subeqnarray}
\usepackage{float}
\usepackage{mathtools}
\usepackage{cite}
\usepackage[export]{adjustbox}
\usepackage{etoolbox}
\usepackage{enumitem}
\usepackage{lmodern}
\usepackage[labelfont=bf,font=sf,labelsep=space]{caption}
\usepackage{mathpazo}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\pgfkeys{/pgf/number format/.cd,1000 sep={}}


\newcommand{\myfont}{\fontfamily{cmss}\selectfont}% used with mathpazo 

\DeclareMathOperator{\Tr}{Tr}

\setcounter{tocdepth}{2}

\pgfplotsset{compat=1.5.1}
\pgfplotsset{label style={font=\Large},
            tick label style={font=\Large}}

\pgfplotsset{error bars/.cd,
    x dir=both, x explicit,
    y dir=both, y explicit,
    }
\pgfplotsset{/pgfplots/error bars/error bar style={semithick,black}}
%\pgfplotsset{/pgfplots/label shift={0pt}}


\begin{document}


\begin{figure}
\centering

\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=7cm,
    legend image post style={mark options={scale=1}},
    legend style={at={(0.95,10.9)},draw=none,
        legend style={row sep=1pt},
        legend style={column sep=3pt}},
    legend cell align={left},
    x tick style={black,semithick},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$E$} [{\myfont GPa}]},
    ymin=0,ymax=5,
    ytick={0,1,...,5},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
        table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     1.98        0.07
        1       2.06        0.07
        10      1.94        0.1
        100     2.06        0.15
        1000    2.2     0.12
    };
    \addlegendentry{\myfont machine direction}

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     2.24        0.18
        1       2.46        0.11
        10      1.92        0.07
        100     2.58        0.23
        1000    2.3     0.32
    };
    \addlegendentry{\myfont transverse direction}

    \addplot [black,dashed,semithick] table [x=x, y=y] {
        x       y
        0.05    2.1
        2000    2.1
    };

\end{axis}
\end{tikzpicture}


\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=7cm,
    x tick style={black,semithick},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$\sigma_{max}$} [{\myfont MPa}]},
    ymin=0,ymax=150,
    ytick={0,50,...,150},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
         table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     89.4    5.9
        1       88.2        3.75
        10      79.4        2.61
        100     84.4        5.26
        1000    86.2        7.19
    };

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     101.7   12.04
        1       114     6.45
        10      82.1        0.6
        100     103.7   8.56
        1000    91.3        7.61
    };

    \addplot [black,dashed,semithick] table [x=x, y=y] {
        x       y
        0.05    63
        2000    63
    };

\end{axis}
\end{tikzpicture}


\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=7cm,
    x tick style={black,semithick},
    x label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    xlabel={{$t_a$} [{\myfont h}]},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$\epsilon_{max}$} [{\myfont -}]},
    ymin=0,ymax=1.5,
    ytick={0,0.5,...,1.5},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
         table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     0.8     0.06
        1       1       0.08
        10      0.8     0.1
        100     1       0.07
        1000    1       0.08
    };

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     0.8     0.1
        1       0.7     0.08
        10      1.2     0.04
        100     0.7     0.06
        1000    0.9     0.09
    };

    \addplot [black,dashed,thick] table [x=x, y=y] {
        x       y
        0.05    0.045
        2000    0.045
    };

\end{axis}
\end{tikzpicture}
\end{figure}


\end{document}
  • The issue is legend style={at={(0.95,10.9)},..., try legend style={at={(0.95,0.9)} instead. – user121799 Feb 4 at 4:45
0

The culprit is legend style={at={(0.95,10.9)},.... This moves the legend so far up that the plot is moved below the lower boundary of the page, which makes it disappear. Note that these coordinates are in "plot units", so the y unit is roughly the height of the plot. If one uses legend style={at={(0.95,0.9)},..., say, instead, the plots reappear.Other than that you are loading a lot of packages that are not related to the problem, and are using a very old version of pgfplots. And I decreased the heights of the plot a bit such they fit well on a page.

\documentclass{article}
\usepackage{pgfplots}

\pgfkeys{/pgf/number format/.cd,1000 sep={}}


\newcommand{\myfont}{\fontfamily{cmss}\selectfont}% used with mathpazo 


\pgfplotsset{compat=1.16}
\pgfplotsset{label style={font=\Large},
            tick label style={font=\Large}}

\pgfplotsset{error bars/.cd,
    x dir=both, x explicit,
    y dir=both, y explicit,
    }
\pgfplotsset{/pgfplots/error bars/error bar style={semithick,black}}
%\pgfplotsset{/pgfplots/label shift={0pt}}


\begin{document}


\begin{figure}
\centering

\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=6cm,
    legend image post style={mark options={scale=1}},
    legend style={at={(0.95,0.9)},draw=none,row sep=1pt,column sep=3pt},
    legend cell align={left},
    x tick style={black,semithick},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$E$} [{\myfont GPa}]},
    ymin=0,ymax=5,
    ytick={0,1,...,5},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
        table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     1.98        0.07
        1       2.06        0.07
        10      1.94        0.1
        100     2.06        0.15
        1000    2.2     0.12
    };
    \addlegendentry{\myfont machine direction}

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     2.24        0.18
        1       2.46        0.11
        10      1.92        0.07
        100     2.58        0.23
        1000    2.3     0.32
    };
    \addlegendentry{\myfont transverse direction}

    \addplot [black,dashed,semithick] table [x=x, y=y] {
        x       y
        0.05    2.1
        2000    2.1
    };

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=6cm,
    x tick style={black,semithick},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$\sigma_{max}$} [{\myfont MPa}]},
    ymin=0,ymax=150,
    ytick={0,50,...,150},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
         table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     89.4    5.9
        1       88.2        3.75
        10      79.4        2.61
        100     84.4        5.26
        1000    86.2        7.19
    };

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     101.7   12.04
        1       114     6.45
        10      82.1        0.6
        100     103.7   8.56
        1000    91.3        7.61
    };

    \addplot [black,dashed,semithick] table [x=x, y=y] {
        x       y
        0.05    63
        2000    63
    };

\end{axis}
\end{tikzpicture}


\begin{tikzpicture}[trim axis left]
\begin{axis}[
    xmode=log,
    ymode=normal,
    enable tick line clipping=false,
    axis line style=semithick,
    width=9cm,
    height=6cm,
    x tick style={black,semithick},
    x label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    xlabel={{$t_a$} [{\myfont h}]},
    xmin=0.05,xmax=2000,
    xtick={0.1,1,10,100,1000},
    xtick pos=bottom,
    minor x tick num=9,
    xtick align=outside,
    y tick style={black,semithick},
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={{$\epsilon_{max}$} [{\myfont -}]},
    ymin=0,ymax=1.5,
    ytick={0,0.5,...,1.5},
    ytick pos=left,
    ytick align=outside,    
]
    \addplot [only marks,mark=*,mark options={scale=1.5,blue}]
         table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     0.8     0.06
        1       1       0.08
        10      0.8     0.1
        100     1       0.07
        1000    1       0.08
    };

    \addplot [only marks,mark=square*,mark options={scale=1.5,blue}] table [x=x, y=y, y error=ey] {
        x       y       ey
        0.1     0.8     0.1
        1       0.7     0.08
        10      1.2     0.04
        100     0.7     0.06
        1000    0.9     0.09
    };

    \addplot [black,dashed,thick] table [x=x, y=y] {
        x       y
        0.05    0.045
        2000    0.045
    };

\end{axis}
\end{tikzpicture}

\end{figure}
\end{document}

enter image description here

  • Thank you very much. The rest of the packages are irrelevant but part of my thesis. What you mean by I am using a very old version of pgfplots? – Gagik Feb 4 at 5:22
  • @Gagik I was referring to \pgfplotsset{compat=1.5.1}, which I changed to \pgfplotsset{compat=1.16} in my answer. – user121799 Feb 4 at 5:25
  • 1
    @Gagik they may be relevant to your thesis but you should remove them from small examples posted here as they just make it harder and slower for anyone offering to help to debug your example. – David Carlisle Feb 4 at 7:55

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.