# Plotting the interpolated function in 3D in Scipy

by sneha@openweaver.com Updated: Apr 5, 2023

Solution Kit

An interpolated function is a mathematical function that takes two or more known data points and uses them to estimate values at other points. It is also referred to as a curve fit or a best-fit line. Interpolation can estimate values in an array of data points or create a smooth curve between existing data points.

SciPy is an open source Python library for scientific computing. It provides a wide variety of numerical and statistical routines and provides tools for integrating Fortran code, C code, and C++ code into Python programs. SciPy is widely used in data science, machine learning, and engineering applications.

Plotting an interpolated function in 3D using SciPy creates a 3D surface plot of a function that has been interpolated from a set of data points.

- This type of plot is useful for visualizing the relationship between x, y, and z values and can help to identify trends in the data or any outliers.
- SciPy provides various functions for plotting interpolated functions in 3D, such as griddata, tricontour, and trisurf.

Here is an example of plotting the interpolated function in 3D in Scipy

Fig1: Preview of the code

Fig2: Preview of the Output

### Code

In this solution, we use SciPy to plot an interpolated function in 3D.

### Instructions

- Install Jupyter Notebook on your computer.
- Open terminal and install the required libraries with following commands.
- Install SciPy - pip install scipy
- Install matplotlib - pip install matplotlib
- Install Numpy - pip install numpy
- Copy the snippet using the 'copy' button and paste it into that file.
- Run the file using run button.

I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.

*I found this code snippet by searching for "**Interpolate 3D field using Scipy**"* * in kandi. You can try any such use case!*

### Dependent Libraries

numpyby numpy

The fundamental package for scientific computing with Python.

numpyby numpy

Python 23755 Version:v1.25.0rc1 License: Permissive (BSD-3-Clause)

matplotlibby matplotlib

matplotlib: plotting with Python

matplotlibby matplotlib

Python 17559 Version:v3.7.1 License: No License

If you do not have SciPy that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the SciPy page in kandi.

*You can search for any dependent library on kandi like **SciPy* / * *numpy* / **matplotlib**.*

### Environment Tested

I tested this solution in the following versions. Be mindful of changes when working with other versions.

- The solution is created in Python3.9.6
- The solution is tested on SciPy-Python 1.9.1 version.

Using this solution, we are able to plot the interpolated function in 3D in Scipy.

This process also facilities an easy to use, hassle free method to create a hands-on working version of code which would help us in plotting the interpolated function in 3D in Scipy.

### Support

- For any support on kandi solution kits, please use the chat
- For further learning resources, visit the Open Weaver Community learning page.