Here is a solution which doesn't really use matplotlib, however it is a work
around by interfacing with the R library. Personally I didn't like some of
the colour choices which are hardwired in the R code so I adjusted the R
code and recompiled, however this assumes the code is as it comes from
Cran. It should produce a plot with two "models" compared to the observed.
#!/usr/bin/env python
import sys
from rpy2.robjects.packages import importr
import rpy2.robjects as robjects
import numpy as np
import rpy2.robjects.numpy2ri
# Note depends on R package plotrix
r = robjects.r
p = importr('plotrix')
r.pdf('x.pdf')
# make up some data, compare (any number of) models with observed
obs = np.random.random_sample(10)
mod = np.random.random_sample(10)
mod2 = np.random.random_sample(10) # etc
model_list = [mod, mod2]
first_model_comp = True # just a hack so that after first comparsion we call
"add=True"
colour_list = ['blue','green','red']
i = 0
for model in model_list:
# make taylor plot...
if first_model_comp == True:
p.taylor_diagram(obs, model, normalize=False, main='',
pos_cor=False, pcex=1.5, col=colour_list[i])
first_model_comp = False
else:
p.taylor_diagram(obs, model, add=True, normalize=False, pcex=1.5,
col=colour_list[i])
i += 1
# Observations are hardwired in the R code, so this is hack so that
everything is nicely
# declared in the legend. All need to be passed as numpy arrays as Rpy2 has
an issue with
# tuples...no doubt there is a better solution, however this works!
colour_list.append('darkgreen')
colour_list = np.array(colour_list)
shapes = np.array([19,19,15]) # circles and a square for the observation
model_list.append("Observation") # add observation to the list of vars
legendlist = np.array(['Model1', 'Model2'])
r.legend("topleft", legend=legendlist, pch=shapes, col=colour_list,
cex=0.75)
r['dev.off']()
Martin

View this message in context: http://old.nabble.com/Taylordiagramtp30421393p30449840.html
Sent from the matplotlib  users mailing list archive at Nabble.com.
