# Mesh3d Generating Inaccurate Meshes

**URL:** <https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445>\
**Category:** plotly.js\
**Created:** [July 2, 2016, 10:13pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445 "2016-07-02T22:13:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattshax](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mattshax](https://community.plotly.com/u/mattshax)\
**Post date:** [July 2, 2016, 10:13pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/1 "2016-07-02T22:13:07Z")

</div>

Hi, I have noticed some strange behavior using both ployly.js and plotly.py, and was wondering if anyone had suggestions on how I might fix it…

When I attempt to plot my particular dataset with Mesh3d, it does render the Mesh, but it also shows a few surfaces that shouldn’t be there - particularly around the edges of the plot, connecting one corner to the another.

The below images showcase this issue (generated via plotly.py) - notice the two edges highlighted and the extra planes that are created connecting the corners (mesh should follow the black dots):

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/0787150c77003c6a2bf0ee02f17aae530b529a31.png)

I also attempted to build a similar mesh directly on Plotly online, and had better success - the [link here](https://plot.ly/~mattshax/2/?share_key=ki0Il3qWtjnndMhLuvAein) is the working plotly online version of a similar dataset / plot.

Below is the python code and dataset I am using to generate the plot (note I am seeing the exact same issue when running plotly.js as well):

[Sample Mesh Data Here (test\_data\_surf.spd)](https://www.dropbox.com/s/7a0bpjrpc7d9iaf/test_data_surf.spd?dl=0)

```auto
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np

pts=np.loadtxt('test_data_surf.spd',skiprows=1)
x,y,z=zip(*pts)

trace1 = go.Mesh3d(x=x,y=y,z=z,color='90EE90',opacity=0.5,showscale=False) 
trace2 = go.Scatter3d(x=x,y=y,z=z,mode='markers',marker=dict(color='rgb(0, 0, 0)',size=2,opacity=0.6))

data = [trace1,trace2]
fig = go.Figure(data=data)
plot(fig, filename="graph_py.html", auto_open=False,show_link=False)

```

Any suggestions on what may be causing this issue?

Thanks,  
Matthew

---

<div class="post-metadata">

**Author:** ![mattshax](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mattshax](https://community.plotly.com/u/mattshax)\
**Post date:** [July 4, 2016, 10:53am UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/2 "2016-07-04T10:53:39Z")

</div>

The link here is a live version of the issue I am seeing (this one generated using plotly.js):

[http://dev.parallel.works/dakota\_graphs/surfpack.html](http://dev.parallel.works/dakota_graphs/surfpack.html)

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [July 4, 2016, 4:23pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/3 "2016-07-04T16:23:24Z")

</div>

Thanks for writing in.

> [@mattshax](#):
>
> I also attempted to build a similar mesh directly on Plotly online, and had better success

It this result correct? Or just better?

Plotly online, plotly.py and plotly.js all use the same plotting code (that is plotly.js) to render graphs. Maybe something is up with your dataset.

---

<div class="post-metadata">

**Author:** ![mattshax](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mattshax](https://community.plotly.com/u/mattshax)\
**Post date:** [July 4, 2016, 8:04pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/4 "2016-07-04T20:04:14Z")

</div>

Thanks for the response etienne…

I just retried to generate the same graph using Plotly online, and it actually appears to be generating the same error.

The online graph is here: [https://plot.ly/~mattshax/18/](https://plot.ly/~mattshax/18/)

Image of the graph on Plotly online is below (drew red areas on the problem area):

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/6ced5a3334b044c53b439ef362205324e28b9660.png)

If is it something with my dataset, do you have suggestions on how to best fix it? I have noticed these rogue surfaces appearing on multiple similar datasets.

Thanks,  
Matthew

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [July 4, 2016, 8:25pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/5 "2016-07-04T20:25:26Z")

</div>

Thanks for the link.

I’ll examine it and see whether it’s our fault (or yours).

Thanks for using plotly!

---

<div class="post-metadata">

**Author:** ![mattshax](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mattshax](https://community.plotly.com/u/mattshax)\
**Post date:** [July 7, 2016, 2:00pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/6 "2016-07-07T14:00:08Z")

</div>

Hi etienne, just wondering if you were able to find anything out about this issue?

Thanks,  
Matthew

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [July 7, 2016, 2:13pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/7 "2016-07-07T14:13:45Z")

</div>

I looked at it briefly and nothing abnormal stuck out.

Have you tried plotting the same data set with a different graphing library?

---

<div class="post-metadata">

**Author:** ![archmoj](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/archmoj/32/8388_2.png) [@archmoj](https://community.plotly.com/u/archmoj)\
**Post date:** [November 22, 2019, 3:00pm UTC](https://community.plotly.com/t/mesh3d-generating-inaccurate-meshes/1445/8 "2019-11-22T15:00:23Z")

</div>

All these demos look fine to me:  
[4x4 grid](https://codepen.io/MojtabaSamimi/pen/oNNOeyq?editors=0010)  
[5x4 grid](https://codepen.io/MojtabaSamimi/pen/JjjVrPv?editors=0010)  
[4x5 grid](https://codepen.io/MojtabaSamimi/pen/gOOyxyJ?editors=0010)  
@mattshax would you mind finding the minimal dataset that cause this problem?
