# Awesome MATLAB surf Charts with Plotly

**URL:** <https://community.plotly.com/t/awesome-matlab-surf-charts-with-plotly/56644>\
**Category:** Plotly for MATLAB®\
**Created:** [September 16, 2021, 1:35am UTC](https://community.plotly.com/t/awesome-matlab-surf-charts-with-plotly/56644 "2021-09-16T01:35:24Z")\
**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 16, 2021, 1:35am UTC](https://community.plotly.com/t/awesome-matlab-surf-charts-with-plotly/56644/1 "2021-09-16T01:35:24Z")

</div>

[surf](https://www.mathworks.com/help/matlab/ref/surf.html) is a MATLAB function that allows us to **plot surfaces**. With this function we can create impressive three-dimensional Charts in MATLAB. However, using `fig2plotly` we can enhance these Charts taking advantage of the elegance that Plotly has.

To handle `surf` with `fig2plotly` it is necessary to set the optional parameter `'TreatAs'` to `'surf'`. Let’s see an example below

```auto
[X,Y,Z] = peaks(25);
CO(:,:,1) = zeros(25); % red
CO(:,:,2) = ones(25).*linspace(0.5,0.6,25); % green
CO(:,:,3) = ones(25).*linspace(0,1,25); % blue
surf(X,Y,Z,CO);

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

```

If we execute the previous code, the result that we will obtain is the following

 ![Screen Shot 2021-09-10 at 11.29.30 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/9/c98b2df3bc053e7e424beb18dd04956622ea0bd3.jpeg)

On the left we find the surface generated by MATLAB, while on the right we can delight in the elegance created by `fig2plotly`. Amazing and easy! Right? 🙌

[Here](https://chart-studio.plotly.com/~galvisgilberto/4214/#/) you can find Plotly’s Chart in Chart-Studio. Please follow that link so you can experience the beauty of Plotly.

Following this [link](https://github.com/plotly/ssim_baselines/tree/main/matlab/code-examples/surface-and-mesh-plots/surf) you can find more examples using `surf`, which you can recreate using `fig2plotly`. Please try to do it! I did it and was fascinated! 😆 I attach below screenshots with results I got

 ![Screen Shot 2021-09-10 at 11.27.58 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/5/f5726c4120949278b39994554072fbcd038352e1.jpeg)  
 ![Screen Shot 2021-09-10 at 11.30.14 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/7/c74dcfde7bb53287d768684ef1676ec759c89570.jpeg)  
 ![Screen Shot 2021-09-10 at 11.32.43 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/6/0/6065bb318849ec4284b5b58a43e478aa21c88afd.jpeg)  
 ![Screen Shot 2021-09-10 at 11.28.31 PM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/0/707a492bf9f88dd276193aee887d9d4b27cd7a06.jpeg)
