[Paraview] Blog: matplotlib View coming in ParaView 4.1

Cory Quammen cory.quammen at kitware.com
Fri Jan 3 09:54:33 EST 2014


Aurélien,

Thanks for your feedback.

I just tried showing a matplotlib window using show() from within a
programmable filter in the ParaView nighly binary on linux and it does
not appear to work. It may be because the version of matplotlib that
is shipped with the ParaView binaries does not have the proper backend
enabled to show matplotlib windows.

On my development build that uses matplotlib installed with apt-get on
Ubuntu, I can indeed use show() from within a programmable filter to
pop up a simple matplotlib window.

I hope that helps,
Cory

On Thu, Dec 19, 2013 at 11:40 AM, Aurélien Marsan <aur.marsan at gmail.com> wrote:
> Hi Cory,
>
> Sorry for the delay,
>
> 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.
>
> Below is a script that illustrates what I have in mind, and that would be
> inserted in a ProgrammableFilter
>
>> import postproc_module as pm      # 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)
>>
>> data = self.GetInput()      # Get the input of the programmable Filter,
>> say a multiblock structured mesh
>> wall = pm.Extractor(input = data, "i=imax").get_output()      # Extract
>> the wall -- behind the class is the vtkSubset function
>>
>> pm.SomeMagicalClassThatPerformsSomeMagicalOperationAndOutputsGraphics(input
>> = wall, array = "ps", save_result = "some_path/some_file")      # that class
>> could perform some advanced post-processing, using scipy, numpy, and finally
>> display some result in a matplotlib window.
>> pm.SetOutput(self, data)      # just put the input data as output data of
>> the filter.
>
>
> Do not hesitate to ask if this is not clear.
>
> Best regards,
>
> Aurélien
>
>
>
> 2013/12/17 Cory Quammen <cory.quammen at kitware.com>
>>
>> Auré Lien,
>>
>> Thanks for the feedback,
>>
>> The Python View could certainly consume output from a
>> ProgrammableFilter. Did you have another way in mind to use matplotlib
>> from within a programmable filter? I don't think anything would stop
>> you from doing so, but to have any matplotlib plots show up in a
>> ParaView window, you would need to have your matplotlib code in the
>> Python View script.
>>
>> You can access the Python View from the Python shell, but it might be
>> a little awkward. You would have to set the script in the Python View
>> as a string, e.g.
>>
>> >>> view =paraview.simple.CreateView("PythonView")
>> >>> view.Script = """
>> ... def setup_data(view):
>> ...   print "setup_data"
>> ...
>> ... def render(view, figure):
>> ...   print "render"
>> ... """
>>
>> You could imagine loading a matplotlib script this way, perhaps.
>>
>> Best,
>> Cory
>>
>> On Tue, Dec 17, 2013 at 10:08 AM, Aurélien Marsan <aur.marsan at gmail.com>
>> wrote:
>> > Wow ! So great ! A very popular python feature that was missing in
>> > Paraview.
>> >
>> > Juste one question : will matplotlib also be directly accessible from a
>> > ProgrammableFilter or from the python console ?
>> >
>> > Many thanks,
>> >
>> > A. Marsan
>
>


More information about the ParaView mailing list