plotting several functions in same window

Asked by Chaffra Affouda

I would be nice to be able to plot several functions in the same window. With viper I had a hack that allowed me to do things like
plt = plot(u)
plt.plot(v) #plot v in the same windows as u

This is useful especially in 1D or 2D

Now with the new plotting interface I fell less confident on how to do this. My first intuition would be to allow VTKPlotter to handle an array of plottables instead of a single one. Maybe there is an easier solution to this.

Chaffra

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Benjamin Kehlet
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Wed, Aug 08, 2012 at 09:56:12PM -0000, Chaffra Affouda wrote:
> Question #205347 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/205347
>
> Description changed to:
> I would be nice to be able to plot several functions in the same window. With viper I had a hack that allowed me to do things like
> plt = plot(u)
> plt.plot(v) #plot v in the same windows as u
>
> This is useful especially in 1D or 2D
>
> Now with the new plotting interface I fell less confident on how to do
> this. My first intuition would be to allow VTKPlotter to handle an array
> of plottables instead of a single one. Maybe there is an easier solution
> to this.
>
> Chaffra

This is something we will consider in our current work on the plotting functionality:

  https://blueprints.launchpad.net/dolfin/+spec/dolfin-plot-c++

It will be added if it can be done with a reasonable effort and if it
does not lead to unnecessary complications.

--
Anders

Revision history for this message
Chaffra Affouda (chaffra) said :
#2

Thanks for the reply Anders,

Two more things; I liked the fact that in Viper for a 1D plot you used to use an VTKXYActor instead of plotting in 3D. In the mean time it would also be nice if there was a way to still use Viper for plotting if the user chooses to. Something like DOLFIN_PLOT_WITH_VIPER=1 when building. I understand it is no longer maintained but that would ease the transition.

Revision history for this message
Best Benjamin Kehlet (benjamik) said :
#3

2012/8/9 Chaffra Affouda <email address hidden>:
> Question #205347 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/205347
>
> Status: Answered => Open
>
> Chaffra Affouda is still having a problem:
> Thanks for the reply Anders,
>
> Two more things; I liked the fact that in Viper for a 1D plot you used
> to use an VTKXYActor instead of plotting in 3D.

Agree, VTKXYActor offers what we want. The only problem is that it
doesn't fit entirely into our design since it is a VTKActor. So we
either need to modify the design a bit or add it as a special case in
the VTKPlotter class. We'll look into that in the near future.

> In the mean time it
> would also be nice if there was a way to still use Viper for plotting if
> the user chooses to. Something like DOLFIN_PLOT_WITH_VIPER=1 when
> building. I understand it is no longer maintained but that would ease
> the transition.

That sounds cumbersome to maintain in a development branch...
Do you need functionality which is not present in the stable branch of
Dolfin? Then I think you should be able to hack this yourself. If you
do "from Viper import *" after importing Dolfin, you'll have Viper's
plot() function available. The arguments are a bit different than
Dolfin's plot() function. Take a look at
site-packages/dolfin/common/plotting.py in the stable branch.

Benjamin

>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Revision history for this message
Chaffra Affouda (chaffra) said :
#4

Thanks Benjamin Kehlet, that solved my question.