1import matplotlib.lines as lines
2import matplotlib.pyplot as plt
3import numpy as np
4
5
6def tukeyplot(results, dim=None, yticklabels=None):
7    npairs = len(results)
8
9    fig = plt.figure()
10    fsp = fig.add_subplot(111)
11    fsp.axis([-50,50,0.5,10.5])
12    fsp.set_title('95 % family-wise confidence level')
13    fsp.title.set_y(1.025)
14    fsp.set_yticks(np.arange(1,11))
15    fsp.set_yticklabels(['V-T','V-S','T-S','V-P','T-P','S-P','V-M',
16                         'T-M','S-M','P-M'])
17    #fsp.yaxis.set_major_locator(mticker.MaxNLocator(npairs))
18    fsp.yaxis.grid(True, linestyle='-', color='gray')
19    fsp.set_xlabel('Differences in mean levels of Var', labelpad=8)
20    fsp.xaxis.tick_bottom()
21    fsp.yaxis.tick_left()
22
23    xticklines = fsp.get_xticklines()
24    for xtickline in xticklines:
25        xtickline.set_marker(lines.TICKDOWN)
26        xtickline.set_markersize(10)
27
28    xlabels = fsp.get_xticklabels()
29    for xlabel in xlabels:
30        xlabel.set_y(-.04)
31
32    yticklines = fsp.get_yticklines()
33    for ytickline in yticklines:
34        ytickline.set_marker(lines.TICKLEFT)
35        ytickline.set_markersize(10)
36
37    ylabels = fsp.get_yticklabels()
38    for ylabel in ylabels:
39        ylabel.set_x(-.04)
40
41    for pair in range(npairs):
42        data = .5+results[pair]/100.
43        #fsp.axhline(y=npairs-pair, xmin=data[0], xmax=data[1], linewidth=1.25,
44        fsp.axhline(y=npairs-pair, xmin=data.mean(), xmax=data[1], linewidth=1.25,
45            color='blue', marker="|",  markevery=1)
46
47        fsp.axhline(y=npairs-pair, xmin=data[0], xmax=data.mean(), linewidth=1.25,
48            color='blue', marker="|", markevery=1)
49
50    #for pair in range(npairs):
51    #    data = .5+results[pair]/100.
52    #    data = results[pair]
53    #    data = np.r_[data[0],data.mean(),data[1]]
54    #    l = plt.plot(data, [npairs-pair]*len(data), color='black',
55    #                linewidth=.5, marker="|", markevery=1)
56
57    fsp.axvline(x=0, linestyle="--", color='black')
58
59    fig.subplots_adjust(bottom=.125)
60
61
62
63results = np.array([[-10.04391794,  26.34391794],
64      [-21.45225794,  14.93557794],
65      [  5.61441206,  42.00224794],
66      [-13.40225794,  22.98557794],
67      [-29.60225794,   6.78557794],
68      [ -2.53558794,  33.85224794],
69      [-21.55225794,  14.83557794],
70      [  8.87275206,  45.26058794],
71      [-10.14391794,  26.24391794],
72      [-37.21058794,  -0.82275206]])
73
74
75#plt.show()
76