Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-face colors in plot_trisurf #47

Open
deeplycloudy opened this issue Aug 9, 2017 · 5 comments
Open

Per-face colors in plot_trisurf #47

deeplycloudy opened this issue Aug 9, 2017 · 5 comments
Labels
enhancement good first issue If you'd like to contribute with a not to complex problem
Milestone

Comments

@deeplycloudy
Copy link

The docs for pylab.plot_trisurf state that triangles is of shape (N,3) and that color should also be of shape (N, 3), implying that the colors will apply to the triangle faces, not the vertices.

However, the observed behavior (on version 0.4.0a2 from PyPI) is to color the vertices.

colors = np.ones((4,3))*.3
colors[0, 2] = 1.0
colors[3, 2] = 1.0
plot_trisurf([0, 0, 3., 3.], [0, 4., 0, 4.], [1, 0., 0, 1.], 
                triangles=[[0, 2, 3], [0, 3, 1]], color=colors)

screen shot 2017-08-08 at 11 07 16 pm

If the above behavior is as intended? If so, is there another way to set the triangle face color directly?

@maartenbreddels
Copy link
Collaborator

Hi Eric,

I've modified the docs, it is only possible to specify per vertex properties, and these will be interpolated (at least that I know of, for WebGL).
A workaround is thus to duplicate the vertices:

ipv.figure()
colors = np.ones((6,3))*.3
colors[:3, 2] = 1.0
colors[3:, 0] = 1.0
x = [0, 3., 3., 0, 0., 3.]
y = [0, 0., 4., 0, 4., 4.]
z = [1, 0., 1., 1, 0., 1.]
ipv.plot_trisurf(x, y, z, 
                triangles=[[0, 1, 2], [3, 5, 4]], color=colors)
ipv.show()

Maybe it's an idea to have face_colors supported, that would do this automatically.
I've also updated the documentation for this. Let me know if this solves it.

cheers,

Maarten

@deeplycloudy
Copy link
Author

Hi Maarten,

Yes, the docs update will be helpful for others, and for now I can duplicate the vertices as you suggest. I'm doing some tests with fairly large meshes — O(10^6) vertices from a research weather radar — so there is some downside to duplicating, but I should still be ok.

In the future, +1 for face_colors support!

Thanks,
Eric

@deeplycloudy
Copy link
Author

Another thought: I was using the face_colors support in vispy in some earlier tests. Not sure if they also auto-duplicated vertices, or if they used some lower-level GL support for face colors.

@maartenbreddels
Copy link
Collaborator

Thanks, I'll keep this open and dive into it later, maybe it is possible more efficiently.

@maartenbreddels
Copy link
Collaborator

I think this can be done at the kernel side first, I guess face_colors and triangle_colors arguments to plot_* would need to sort out the duplication of vertices manually.

@maartenbreddels maartenbreddels added the good first issue If you'd like to contribute with a not to complex problem label Sep 12, 2018
@maartenbreddels maartenbreddels added this to the Major release milestone Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue If you'd like to contribute with a not to complex problem
Projects
None yet
Development

No branches or pull requests

2 participants