# Transform both axes in tikz, plot f(x,y) vs g(x,y) where x, and y are Cartesian axis

It is easy to do with \addplot3 but I want a 2d plot.

I want to plot a scatter plot: g(x,y) value on vertical axis and f(x,y) on horizontal axis. AFAIK, The parametric plot syntax allows only one axis value as its argument e.g. How to plot functions like ‎‎‎‎‎x=f(y)‎‎ using TikZ?

Any solution which uses tikz-datavisualization, pgfplot or gnuplot is fine.

• Did you try \addplot with keys x expr, y expr ? Sep 22, 2016 at 6:02
• @percusse Thanks. I was bit successful with datavisualization library using func x and func y. I'll try now. Sep 22, 2016 at 6:05

I managed to do it using both pgfplot and tikz-datavisualization. Though pgfplot solution is better.

# Pgfplot solution

% create a new table with 10 rows and columns 'x' and 'y':
\pgfplotstablenew
[
% define how the 'new' column shall be filled:
create on use/x/.style ={ create col/expr ={100*rand}},
create on use/y/.style ={ create col/expr ={100*rand}},
columns={x,y}
] {1000} \mydata
% show it:
%\pgfplotstabletypeset\mydata

\begin{tikzpicture}[scale=1
, every node/.style={}
]
\begin{axis}[
xlabel=$||x|-|y||$,ylabel=$|x+y|$
]
\addplot[ only marks, color = blue ] table [
, x expr=abs(abs(\thisrowno{0}) - abs(\thisrowno{1}))
, y expr=abs(\thisrowno{0}+\thisrowno{1})
] {\mydata};
\end{axis}

\end{tikzpicture}


# tikz-datavisualization solution

Almost same but could not get random sampling of interval.

\begin{tikzpicture}[scale=1 , every node/.style={} ]
\datavisualization[
scientific axes=clean, visualize as scatter
, scatter={
style={mark=*
, mark options={color=blue,mark size=2pt} }
}
]
data[ format=function ] {
var i : interval [-100:100];
var j : interval [-100:100];
func y = abs(\value i + \value j) ;
func x = abs( abs(\value i) - abs(\value j) );
};

\end{tikzpicture}