SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: jilguero <jil...@gm...> - 2013年12月03日 12:50:12
Hi,
I am trying to make plots by using matplotlib.pyplot (within a Python
script) to be used in a web site (apache, and PHP). I am using Ubuntu
12.04.3. The script works fine when run from the command line (it is able to
generate the image with "savefig"), but when the script doesn't work when
run from PHP under an apache request. I have found a similar problem in this
post:
http://matplotlib.1069221.n5.nabble.com/savefig-fails-under-apache-on-solaris-td15122.html
Finally, I have found the solution in this web:
http://texnological.blogspot.com.es/2013/01/how-to-execute-python-matplolib-pylab.html
The solution consists on importing matplotlib in this way:
 # To import pylab
 os.environ[ 'MPLCONFIGDIR' ] = '/tmp/'
 import matplotlib
 matplotlib.use('agg')
 import pylab
This works for me, but I don't know whether this is a bug and it has to be
reported anywhere. The best option should be to import it in a regular way
(such as import matplotlib.pyplot as plt), and this can be confusing for a
lot of people. Well, let me know. Thank you.
Best regards,
Jilguero.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/images-for-web-sites-tp42581.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Scott S. <sco...@gm...> - 2013年12月04日 10:04:32
On 3 December 2013 14:50, jilguero <jil...@gm...> wrote:
> I am trying to make plots by using matplotlib.pyplot (within a Python
> script) to be used in a web site (apache, and PHP). I am using Ubuntu
> 12.04.3. The script works fine when run from the command line (it is able to
> generate the image with "savefig"), but when the script doesn't work when
> run from PHP under an apache request. I have found a similar problem in this
> post:
> http://matplotlib.1069221.n5.nabble.com/savefig-fails-under-apache-on-solaris-td15122.html
>
> Finally, I have found the solution in this web:
> http://texnological.blogspot.com.es/2013/01/how-to-execute-python-matplolib-pylab.html
>
> The solution consists on importing matplotlib in this way:
> # To import pylab
> os.environ[ 'MPLCONFIGDIR' ] = '/tmp/'
> import matplotlib
> matplotlib.use('agg')
> import pylab
>
> This works for me, but I don't know whether this is a bug and it has to be
> reported anywhere. The best option should be to import it in a regular way
> (such as import matplotlib.pyplot as plt), and this can be confusing for a
> lot of people. Well, let me know. Thank you.
Check out http://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server
Cheers,
Scott
From: jilguero <jil...@gm...> - 2013年12月06日 19:34:52
Hi Scott,
Ok!. Thank you. I take note.
Best regards,
Jilguero.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/images-for-web-sites-tp42581p42604.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /