source: trunk/years_matplotlib.xsl @ 140

Last change on this file since 140 was 113, checked in by pinsard, 13 years ago

addd draft of python plotting tool

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<xsl:stylesheet
3version="1.0"
4xmlns:d="http://docbook.org/ns/docbook"
5xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6
7<!--
8
9DESCRIPTION
10===========
11
12production d'un fichier de commande matplotlb avec données incorporées pour
13le graphe publications/année
14
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
36$Id$
37$URL$
38
39- fplod 20110627T144044Z aedon.locean-ipsl.upmc.fr (Darwin)
40
41  * creation draft
42
43-->
44
45<xsl:output
46 method="text"
47 encoding="ISO-8859-1"
48 indent="yes"/>
49
50<xsl:include href="biblioentry_xml.xsl"/>
51
52<xsl:variable name="list_years" select="///d:pubdate[not( self::node() = following::d:pubdate )]"/>
53
54<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"/>')
84#
85
86dates=[]
87values=[]
88   <!-- loop on years -->
89   <xsl:for-each select="$list_years">
90    <xsl:sort order="ascending" data-type="number" select="."/>
91    <xsl:call-template name="one_year">
92     <xsl:with-param name="year" select="."/>
93    </xsl:call-template>
94   </xsl:for-each>
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
106</xsl:template>
107
108<xsl:template name="one_year">
109<xsl:param name="year"/>
110dates.append(<xsl:value-of select="$year"/>)
111<xsl:text> </xsl:text>
112values.append(<xsl:value-of select="count(/descendant::d:biblioentry[child::d:biblioset[child::d:pubdate=$year]]) "/>)
113<xsl:text>&#xA;</xsl:text>
114</xsl:template>
115
116</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.