I admit that I may be abusing pgfplots somewhat, but I want to add a plot of a function into a tikz-picture in a certain way. I have now managed to get this to run, I'm just wondering why the line thickness varies, and how to get rid of it, resp. what part of my code is responsible for it (however I can say that it's not the scaling nor the rotation).
I've mostly drawn upon Consistently specify a Function and use it for computation and plotting and How to define a parameterized command to be consumable in \pgfmathdeclarefunction?, and managed to extend it by nesting one further layer of functions with \edef.
As a side note, I'm amazed what \pgfmathparse can deal with (because after expanding all the functions, it's a long expression, and longer still in my actual implementation)
Below is the (cut-to-basics) MWE:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\newcommand{\T}[1]{3*(#1)^2-2*(#1)^3}
\edef\U#1{sin((\T{#1})*pi/2 r)}
\pgfmathdeclarefunction{q}{1}{%
\pgfmathparse{(and(#1>1, #1<2)*\U{#1-1})+(and(#1>=2, #1<4)*\U{2-#1/2})}%
}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{scope} %[very thin]
\draw[->] (0,0) -- (5,0);
\draw[->] (0,0) -- (0,4);
\end{scope}
\draw (1,1) -- (4,4);
\coordinate (x) at (1,1.25);
\pgfmathsqrt{2}
\pgfmathsetmacro{\mysc}{\pgfmathresult}
\begin{scope}[rotate=45,scale=\mysc]
\begin{axis}[
at=(x.north), % doesn't work with explicit coordinate {(1,1.25)}
domain=1:4, samples=200,
hide axis,
ymin=0, ymax=1,
xmin=1, xmax=4,
width=3cm, height=0.5cm, scale only axis,
]
\addplot [cyan] {q(x)};
\end{axis}
\end{scope}
\end{tikzpicture}
\end{document}


at=...disregards an explicit coorinate? – Axel Oct 07 '14 at 23:27