Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Christian Feuersänger for Tufte style range frames for three dimensional plots

EDIT

Recent versions of pgfplots come with axis line shift, which allows us to simplify the style as follows:

\documentclass{standalone}\usepackage{pgfplots}\def\axisdefaultwidth{360pt}\pgfplotsset{  every axis/.append style={thick},tick style={thick,black},  %  range3frame/.style={    tick align=outside,    scaled ticks=false,    enlargelimits=false,    axis lines*=left,    line cap=round,    clip=false,    axis line shift=10pt,  }}\begin{document}\begin{tikzpicture}  \begin{axis}[range3frame,view={55}{45}]    \addplot3[mesh,samples=41,domain=0:360] {sin(x)*sin(y)};  \end{axis}\end{tikzpicture}\end{document}

Image may be NSFW.
Clik here to view.
enter image description here

End of edit


There is no such predefined style.

But here is one defined in 5 lines:

Image may be NSFW.
Clik here to view.
enter image description here

\documentclass{standalone}\usepackage{tikz}\usepackage{pgfplots}\def\axisdefaultwidth{360pt}\pgfplotsset{  every axis/.append style={thick},tick style={thick,black},  %  % #1 = x, y, or z  % #2 = the shift value  /tikz/normal shift/.code 2 args={%    \pgftransformshift{%        \pgfpointscale{#2}{\pgfplotspointouternormalvectorofticklabelaxis{#1}}%    }%  },%  %  range3frame/.style={    tick align=outside,    scaled ticks=false,    enlargelimits=false,    ticklabel shift={10pt},    axis lines*=left,    line cap=round,    clip=false,    xtick style={normal shift={x}{10pt}},    ytick style={normal shift={y}{10pt}},    ztick style={normal shift={z}{10pt}},    x axis line style={normal shift={x}{10pt}},    y axis line style={normal shift={y}{10pt}},    z axis line style={normal shift={z}{10pt}},  }}\begin{document}\begin{tikzpicture}  \begin{axis}[range3frame,view={55}{45}]    \addplot3[mesh,samples=41,domain=0:360] {sin(x)*sin(y)};  \end{axis}\end{tikzpicture}\end{document}

The command \pgfplotspointouternormalvectorofticklabelaxis{x} is a shortcut for \pgfplotspointouternormalvectorofaxis{\pgfplotsticklabelaxisspec{x}}. I fear the documentation for \pgfplotspointouternormalvectorofticklabelaxis is missing in the reference manual.

Note that this shift is incompatible with the grid lines (by construction!). To see this, try to add grid=major and you will see the the descriptions are slightly off. You may need to decide if that is what you want (or how to repair it).


Viewing all articles
Browse latest Browse all 2

Trending Articles