As a follow up to an earlier question, How can I use Contour plots in a skew domain?
I'd like to apply a trapezoidal angle (fe) to my plot, similarly to what's shown in the image on the right.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityAs a follow up to an earlier question, How can I use Contour plots in a skew domain?
I'd like to apply a trapezoidal angle (fe) to my plot, similarly to what's shown in the image on the right.
I relied on my answer at Gimp-like perspective transform in TikZ to taper an image. Because it only tapers left to right, I had to do a double rotation to taper front to back.
In addition, pgfplots is such a memory hog that I had memory overflow issues, according to this question, How to expand TeX's "main memory size"? (pgfplots memory overload). So rather than deal with externalized plots and such, I took your code at the referenced question (with a 0mm border) to generate the basic un-transformed rectangular image and saved it as myplot.pdf.
Then I relied on my above referenced answer to employ this code which I do not think fixes the perspective problem, originally pointed out by Andrew Kepert in comment to my answer at Gimp-like perspective transform in TikZ. That is to say, while the given straight lines of the OP's problem remain straight under this transformation, one can see that the original diagonals of the figure no longer are straight under this transformation.
\documentclass{article}
\usepackage{ifthen,trimclip,calc,fp,graphicx,xcolor}
\newsavebox\mytext
\newcounter{mycount}
\newlength\clipsize
\newcommand\tapertext[5][0]{%
\edef\neck{#3}% percent to depress the amplitude
\def\cuts{#4}% Number of cuts
\savebox{\mytext}{#5}% TEXT
\FPeval{\myprod}{1/cuts}%
\clipsize=\myprod\wd\mytext\relax%
\setcounter{mycount}{0}%
\whiledo{\value{mycount}<\cuts}{%
\stepcounter{mycount}%
\edef\NA{\themycount}%
\edef\NB{\the\numexpr\cuts-\themycount\relax}%
\FPeval{\myprod}{\NA/\cuts}%
\ifnum0#1=0\relax%
\FPeval{\myprod}{1 - \neck*(\myprod)}%
\else%
\FPeval{\myprod}{1 - \neck*(1-\myprod)}%
\fi%
\FPmul{\myprodB}{\myprod}{\myprod}%
\scalebox{\myprod}[1]{\clipbox{%
\value{mycount}\clipsize\relax{} %
-1pt %
\wd\mytext-\value{mycount}\clipsize-\clipsize\relax{} %
-1pt%
}%
{\raisebox{#2\dimexpr\ht\mytext-\myprodB\ht\mytext}{%
\scalebox{1}[\myprodB]{\usebox{\mytext}}}}%
}}%
}
\begin{document}
\rotatebox{90}{\tapertext{.00}{.25}{99}{\rotatebox[origin=left]{-90}{\includegraphics{myplot}}}}
\end{document}
It took the previously generated rectangular image and (after rotation), did 99 vertical slices on it, and scaled and raised as necessary each ribbon slice. Finally it rotated the image back to the original orientation.
The problem is the parameters to \tapertext
do not necessarily correspond to desired angles, etc. The first mandatory parameter effects the left/right skew (a value of 1.0
makes the left edge vertical) while the second mandatory argument (#3
) is related to the net shrinkage of the tail of the image relative to the front (namely, the back edge length is (1 - #3
^2) times the front -edge length and a value of 1.0
tapers the image to the vanishing point). Using \rotatebox{90}{\tapertext{.10}{.50}{99}{\rotatebox[origin=left]{-90}{\includegraphics{myplot}}}}
produces, for example, this: