2D plot on surface of VTK Object

Hi there,

I created a VTK object, which is made out of 20 cubes and appears to be one cube, with several Layers, defined through different colours.
I created a polar plot with Matplotlib. Now I want to integrate those two. I converted the Matplot to a PDF file, via Pandas. Hence I want to lay this 2D plot on top if the cube. Is that possible? And is it possible that the cube is than still interactive? What would be your suggestions?

I am thankful for any help.


You may want to take a look at using texture maps.

1 Like

Most probably you can paint the surface directly with VTK, so there is no need to mess with matplotlib at all.

Using vtkImageActor can also be an option , trying to reproduce the above with vedo.Picture(vtkImageActor)

import numpy, vtk
from vedo import *
from vedo.pyplot import histogram

settings.annotatedCubeColor      = 'brown'
settings.annotatedCubeTextColor  = 'white'
settings.annotatedCubeXPlusText  = "R"
settings.annotatedCubeXMinusText = "L"
settings.annotatedCubeYPlusText  = "F"
settings.annotatedCubeYMinusText = "B"
settings.annotatedCubeZPlusText  = "T"
settings.annotatedCubeZMinusText = "D"
settings.annotatedCubeTextScale  = 0.5

box = Box(size=(8,5,1)).c('grey')
his = histogram(numpy.random.randn(10000),
                mode='polar', cmap='viridis_r', showDisc=False)

f = 'https://matplotlib.org/_images/sphx_glr_polar_legend_001.png'
pic = Picture(f).scale(5e-3).pos(-3.5,-1.2,0.51)

show(box, his, pic, axes=5, bg='steelblue', bg2='royalblue')

print(isinstance(pic, vtk.vtkImageActor)) # True

Screenshot from 2020-06-28 14-35-17

1 Like

I am very new to VTK and this is my first question . Thanks for all the answers, they helped a lot! It worked with vtkPlaneSource. Also vtkImageActor was great. I continued working on the project.
Now I want to create several quad objects with VTK. For example 3 quads, which are next to each other and on each of the element I want to set a different png.
Is it possible to set png on a quad or tria element ?