<div dir="ltr">Hi Cory, <div><br></div><div>Sorry for the delay, </div><div><br></div><div>Sometimes, I suppose that I would like to be able to just plot some matplotlib graphics from the programmable filter, as if it were a standard python script. No matter if the window is included or not within the paraview interface. A simple matplotlib window -- like when we do show() in a simple python script -- would then do the job. </div>
<div><br></div><div>Below is a script that illustrates what I have in mind, and that would be inserted in a ProgrammableFilter</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
import postproc_module as pm <i># this is a module, with classes etc., that do all the post-treatment that I want. I use it both inside and outside Paraview. (programmable filter / sources and simple python script)</i></blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><i></i>data = self.GetInput() <i># Get the input of the programmable Filter, say a multiblock structured mesh<br>
</i>wall = pm.Extractor(input = data, "i=imax").get_output() <i># Extract the wall -- behind the class is the vtkSubset function<br></i>pm.SomeMagicalClassThatPerformsSomeMagicalOperationAndOutputsGraphics(input = wall, array = "ps", save_result = "some_path/some_file") <i># that class could perform some advanced post-processing, using scipy, numpy, and finally display some result in a matplotlib window. </i><i><br>
</i>pm.SetOutput(self, data) <i># just put the input data as output data of the filter. </i></blockquote><div><br></div><div>Do not hesitate to ask if this is not clear. </div><div><br></div><div>Best regards, </div>
<div><br></div><div>Aurélien</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/17 Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Auré Lien,<br>
<br>
Thanks for the feedback,<br>
<br>
The Python View could certainly consume output from a<br>
ProgrammableFilter. Did you have another way in mind to use matplotlib<br>
from within a programmable filter? I don't think anything would stop<br>
you from doing so, but to have any matplotlib plots show up in a<br>
ParaView window, you would need to have your matplotlib code in the<br>
Python View script.<br>
<br>
You can access the Python View from the Python shell, but it might be<br>
a little awkward. You would have to set the script in the Python View<br>
as a string, e.g.<br>
<br>
>>> view =paraview.simple.CreateView("PythonView")<br>
>>> view.Script = """<br>
... def setup_data(view):<br>
... print "setup_data"<br>
...<br>
... def render(view, figure):<br>
... print "render"<br>
... """<br>
<br>
You could imagine loading a matplotlib script this way, perhaps.<br>
<br>
Best,<br>
Cory<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Dec 17, 2013 at 10:08 AM, Aurélien Marsan <<a href="mailto:aur.marsan@gmail.com">aur.marsan@gmail.com</a>> wrote:<br>
> Wow ! So great ! A very popular python feature that was missing in Paraview.<br>
><br>
> Juste one question : will matplotlib also be directly accessible from a<br>
> ProgrammableFilter or from the python console ?<br>
><br>
> Many thanks,<br>
><br>
> A. Marsan<br>
</div></div></blockquote></div><br></div>