* fixed a bug that caused nonsensical output in eul
[quplot.git] / bifandvel.py
blob10c772f64b3ea6ab8b175eefbb9295e3ab7114da
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 = '../eu_bifurcate.dat'
11 DATAV = '../eu_bif_avg_velo.dat'
12 FOUT = '../test.png'
14 # some macros
15 PI = math.pi
16 L = 2*PI
18 # options
19 xpad = 0.002
20 ypad = 0.1
21 max = 0.875
22 tsize = 24
23 ticksize = 16
25 # default values
26 xtks1 = []
27 ytks1 = [0,L/2,L]
28 ytks2 = [-1,-0.5,0,0.5,1]
29 xtkl1 = []
30 ytkl1 = ["0","L/2","L"]
31 ylim1 = [0-ypad,L+ypad]
32 #ylim2 = [-1-ypad,1+ypad]
33 xlbl1 = r''
34 xlbl2 = r'$l$'
35 ylbl1 = r'$x(k\tau)$ mod $L$'
36 ylbl2 = r'$v_x$'
37 res = (1440/80,900/80) # default dpi is 80
39 # calculate 3 to 1 ratio of upper to lower plot
40 left, width = 0.1, 0.8
41 c = max/4
42 rect1 = [left, c+0.1, width, c*3]
43 rect2 = [left, 0.1, width, c]
45 # title
46 title = "a = 1.15, w = 0.1, l = 3.0, eta1 = 1.0, eta2 = 1.5, theta = 0, alpha = 83"
48 # import data
49 r = mlab.csv2rec(DATAX, delimiter='\t', comments='#')
50 s = mlab.csv2rec(DATAV, delimiter='\t', comments='#')
52 xmin = r.r.min()
53 xmax = r.r.max()
54 vmin = s.x.min()
55 vmax = s.x.max()
57 xlim1 = xmin-xpad,xmax+xpad
58 xlim2 = xmin-xpad,xmax+xpad
60 ylim2 = vmin-ypad,vmax+ypad
62 # draw figure
63 fig = plt.figure(figsize=res)
64 #fig.suptitle(title, size=tsize)
66 # draw first subplot and setup axis
67 ax1 = fig.add_axes(rect1)
68 ax2 = fig.add_axes(rect2)
70 # put x into the plot
71 ax1.plot(r.r, r.x, c='r', marker=',', ms=0.1, ls='')
72 ax1.set_xlim(xlim1)
73 ax1.set_ylim(ylim1)
74 ax1.set_yticks(ytks1)
75 ax1.set_ylabel(ylbl1, size=tsize)
76 ax1.set_xticklabels(xtkl1, size=ticksize)
77 ax1.set_yticklabels(ytkl1, size=ticksize)
79 # put <v> into the plot
80 ax2.plot(s.r, s.x, c='b', marker=',', ms=0.1, ls='')
81 ax2.set_xlim(xlim2)
82 ax2.set_ylim(ylim2)
83 #ax2.set_xticks(xtks2)
84 #ax2.set_yticks(ytks2)
85 ax2.set_ylabel(ylbl2, size=tsize)
86 ax2.set_xlabel(xlbl2, size=tsize)
87 ax2.set_xticklabels(ax2.get_xticks(), size=ticksize)
88 ax2.set_yticklabels(ax2.get_yticks(), size=ticksize)
90 # adjust subplots
91 plt.subplots_adjust(hspace=0)
93 # stream the whole mess into a file
94 plt.savefig(FOUT)
96 # EOf