Save plot 1D mesh

Asked by Anders Pettersson

Hi!
I have problems with saving my plots. It seems like I can't save them with the commands write_png, write_ps... when the mesh is one dimensonal. Is this correct? Is there any other way to save it? Parts of the code follows:

q = 1
W_h = FunctionSpace(mesh, "DG", q)

x_h = Function(W_h, x_h)
p = plot(x_h, title = "x_h", basename = "begynnelse50")
p.write_png("begynnelse50.png")

Thanks in advance!

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johannes Ring
Solved:
Last query:
Last reply:
Revision history for this message
Best Johannes Ring (johannr) said :
#1

I'm not sure this is a correct fix, but you can try to apply the following patch to viper.py (from Viper):

=== modified file 'src/viper/viper.py'
--- src/viper/viper.py 2012-02-07 14:50:00 +0000
+++ src/viper/viper.py 2012-04-17 14:33:40 +0000
@@ -690,6 +690,8 @@
             #x.shape = shape
         if x is None and self.mode=="vector":
             self._update_directions(self.x)
+ if x is None and self.mode=="scalar_xy":
+ x = self.x

         self.darr.Modified()
         self.ren.ResetCameraClippingRange()

Revision history for this message
Anders Logg (logg) said :
#2

Johannes, if it works for you, just go ahead and apply the patch to
Viper so we don't forget about it.

--
Anders

On Tue, Apr 17, 2012 at 02:35:46PM -0000, Johannes Ring wrote:
> Question #193927 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/193927
>
> Status: Open => Answered
>
> Johannes Ring proposed the following answer:
> I'm not sure this is a correct fix, but you can try to apply the
> following patch to viper.py (from Viper):
>
> === modified file 'src/viper/viper.py'
> --- src/viper/viper.py 2012-02-07 14:50:00 +0000
> +++ src/viper/viper.py 2012-04-17 14:33:40 +0000
> @@ -690,6 +690,8 @@
> #x.shape = shape
> if x is None and self.mode=="vector":
> self._update_directions(self.x)
> + if x is None and self.mode=="scalar_xy":
> + x = self.x
>
> self.darr.Modified()
> self.ren.ResetCameraClippingRange()
>

Revision history for this message
Johannes Ring (johannr) said :
#3

Ok! This is fixed now in the development version of Viper.

Revision history for this message
Anders Pettersson (fridasvelander) said :
#4

Thanks, this helped!!

Revision history for this message
Anders Pettersson (fridasvelander) said :
#5

Thanks Johannes Ring, that solved my question.