pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
200 stars 35 forks source link

Provide a "school book axes" option #304

Open pgf-tikz-bot opened 7 years ago

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/feature-requests/70/ Author: denisbitouze Timestamp: 2017-03-25 08:12:06.129000

A plot created with pgfplots doesn't look by default like the ones in "school books".

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    % axis lines=center,
    % extra x ticks=0,
    % extra x tick style={
    %   tick label style={
    %     anchor=north east,
    %     xshift=-.5*\pgfkeysvalueof{%
    %       /pgfplots/major tick length%
    %     },
    %   }
    % }
  ]
  \addplot {x^2-10};
\end{axis}
\end{tikzpicture}
\end{document}

On the other hand, tikz's school book axes option is both helpfull and simple in this respect.

Hence it would be nice for pgfplots to provide a school book axes option as well.

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/feature-requests/70/#cdaa Author: symbol-1 Timestamp: 2017-06-18 15:40:22.637000

Comment: As the source code and the example in the pgfmanual suggest, the dv's school book axes does not compensate the major tick length.

By the way, school book axes/standard labels corresponds to x label style={right} and y label style={above}. These options should be a consequence of axis lines=center.

If I read correctly, the default anchor is decided by the following (pgfplots.code.tex line 2881)

        \ifnum\pgfplots@yaxislinesnum=3 % if 'axis y line==right' then
            \pgfkeysalso{/pgfplots/every axis x label/.style={
                /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
        \else
            \pgfkeysalso{/pgfplots/every axis x label/.style={
                /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:1)},anchor=near ticklabel opposite}}%
        \fi

This distinguishs right. But does not distinguish between left and middle. Hence I need extra x label style={right}.

My MWE is

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
     axis lines=center,
     xlabel={$x$},x label style={right},
     ylabel={$f(x)$},y label style={above},
     extra x ticks=0,
     extra x tick style={
       tick label style={
         anchor=north east,
         %xshift=-.5*\pgfkeysvalueof{   % A philosophical question:
         %  /pgfplots/major tick length % Do we really need to
         %},                            %   compensate this length?
       }
     }
  ]
  \addplot {x^2-10};
\end{axis}
\end{tikzpicture}
\end{document}

PS. I did not pay attention in school. I do not have a clear idea what textbooks should look like.