2

Consider the following MWE (mostly copy-pasted from this example) :

\documentclass[12pt,%                      
               a4paper,]{scrreprt}                 
\usepackage{pgfplots}
\usepackage{tikzscale}
\pgfplotsset{compat=newest}


\pgfplotsset{
  every axis legend/.append style =
    {
      cells = { anchor = east },
      draw  = none
    }
}

\pgfplotsset{
  c v/.style =
    {
      every x tick label/.append style  =
        { 
          /pgf/number format/.cd ,
           precision = 1 , 
           fixed         ,
           zerofill
        },
    },
}

\makeatletter
\pgfplotsset{
  tufte axes/.style =
    {
      after end axis/.code =
        {
          \draw ({rel axis cs:0,0} -| {axis cs:\pgfplots@data@xmin,0})
            -- ({rel axis cs:0,0}  -| {axis cs:\pgfplots@data@xmax,0});
          \draw ({rel axis cs:0,0} |- {axis cs:0,\pgfplots@data@ymin})
            -- ({rel axis cs:0,0}  |-{axis cs:0,\pgfplots@data@ymax});
        },
      axis line style = {draw = none},
      tick align      = outside,
      tick pos        = left,
      axis line style = {opacity=0}
    }
}
\makeatother
\usepackage{siunitx}
\usepackage{tikzscale}
\begin{document}
\begin{figure}
\includegraphics[width=1.\textwidth,axisratio=1.618]{myfile.tikz}
\end{figure}
\end{document}

And the myfile.tikz:

\begin{tikzpicture}
\begin{axis}[c v, tufte axes,font={\sffamily},every axis legend/.append style = {at = {(0.9,0.5)}},
ymode=log,
legend entries={{q = \SI{48}{\kilo \pascal}},{q = $96 kPa$}}
]

\addplot [line width=0.30000000000000004pt, blue]
coordinates {
(4.5,1038900)
(4.60606060606061,1138300)
(4.71212121212121,1246900)
(4.81818181818182,1365900)
(4.92424242424242,1494800)
(5.03030303030303,1635200)
(14.5757575757576,1147470000)
(14.6818181818182,1216740000)
(14.7878787878788,1290050000)
(14.8939393939394,1367150000)
(15,1448750000)

};
\addplot [line width=0.30000000000000004pt, green!50.0!black]
coordinates {
(4.5,2073100)
(4.60606060606061,2270700)
(4.71212121212121,2486100)
(4.81818181818182,2720700)
(4.92424242424242,2976300)
(14.5757575757576,2029699999.99999)
(14.6818181818182,2150580000)
(14.7878787878788,2277379999.99999)
(14.8939393939394,2410969999.99999)
(15,2551200000)

};

\end{axis}

\end{tikzpicture}

THe y axis is not plotted, whereas in normal mode (ie, comment ymode=log) it is. How can I fix that?

2
  • In logarithmic scale {axis cs:\pgfplots@data@xmin,0} means draw something from (<finite>,<infinite>). That's why it trips up
    – percusse
    Feb 7, 2015 at 7:17
  • Okay, but how to calculate the log(.) of the ymax/ymin?
    – Pierpaolo
    Feb 7, 2015 at 15:24

1 Answer 1

3

With the new features of PGFPlots this is quite easily achievable. Therefore I adapted this answer.

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        tufte axes/.style={
            separate axis lines,
            axis x line*=bottom,
            axis x line shift=10pt,
            xlabel shift=10pt,
            axis y line*=left,
            axis y line shift=10pt,
            ylabel shift=10pt,
            %
            every axis legend/.append style={
                cells={anchor=east},
                draw=none,
            },
            %
            tick align=outside,
            tick pos=left,
        },
    }
\usepackage{siunitx}
\begin{document}
    \begin{tikzpicture}[
        font={\sffamily},
    ]
        \begin{axis}[
            tufte axes,
            ymode=log,
            legend entries={
                {$q = \SI{48}{\kilo \pascal}$},
                {$q = \SI{96}{\kilo \pascal}$},
            },
            every axis legend/.append style={
                at={(0.9,0.4)},
            },
        ]
            \addplot [line width=0.3pt,blue] coordinates {
                (4.5,1038900)
                (4.60606060606061,1138300)
                (4.71212121212121,1246900)
                (4.81818181818182,1365900)
                (4.92424242424242,1494800)
                (5.03030303030303,1635200)
                (14.5757575757576,1147470000)
                (14.6818181818182,1216740000)
                (14.7878787878788,1290050000)
                (14.8939393939394,1367150000)
                (15,1448750000)
            };
            \addplot [line width=0.3pt,green!50.0!black] coordinates {
                (4.5,2073100)
                (4.60606060606061,2270700)
                (4.71212121212121,2486100)
                (4.81818181818182,2720700)
                (4.92424242424242,2976300)
                (14.5757575757576,2029699999.99999)
                (14.6818181818182,2150580000)
                (14.7878787878788,2277379999.99999)
                (14.8939393939394,2410969999.99999)
                (15,2551200000)
            };
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .