Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Close
From: mdekauwe <mdekauwe@gm...>  20101209 22:42:49

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/Taylordiagramtp30421393p30421393.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Arthur M. Greene <amg@ir...>  20101210 03:28:41

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 Pythonbased library: http://www2pcmdi.llnl.gov/cdat HTH, AMG  
From: mdekauwe <mdekauwe@gm...>  20101212 22:45:00

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 Pythonbased library: http://www2pcmdi.llnl.gov/cdat > > HTH, > > AMG > >  > >  > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > >  View this message in context: http://old.nabble.com/Taylordiagramtp30421393p30441386.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: mdekauwe <mdekauwe@gm...>  20101213 00:10:39

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/Taylordiagramtp30421393p30441744.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: mdekauwe <mdekauwe@gm...>  20101213 22:03:33

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. 
From: Yannick Copin <yannick.copin@la...>  20101227 17:03:04

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/Taylordiagramtp30421393p30540085.html Sent from the matplotlib  users mailing list archive at Nabble.com. 