Merge branch 'master' of git://repo.or.cz/quplot
[quplot.git] / bifandvel.py
blob1e2ddf1c3a0fa3346a02db4b256a1bac780db26d
1 # import stuff
2 import math
3 import numpy as np
4 import matplotlib as mpl
5 import matplotlib.pyplot as plt
6 import matplotlib.mlab as mlab
7 import matplotlib.axes as axe
8 import matplotlib.text as txt
10 DATAX = 'rk_bifurcate.dat'
11 DATAV = 'rk_bif_avg_velo.dat'
13 # some macros
14 PI = math.pi
15 L = 2*PI
17 # options
18 xpad = 0.002
19 ypad = 0.2
20 max = 0.84
21 tsize = 12
23 # default values
24 xtks1 = []
25 ytks1 = [0,L/2,L]
26 ytks2 = [-1,-0.5,0,0.5,1]
27 xtkl1 = []
28 ytkl1 = ["0","L/2","L"]
29 ylim1 = [0-0.2,L+0.2]
30 ylim2 = [-1-ypad,1+ypad]
31 xlbl1 = r''
32 xlbl2 = r'$l$'
33 ylbl1 = r'$x(k\tau)$ mod $L$'
34 ylbl2 = r'$v_x$'
35 res = (1440/80,900/80) # default dpi is 80
37 # calculate 3 to 1 ratio of upper to lower plot
38 left, width = 0.1, 0.8
39 c = max/4
40 rect1 = [left, c+0.1, width, c*3]
41 rect2 = [left, 0.1, width, c]
43 # title
44 title = "a = 1.15, w = 0.1, l = 3.0, eta1 = 1.0, eta2 = 1.5, theta = 0, alpha = 83"
46 # import data
47 r = mlab.csv2rec(DATAX, delimiter='\t', comments='#')
48 s = mlab.csv2rec(DATAV, delimiter='\t', comments='#')
50 xmin = r.r.min()
51 xmax = r.r.max()
53 xlim1 = xmin-xpad,xmax+xpad
54 xlim2 = xmin-xpad,xmax+xpad
56 # draw figure
57 fig = plt.figure(figsize=res)
58 fig.suptitle(title, size=tsize)
60 # draw first subplot and setup axis
61 ax1 = fig.add_axes(rect1)
62 ax2 = fig.add_axes(rect2)
64 # put x into the plot
65 ax1.plot(r.r, r.x, c='r', marker=',', ms=0.1, ls='')
66 ax1.set_xlim(xlim1)
67 ax1.set_ylim(ylim1)
68 ax1.set_yticks(ytks1)
69 ax1.set_ylabel(ylbl1, size=tsize)
70 ax1.set_xticklabels(xtkl1, size=tsize)
71 ax1.set_yticklabels(ytkl1, size=tsize)
73 # put <v> into the plot
74 ax2.plot(s.r, s.x, c='b', marker=',', ms=0.1, ls='')
75 ax2.set_xlim(xlim2)
76 ax2.set_ylim(ylim2)
77 #ax2.set_xticks(xtks2)
78 ax2.set_yticks(ytks2)
79 ax2.set_ylabel(ylbl2, size=tsize)
80 ax2.set_xlabel(xlbl2, size=tsize)
81 ax2.set_xticklabels(ax2.get_xticks(), size=tsize)
82 ax2.set_yticklabels(ax2.get_yticks(), size=tsize)
84 # adjust subplots
85 plt.subplots_adjust(hspace=0)
87 # stream the whole mess into a file
88 plt.savefig('test.png')
90 # EOF