Re: Using a different Matplotlib backend on a per-script basis

2019-03-13 Thread Christoph Margenfeld

Dear Jonathan,

this worked well, even with the PDF backend. Maybe that short piece of 
information could be added to the corresponding FAQ.


Thank you for the swift help.

Best regards,
Christoph

Am 13.03.2019 um 17:28 schrieb Guyer, Jonathan E. Dr. (Fed) via fipy:

I think option 3 is what you want. Before import fipy or anything else, start 
your script with
```
import matplotlib
matplotlib.use('backend')
```


On Mar 13, 2019, at 9:43 AM, Christoph Margenfeld 
 wrote:

Hello,

as mentioned in the FiPy FAQ, a different Matplotlib backend has to be
used when exporting images from the MatplotlibViewer class without any
output to the screen.

 From the Matplotlib documentation (at
https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmatplotlib.org%2Ftutorials%2Fintroductory%2Fusage.html%23what-is-a-backend&data=02%7C01%7Cjonathan.guyer%40nist.gov%7Cfcdca20d85b343ceac4b08d6a7ba19f0%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C636880815078320111&sdata=%2B0YF4KH4MUJJcHVjxm5RXUpE%2BYUdSoLLcWEn6HAlmsE%3D&reserved=0),
there are three ways to select a backend. The first two would involve
setting it in a .matplotlibrc file or as an environment variable.
However, that would affect all scripts run in that particular
environment, which I do not want to do. The third approach is setting
matplotlib.use('backend').

How can I select a Matplotlib backend for a certain MatplotlibViewer
without affecting any other scripts run from my environment?

Thank you!

Best regards,
Christoph Margenfeld
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


--

Christoph Margenfeld, M.Sc.
Institut für Halbleitertechnik
TU Braunschweig
Hans-Sommer-Straße 66
38106 Braunschweig
Tel. +49 531 391 3786
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Using a different Matplotlib backend on a per-script basis

2019-03-13 Thread Michael J. Waters

Hi Christoph,

Have you tried setting the backend at the start of your FiPy script like 
this?:


importmatplotlib

matplotlib.use('AGG')  

This won't make the changes system wide, only for the script. I think 
this will work since FiPy doesn't appear to deviate from the default 
rcparams setting for the backend. 
(https://github.com/usnistgov/fipy/tree/develop/fipy/viewers/matplotlibViewer)


Best,

-Mike




On 3/13/19 9:43 AM, Christoph Margenfeld wrote:

Hello,

as mentioned in the FiPy FAQ, a different Matplotlib backend has to be
used when exporting images from the MatplotlibViewer class without any
output to the screen.

  From the Matplotlib documentation (at
https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend),
there are three ways to select a backend. The first two would involve
setting it in a .matplotlibrc file or as an environment variable.
However, that would affect all scripts run in that particular
environment, which I do not want to do. The third approach is setting
matplotlib.use('backend').

How can I select a Matplotlib backend for a certain MatplotlibViewer
without affecting any other scripts run from my environment?

Thank you!

Best regards,
Christoph Margenfeld
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Using a different Matplotlib backend on a per-script basis

2019-03-13 Thread Guyer, Jonathan E. Dr. (Fed) via fipy
I think option 3 is what you want. Before import fipy or anything else, start 
your script with 
```
import matplotlib
matplotlib.use('backend')  
```

> On Mar 13, 2019, at 9:43 AM, Christoph Margenfeld 
>  wrote:
> 
> Hello,
> 
> as mentioned in the FiPy FAQ, a different Matplotlib backend has to be 
> used when exporting images from the MatplotlibViewer class without any 
> output to the screen.
> 
> From the Matplotlib documentation (at 
> https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmatplotlib.org%2Ftutorials%2Fintroductory%2Fusage.html%23what-is-a-backend&data=02%7C01%7Cjonathan.guyer%40nist.gov%7Cfcdca20d85b343ceac4b08d6a7ba19f0%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C636880815078320111&sdata=%2B0YF4KH4MUJJcHVjxm5RXUpE%2BYUdSoLLcWEn6HAlmsE%3D&reserved=0),
>  
> there are three ways to select a backend. The first two would involve 
> setting it in a .matplotlibrc file or as an environment variable. 
> However, that would affect all scripts run in that particular 
> environment, which I do not want to do. The third approach is setting 
> matplotlib.use('backend').
> 
> How can I select a Matplotlib backend for a certain MatplotlibViewer 
> without affecting any other scripts run from my environment?
> 
> Thank you!
> 
> Best regards,
> Christoph Margenfeld
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Using a different Matplotlib backend on a per-script basis

2019-03-13 Thread Christoph Margenfeld
Hello,

as mentioned in the FiPy FAQ, a different Matplotlib backend has to be 
used when exporting images from the MatplotlibViewer class without any 
output to the screen.

 From the Matplotlib documentation (at 
https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend), 
there are three ways to select a backend. The first two would involve 
setting it in a .matplotlibrc file or as an environment variable. 
However, that would affect all scripts run in that particular 
environment, which I do not want to do. The third approach is setting 
matplotlib.use('backend').

How can I select a Matplotlib backend for a certain MatplotlibViewer 
without affecting any other scripts run from my environment?

Thank you!

Best regards,
Christoph Margenfeld
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]