# Height function for 3D drawing

I've been drawing 2D features in 3D space using code like the following:

\begin{tikzpicture}[x={(-0.2cm,-0.4cm)}, y={(1cm,0cm)}, z={(0cm,1cm)}]{
\begin{scope}[canvas is yx plane at z=1]
\draw[fill=blue,opacity=0.3] (0,0) circle (3cm);
\end{scope}
\end{tikzpicture}


I'd now like to distort the z-coordinate of the scope in which I am drawing. That is, instead of just drawing at height z=1, I'd like z to be a function of x and y.

Is this (relatively speaking) easily possible? If it helps, I think in the end all I'd like to have is something piecewise with z = x^2 up to some fixed x, and then a constant value after that.

• Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. it's much easier to help you if we have full working code to start from. – Andrew Sep 30 '19 at 11:55

Yes, it is possible to declare your own coordinate system. As Andrew says, you may want to make your example a bit more specific and complete, but here is something that tells you how that works.

\documentclass[tikz,border=3mm]{standalone}
\makeatletter
\define@key{weirdkeys}{x}{\def\myx{#1}}
\define@key{weirdkeys}{y}{\def\myy{#1}}
\define@key{weirdkeys}{z}{\def\myz{#1}}
\tikzdeclarecoordinatesystem{weird}%
{%
\setkeys{weirdkeys}{#1}%
\pgfpointxyz{\myx}{\myy}{\myz+\myx*\myx}
}
\makeatother
\begin{document}
\begin{tikzpicture}[x={(-0.2cm,-0.4cm)}, y={(1cm,0cm)}, z={(0cm,1cm)}]
\foreach \X in {1,2,3}