# Drawing contour plot under surface using MATLAB's surfc function and Plotly!

**URL:** <https://community.plotly.com/t/drawing-contour-plot-under-surface-using-matlabs-surfc-function-and-plotly/56750>\
**Category:** Plotly for MATLAB®\
**Created:** [September 19, 2021, 12:26am UTC](https://community.plotly.com/t/drawing-contour-plot-under-surface-using-matlabs-surfc-function-and-plotly/56750 "2021-09-19T00:26:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilbertogalvis](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/gilbertogalvis/32/16377_2.png) [@gilbertogalvis](https://community.plotly.com/u/gilbertogalvis)\
**Post date:** [September 19, 2021, 12:26am UTC](https://community.plotly.com/t/drawing-contour-plot-under-surface-using-matlabs-surfc-function-and-plotly/56750/1 "2021-09-19T00:26:22Z")

</div>

With MATLAB we can create a _3-D surface plot with a contour plot underneath_. For this MATLAB has reserved the function `surfc(X,Y,Z)`. The figure generated by MATLAB is really captivating. In this post we will see what the equivalent version created by Plotly using `fig2plotly` looks like. I can tell you that it is something exquisite 😋

To achieve this with `fig2plotly`, we again need to resort to the optional `'TreatAs'` parameter, setting it to `'surfc'`. Let’s see how this would be with an example

```auto
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);

sc = surfc(X,Y,Z);
sc(1).EdgeColor = 'yellow';

fig2plotly(gcf, 'offline', false, 'TreatAs', 'surfc');

```

After we run the MATLAB code above, the results we would get looks like this

 ![Screen Shot 2021-09-16 at 10.09.49 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/6/6/6656ed665ad616ff4f2aa3a2f8bd22471164f31f.jpeg)

As I mentioned before, MATLAB version (on the left) is compelling. But Plotly version (on the right) is really sweet

If you want to experience this on your own at Plotly Chart-Studio, please follow [this link](https://chart-studio.plotly.com/~galvisgilberto/4420/#/). I am inviting you to what you are doing. You will not regret! 😍

In [this repository folder](https://github.com/plotly/ssim_baselines/tree/main/matlab/code-examples/surface-and-mesh-plots/surfc) you can find more examples using MATLAB’s `surfc` functionality. Please feel free to recreate those examples with `fig2plotly` using what is explained in this post 🤙

Attached below more results that I obtained from my side 🙃

 ![Screen Shot 2021-09-16 at 10.07.35 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/e/cea1f1ece56015be9bd9c999bc8731bb8d7efa7f.jpeg)  
 ![Screen Shot 2021-09-16 at 10.08.00 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/b/b/bba28988668e27a1eda596f44478593c9c97de2d.jpeg)  
 ![Screen Shot 2021-09-16 at 10.08.24 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/d/f/df58cd41f37512e18930065d8dc6e903e1d3ed5b.jpeg)  
 ![Screen Shot 2021-09-16 at 10.08.48 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/a/7/a7b877dfc99c3e62437efe1140d1b6417fcea52a.jpeg)  
 ![Screen Shot 2021-09-16 at 10.09.24 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/4/4438d9c6db93d61cc4e08a32b789b9e5de13207d.jpeg)
