question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Questions regarding plotting window and drawing custom surface with colour

See original GitHub issue

Dear Marco,

I just came upon the vtkplotter lib and it seems quite interesting thus I started playing a bit with it. I have two questions though which I couldn’t clearly answer by going through the examples and the issues section.

  1. Is it possible to have interactive action menu on the plotting window so that you can activate/deactivate/adjust axes, grid, take a screenshot, save plot, etc. From what I’ve seen in the examples https://github.com/marcomusy/vtkplotter/blob/master/vtkplotter/examples/pyplot/customAxes.py for the axes you can do that only by code. Is that the only way?
  2. I was testing on an example of mine where I have 4 numpy arrays for the corresponding coordinates of faces/polygons and their corresponding color, something like that:
x = np.array([[-0.93333333, -0.93333333, -0.93333333, -0.93333333],
 [-0.93333333, -0.93333333, -0.93333333, -0.93333333],
 [-1.,         -1.,         -1.,         -1.        ],
 [-1.,         -1.,         -1.,         -1.        ]])

y = np.array([[1., 1., 1., 1.],
 [1., 1., 1., 1.],
 [1., 1., 1., 1.],
 [1., 1., 1., 1.]])

z = np.array([[-1.,         -0.93333333, -0.86666667, -0.8       ],
 [-0.93333333, -0.86666667, -0.8,        -0.73333333],
 [-0.93333333, -0.86666667, -0.8,        -0.73333333],
 [-1.,         -0.93333333, -0.86666667, -0.8       ]])

colormat = np.array([[0.11484721, 0.11484721, 0.11484721],
 [0.11648363, 0.11648363, 0.11648363],
 [0.12010454, 0.12010454, 0.12010454],
 [0.12384401, 0.12384401, 0.12384401]])

Now each column in the x, y, z matrices corresponds to the four 3d coordinates of the quadrangle in an clockwise/anti-clockwise order and each row in the colormat matrix to the face color (it is grayscale as you can see). For example for the first quadrangle you have, something like:

image

My question now is how to draw these quadrangles all together with the corresponding color using vtkplotter. To be honest looking on the examples I couldn’t find something relevant but I might have overlooked.

Also you might get the points in an [x, y, z] form array with numpy as follows in case that this helps somehow:


>>> verts = np.hstack([x.reshape(-1,1,order='F'), y.reshape(-1,1,order='F'), z.reshape(-1,1,order='F')])
>>> verts
array([[-0.93333333,  1.        , -1.        ],
       [-0.93333333,  1.        , -0.93333333],
       [-1.        ,  1.        , -0.93333333],
       [-1.        ,  1.        , -1.        ],
       [-0.93333333,  1.        , -0.93333333],
       [-0.93333333,  1.        , -0.86666667],
       [-1.        ,  1.        , -0.86666667],
       [-1.        ,  1.        , -0.93333333],
       [-0.93333333,  1.        , -0.86666667],
       [-0.93333333,  1.        , -0.8       ],
       [-1.        ,  1.        , -0.8       ],
       [-1.        ,  1.        , -0.86666667],
       [-0.93333333,  1.        , -0.8       ],
       [-0.93333333,  1.        , -0.73333333],
       [-1.        ,  1.        , -0.73333333],
       [-1.        ,  1.        , -0.8       ]])

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ttsesmcommented, Jun 7, 2020

yes that was the problem, I was rendering the lines as:

# stack rays into line segments for visualization as Path3D
ray_visualize = trimesh.load_path(np.hstack((origins, origins + drays * 1.2)).reshape(-1, 2, 3))

taken from the corresponding example. Rendering them instead as:

lines = vp.Lines(origins,drays, c='b')

gives me the same smooth result 😉

1reaction
ttsesmcommented, Jun 7, 2020

I see, well it should be able to add/send a mesh to the child process because you might need to send a custom mesh rather an existing mesh from within the vtkplotter api.

Regarding pathos, you might try to open a new issue in their github account and ask if you cannot figure it out. I am looking at it as well, it seems to be a bit different from the vanilla multiprocessing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Questions regarding plotting window and drawing custom ...
I have two questions though which I couldn't clearly answer by going through the examples and the issues section. Is it possible to...
Read more >
Plot style is not reflected accurately when plotting from AutoCAD
Solution: · Change drawing component colors from TrueColor (RGB) to Index colors (1-255). · Remove and reinstall the affected printer driver. · Set ......
Read more >
plotting - Strange behavior with SliceDensityPlot3D using ...
Strange behavior with SliceDensityPlot3D using custom surfaces, Mesh lines have a great influence on the density plot. Save this question. Show activity on...
Read more >
Plot surface with binary colormap - python - Stack Overflow
You can define a custom color map and pass to plot_surface : from matplotlib.colors import ListedColormap, BoundaryNorm cmap ...
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
plot is that it can be used to create scatter plots where the properties of each individual point (size, face color, edge color,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found