Taylor diagram

Hi,

Has anyone ever managed to draw a taylor diagram in Matplotlib? For example
like this

http://www.mathworks.com/matlabcentral/fx_files/20559/2/taylordiag_fig.jpg

Cheers,

Martin

···

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

Not sure whether Matplotlib can do this, but it can be done with CDAT, another Python-based library: http://www2-pcmdi.llnl.gov/cdat

HTH,

AMG

···

On 12/09/2010 05:42 PM, mdekauwe wrote:

Hi,

Has anyone ever managed to draw a taylor diagram in Matplotlib? For example
like this

http://www.mathworks.com/matlabcentral/fx_files/20559/2/taylordiag_fig.jpg

Cheers,

Martin

-----------------

Hi thanks for the link thats interesting though I would perhaps rather not
learn a new set of commands just for one plot. Though it seems from my
searching that this might be the only route!

cheers,

Martin

Arthur M. Greene wrote:

···

On 12/09/2010 05:42 PM, mdekauwe wrote:

Hi,

Has anyone ever managed to draw a taylor diagram in Matplotlib? For
example
like this

http://www.mathworks.com/matlabcentral/fx_files/20559/2/taylordiag_fig.jpg

Cheers,

Martin

Not sure whether Matplotlib can do this, but it can be done with CDAT,
another Python-based library: http://www2-pcmdi.llnl.gov/cdat

HTH,

AMG

-----------------

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

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

Hi,

thanks to Juan for the Rpy package suggestion

I came up with this, which at least produces the plot. I can't quite work
out R specific bits at the moment (e.g. legend), but perhaps it might help
someone else.

#!/usr/bin/env python
import sys
from rpy2.robjects.packages import importr
import rpy2.robjects as robjects
r = robjects.r

# Note depends on R package plotrix

r.png(filename="x.png" ,width=480, height=480)

# fake some reference data
s = importr('stats')
ref = s.rnorm(30, sd=2)
ref_sd = r.sd(ref)

# add a little noise
model1 = s.rnorm(30, sd=2)

# add more noise
model2 = s.rnorm(30, sd=6)

# display the diagram with the better model
p = importr('plotrix')

#print plot
p.taylor_diagram(ref,model1)

# now add the worse model
p.taylor_diagram(ref,model2, add=True, col="blue")

# get approximate legend position
lpos = 1.5 * ref_sd[0]

# add a legend
#r.legend(lpos,lpos,legend=("Better","Worse"),pch=19,col=("red","blue"))

# now restore par values
#p.par(oldpar)

# show the "all correlation" display
p.taylor_diagram(ref,model1,pos_cor=False)
p.taylor_diagram(ref,model2,add=True,col="blue")

Martin

···

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

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 re-compiled, 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/Taylor-diagram-tp30421393p30449840.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Hi,

mdekauwe wrote:

Has anyone ever managed to draw a taylor diagram in Matplotlib? For
example like this

http://www.mathworks.com/matlabcentral/fx_files/20559/2/taylordiag_fig.jpg

here is my try [ http://old.nabble.com/file/p30540085/taylorDiagram.py
taylorDiagram.py ] using matplotlib 1.0 (requires floating_axes). This is
heavily based on the
http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html
floating_axes demo (which I find tricky).

I'm sure there're plenty of way to improve the TaylorDiagram class, but I'm
not familiar with all the bells and whistles of axes projections
(furthermore, I'm not sure Taylor diagrams are exactly what I need...). So
feel free to ellaborate!

Cheers,

Yannick

···

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