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 ?
    – percusse
    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.
    – Dilawar
    Sep 22, 2016 at 6:05

1 Answer 1


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':
    % 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}},
] {1000} \mydata
% show it:

    , every node/.style={}
        \addplot[ only marks, color = blue ] table [
            , x expr=abs(abs(\thisrowno{0}) - abs(\thisrowno{1}))
            , y expr=abs(\thisrowno{0}+\thisrowno{1})
        ] {\mydata};


pgfplot solution. I could get random sampling easily using <code>pgfplotstables</code>

tikz-datavisualization solution

Almost same but could not get random sampling of interval.

\begin{tikzpicture}[scale=1 , every node/.style={} ]
       scientific axes=clean, visualize as scatter
       , scatter={
               , 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) );


<code>tikz-datavisualization</code> solution. I could not get random sampling between interval.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .