savefig behaviour with transparent patches

I am searched the mailing list and web without success with this problem. I am getting unexpected behaviour when using savefig in the eps format.

The pdf renders the figure as it appears in the plot figure however the alpha for the patches is lost when saving as eps (see code below).

Any help would be greatly appreciated.

Kind Regards,

Kurt

matplotlib '0.98.5.2'
python 2.6.2
ubuntu 9.04

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numpy import *
from pylab import plot, show, grid, xlabel, ylabel, axhspan, axvspan, savefig
from scipy.optimize import leastsq, fsolve

sample_day = array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,\
22,23,24,25,26,27,28,29,30,31])

sample_measurement = array([0,0,0,0,0,0,0,0.02190,0.04910,0.06540,0.08170,\
0.10930,0.13650,0.15850,0.20200,0.33320,0.52000,0.66110,0.78710,0.85250,\
0.89070,0.91270,0.92890,0.94560,0.96180,0.97280,0.97280,0.97810,0.97810,\
0.98370,0.98370,0.98370])

## Logistic function
logistic = lambda a, x: (a[0] + (a[1]-a[0])/(1 + (a[2]/x)**a[3]))

## Linear first order function
linear_first_order = lambda a, x: (a[0]*x + a[1])

## Column leach model function
column_leach_model = lambda a, x: (array([zeros(len(x)), linear_first_order(a[0:2],x), logistic(a[2:len(a)],x)]).max(0))

## Error function
e = lambda a, x, y: (column_leach_model(a,x)-y)

## Initial conditions
a0 = [0.022,-0.13, 0.0,0.987,15.5,10.3]

## Least-squares regression
a, cov_x, infodict, mesg ,success = leastsq(e, a0, args=(sample_day,sample_measurement), full_output=1)

## Intercept of the linear and logistic functions
intercept = lambda x, a: (logistic(a[2:len(a)],x) - linear_first_order(a[0:2],x))
xint = fsolve(intercept, a[4], args=(a))

def plot_fit():
    # Create a time series data set to evaluate the regression model against
    x0 = linspace(0,-a[1]/a[0])
    x1 = linspace(-a[1]/a[0], xint)
    x2 = logspace(log10(xint), log10(31.))
    xsample = array([x0,x1,x2]).flatten()

    # Evaluate the regression model
    y = column_leach_model(a, xsample)

    # Plot the experimental data and the regression model results
    plot(sample_day, sample_measurement, marker='o', linestyle='none')
    xlabel("Duration [days]")
    ylabel("Fraction Recovered [-]")
    plot(xsample, y, linewidth=2)

    patch1 = axvspan(0, -a[1]/a[0], facecolor='.1', alpha=0.25)
    patch2 = axvspan(-a[1]/a[0], xint, facecolor='g', alpha=0.25)
    patch3 = axvspan(xint, 35, facecolor='b', alpha=0.25)

    grid("on")

    savefig('data_model.eps')
    savefig('data_model.pdf')

plot_fit()
show()

···

_________________________________________________________________
View photos of singles in your area Click Here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating.ninemsn.com.au%2Fsearch%2Fsearch.aspx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT

PS/EPS do not support alpha transparency. This is not a limitation of
mpl, but of the format. You will need to use SVG or PDF if you need a
vector output that supports transparency.

JDH

···

On Mon, Jun 1, 2009 at 4:37 PM, Kurt Forrester <kurtforrester@...32...> wrote:

I am searched the mailing list and web without success with this problem. I am getting unexpected behaviour when using savefig in the eps format.