Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to plot a surface plot using TikZ. I have the (x,y) coordinate and the corresponding function value in a table form. I have not done 3D plots before in TikZ and hence I would appreciate any help. I would want a surf plot like this, but I do not have a closed form expression for my function. Instead, I have a table of values as shown below.The (X,Y) values are a two dimensional uniform grid on the domain [0,4] * [0,4].

enter image description here

share|improve this question
9  
Please provide the data in a plain text rather than an image. – Click Me Aug 1 '12 at 19:48

1 Answer

up vote 19 down vote accepted

TikZ cannot do this with builtin methods. pgfplots can do it - in your case with \addplot3[surf, mesh/ordering=x varies] table {myfile.dat}; .

It supports custom colormaps, color bars, draws an appropriate axis, chooses suitable scales, ticks, and ticklabels etc.

See http://pgfplots.sourceforge.net/pgfplots.pdf for details and examples.


By default, pgfplots assumes numerical input (i.e. 0.29 instead of 29/10). If your data file really looks like

X Y Z
0 0 29/10
...

you need to write \addplot3.... table[z expr=\thisrow{Z}] {myfile.dat}; in order to activate math expression parsing for that column.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.