Changeset 113 for trunk


Ignore:
Timestamp:
06/27/11 17:54:21 (13 years ago)
Author:
pinsard
Message:

addd draft of python plotting tool

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/years_matplotlib.xsl

    r111 r113  
    66 
    77<!-- 
    8 module : 
    9 production d'un fichier de commande gnuplot avec données incorporées pour 
     8 
     9DESCRIPTION 
     10=========== 
     11 
     12production d'un fichier de commande matplotlb avec données incorporées pour 
    1013le graphe publications/année 
    1114 
    12 update : 
     15EXAMPLES 
     16======== 
     17 
     18:: 
     19 
     20  $ xsltproc \-\-param makedate $((date)) \-\-param path "'.'" \-\-output ginette.py years_matplotlib.xsl biblio.xml 
     21  $ python ginette.py 
     22  $ open ++.png 
     23 
     24TODO 
     25==== 
     26 
     27x time axe with yyyy labels 
     28 
     29add in makefile 
     30 
     31see http://matplotlib.sourceforge.net/examples/pylab_examples/demo_ribbon_box.html 
     32 
     33EVOLUTIONS 
     34========== 
     35 
    1336$Id$ 
    14 fplod 2008-04-30T06:50:45Z aedon.locean-ipsl.upmc.fr (Darwin) 
    15 chgt for dbk5 in 
    16 fplod 2007-05-21T12:52:07Z aedon.locean-ipsl.upmc.fr (Darwin) 
    17 d'après /Users/pinsard/ES/src/estimation/src/estimation_graph1_gnuplot.xsl 
    18 creation 
     37$URL$ 
     38 
     39- fplod 20110627T144044Z aedon.locean-ipsl.upmc.fr (Darwin) 
     40 
     41  * creation draft 
     42 
    1943--> 
    2044 
     
    2953 
    3054<xsl:template match="d:bibliography"> 
     55"""" 
     56 
     57EXAMPLES 
     58======== 
     59 
     60:: 
     61 
     62  $ python graph1_<xsl:value-of select="years"/>.py 
     63 
     64 
     65EVOLUTIONS 
     66========== 
     67 
     68<xsl:value-of select="$makedate"/> 
     69 
     70""" 
     71 
     72import matplotlib.pyplot as plot 
     73import numpy as np 
     74import datetime 
     75 
     76fig = plot.figure() 
     77ax = fig.gca() 
     78 
     79# definition of axes 
     80ax.set_xlabel('Year') 
     81ax.set_ylabel('Nb of publications') 
     82# titre sur le graphique 
     83plot.title('nb of publications by year date : <xsl:value-of select="$makedate"/>') 
    3184# 
    32 #  $ gnuplot graph1_<xsl:value-of select="years"/>.gnu 
    33 # 
    34 # source : 
    35 # ++/graph1_<xsl:value-of select="years"/>.gnu 
    36 # 
    37 # update : 
    38 # <xsl:value-of select="$makedate"/> 
    39 # 
    40 reset 
    41 # 
    42 # codage iso pour les diacritiques 
    43 set encoding iso_8859_1 
    44 # 
    45 set size 1.0, 1.0 
    46 set origin 0.0, 0.0 
    47 # 
    48 # pas de légendes 
    49 set nokey 
    50 # 
    51 # definition of axes 
    52 set xlabel "Year" 
    53 set xdata time 
    54 set timefmt "%Y" 
    55 set format x "%Y" 
    56 #++set xrange ++ year min year max 
    57 set ylabel "Nb of publications" 
    58 # titre sur le graphique 
    59 set title "nb of publications by year date : <xsl:value-of select="$makedate"/>" 
    60 # 
    61 #set term svg dynamic 
    62 #set output "years.svg" 
    63 #++set output "fichier_svg" 
    64 set term png 
    65 set output "<xsl:value-of select="$path"/>/years.png" 
    6685 
    67 plot '-' using 1:2 with linespoints 
     86dates=[] 
     87values=[] 
    6888   <!-- loop on years --> 
    6989   <xsl:for-each select="$list_years"> 
     
    7393    </xsl:call-template> 
    7494   </xsl:for-each> 
    75    <xsl:text>e</xsl:text> 
    76    <xsl:text>&#xA;</xsl:text> 
     95 
     96ax.set_xlim(dates[0]-0.5, dates[-1]+0.5) 
     97plot.bar(dates, values,width=0.5) 
     98 
     99# avoid overlap on labels 
     100fig.autofmt_xdate() 
     101# 
     102fig.savefig('<xsl:value-of select="$path"/>/years.png') 
     103 
     104plot.show() 
     105 
    77106</xsl:template> 
    78107 
    79108<xsl:template name="one_year"> 
    80109<xsl:param name="year"/> 
    81 <xsl:value-of select="$year"/> 
     110dates.append(<xsl:value-of select="$year"/>) 
    82111<xsl:text> </xsl:text> 
    83 <xsl:value-of select="count(/descendant::d:biblioentry[child::d:biblioset[child::d:pubdate=$year]]) "/> 
     112values.append(<xsl:value-of select="count(/descendant::d:biblioentry[child::d:biblioset[child::d:pubdate=$year]]) "/>) 
    84113<xsl:text>&#xA;</xsl:text> 
    85114</xsl:template> 
Note: See TracChangeset for help on using the changeset viewer.