[SciPy-User] matplotlib: print to postscript file and some other questions
Johannes Radinger
jradinger at gmx.at
Wed May 11 15:30:16 EDT 2011
Hello ,
sofar I know how to safe a plot into a *.eps file and it works good,
but there is one issue with filled areas between two functions.
When I try to use:
plt.fill_between(x, pdf_min, pdf_max, color='0.85')
and I try to open it on my mac I fail. So far as I know
is the mac converting the eps internally to pdf to be
displayed, but it seems it can't be converted.
If I try to set the output to *.pdf it works perfectly and I can
open the file. Something in the combination of fill_between
and eps is causing the error. I tried also color="red" but with
the same problems.
Is there anything I've to set because I need the output as
a working eps.
/johannes
Am 07.05.2011 um 12:19 schrieb Nils Wagner:
> On Sat, 7 May 2011 15:37:16 +0530
> Rajeev Singh <rajs2010 at gmail.com> wrote:
>> On Fri, May 6, 2011 at 3:16 PM, Johannes Radinger
>> <JRadinger at gmx.at> wrote:
>>
>>> Hello
>>>
>>> I don't know if there is a special matplotlib-user list
>>> but anyway:
>>>
>>> I managed to draw a very simple plot of a probability
>>> density function
>>> (actually two superimposed pdfs). Now I'd like to draw
>>> vertical lines fat
>>> the points of the scale-parameters (only under the curve
>>> of the function)
>>> and label them. How can I do that?
>>>
>>> And what is the command to print the result into a
>>> postscript-file?
>>>
>>> Here is what I've got so far:
>>>
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from scipy import stats
>>>
>>> p=0.3
>>> m=0
>>>
>>> x = np.arange(-100, 100, 0.2)
>>>
>>> def pdf(x,s1,s2):
>>> return p * stats.norm.pdf(x, loc=m, scale=s1) + (1-p)
>>> *
>>> stats.norm.pdf(x, loc=m, scale=s2)
>>>
>>> #plt.axis([-100, 100, 0, 0.03])#probably not necessary
>>> plt.plot(x, pdf(x,12,100), color='red')
>>> plt.title('Pdf of dispersal kernel')
>>> plt.text(60, 0.0025, r'$\mu=100,\ \sigma=15$')
>>> plt.ylabel('probabilty of occurance')
>>> plt.xlabel('distance from starting point')
>>> plt.grid(True)
>>>
>>> plt.show()
>>>
>>> thanks
>>> /johannes
>>> --
>>> NEU: FreePhone - kostenlos mobil telefonieren und
>>> surfen!
>>> Jetzt informieren: http://www.gmx.net/de/go/freephone
>>> _______________________________________________
>>> SciPy-User mailing list
>>> SciPy-User at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>
>>
>> Hi,
>>
>> You can try the following hack -
>>
>> import matplotlib.pyplot as plt
>> import numpy as np
>> from scipy import stats
>>
>> p=0.3
>> m=0
>>
>> x = np.arange(-100, 100, 0.2)
>>
>> def pdf(x,s1,s2):
>> return p * stats.norm.pdf(x, loc=m, scale=s1) + (1-p)
>> * stats.norm.pdf(x,
>> loc=m, scale=s2)
>>
>> #plt.axis([-100, 100, 0, 0.03])#probably not necessary
>> s1, s2 = 12, 100
>> plt.plot(x, pdf(x,s1, s2), color='red')
>> plt.plot(np.array([s1,s1]),
>> np.array([plt.ylim()[0],pdf(s1,s1,s2)]), '--k')
>> plt.plot(np.array([s2,s2]),
>> np.array([plt.ylim()[0],pdf(s2,s1,s2)]), '--k')
>> plt.title('Pdf of dispersal kernel')
>> plt.text(60, 0.0025, r'$\mu=100,\ \sigma=15$')
>> plt.ylabel('probabilty of occurance')
>> plt.xlabel('distance from starting point')
>> #plt.grid(True)
>>
>> #plt.show()
>> plt.savefig('filename.eps') # this will save the figure
>> in an eps file in
>> current directory
>>
>> I am not sure if this is what you want!
>>
>> Rajeev
>
> See
>
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.savefig
> http://matplotlib.sourceforge.net/users/customizing.html
>
> for details.
>
> HTH
>
> Nils
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list