Python 3D Plot made simple, from text file data.

This brief article introduces how you can plot a 3D chart in Python from data that you would store in a data file (.csv or .txt). The exercise may sound trivial but in practice it is not so obvious, especially for a novice python programmer. And on top of this, charting such 3D illustration is a very recurrent use when performing numerical analysis.

In this post we explain how you could plot a rate surface (bootstrapped from a multicurve procedure), arranged by tenor and zero coupon rate maturity.

The data (a 3-column array sorted by maturity/tenor/rate) is attached in the Surface.txt file at the end of this article. I used Visual Studio 2010 and the Python Tools for Visual Studio extension.

This is the output of this code, finally:

3D plot python

3D plot in python matplotlib from text file data