1

I'd like to apply a skew angle (fe) to my plot, similarly to what's shown in the image on the right.In addition, it is better when I change view={0}{90},also it works

enter image description here

    \documentclass[border=5mm]{standalone}   
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{colorbrewer}

\begin{document}
\begin{tikzpicture}[yscale=0.5]
\begin{axis}[
domain=-180:180,
samples=50,
view={0}{90},
colormap/PiYG,
hide axis,
]
\addplot3 [surf] { cos(x)*cos(y) / 5};
\end{axis}
\end{tikzpicture}
\end{document}
sayros
  • 2,629

1 Answers1

0

My favorite macro (Cunning (La)TeX tricks), which was provided by Bruno at Shear transform a "box", named \slantbox[]{}. The optional argument is the tangent of the slant angle (\phi in the notation of the OP).

Requires pdflatex, as it uses pdf "specials".

\documentclass[border=5mm]{standalone}   
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{colorbrewer}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][.5]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\begin{document}
\setbox0=\hbox{\begin{tikzpicture}[yscale=0.5]
\begin{axis}[
domain=-180:180,
samples=50,
view={0}{90},
colormap/PiYG,
hide axis,
]
\addplot3 [surf] { cos(x)*cos(y) / 5};
\end{axis}
\end{tikzpicture}}
\slantbox[.5]{\box0}\kern14mm
\end{document}

enter image description here

  • @sayros You are welcome. I noticed you have asked many questions over time, but have not "accepted" any of the answers provided, which is the way to give credit to the answer that best answers your question. If you are satisfied with one particular answer (if several are given), you click on the check next to the answer to "accept" it. This gives credit to the answerer and tells the reader what you found most useful. For any question or answer not your own, you can click the up arrow next to the Q or A to "upvote", indicating that you found the Q or A "useful". – Steven B. Segletes Aug 31 '16 at 18:03