| 1 | from pymantidplot.future.pyplot import * |
|---|
| 2 | |
|---|
| 3 | ## plot arrays |
|---|
| 4 | plot([0.1, 0.3, 0.2, 4]) |
|---|
| 5 | plot([0.1, 0.2, 0.3, 0.4], [1.2, 1.3, 0.2, 0.8]) |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | # Loads |
|---|
| 9 | ws = Load("MAR11060.raw", OutputWorkspace="foo") |
|---|
| 10 | mar = Load('MAR11060.raw', OutputWorkspace="MAR11060") |
|---|
| 11 | loq=Load('LOQ48097.raw', OutputWorkspace="LOQ48097") |
|---|
| 12 | ws2 = Load('HRP39182.RAW', OutputWorkspace="HRP39182") |
|---|
| 13 | |
|---|
| 14 | ## plot workspaces |
|---|
| 15 | plot(ws, 100) |
|---|
| 16 | plot(ws, [100, 101, 102]) |
|---|
| 17 | plot('MAR11060', [10,100,500]) |
|---|
| 18 | plot(mar,[3, 500, 800]) |
|---|
| 19 | yscale('log') |
|---|
| 20 | plot([mar, 'LOQ48097'], [800, 900]) |
|---|
| 21 | plot([mar, loq], [800, 900]) |
|---|
| 22 | plot(['MAR11060', loq], [800, 900]) |
|---|
| 23 | plot(['MAR11060', loq], [800, 900], tool='plot_spectrum') |
|---|
| 24 | |
|---|
| 25 | # tools |
|---|
| 26 | plot_spectrum(['MAR11060', loq], [800, 900]) |
|---|
| 27 | plot(ws, [1, 5, 7, 100], tool='plot_bin') |
|---|
| 28 | |
|---|
| 29 | plot_bin(ws, [1, 5, 7, 100], linewidth=4, linestyle=':') |
|---|
| 30 | xscale('log') |
|---|
| 31 | |
|---|
| 32 | simple_md_ws = CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace=MDWWorkspaceName) |
|---|
| 33 | plot(simple_md_ws, tool='plot_md') |
|---|
| 34 | plot_md(simple_md_wsws) |
|---|
| 35 | |
|---|
| 36 | # some plot properties |
|---|
| 37 | a = [0.1, 0.3, 0.2, 4] |
|---|
| 38 | plot(a) |
|---|
| 39 | import numpy as np |
|---|
| 40 | y = np.sin(np.linspace(-2.28, 2.28, 1000)) |
|---|
| 41 | plot(y, linestyle='-.', marker='o', color='red') |
|---|
| 42 | plot(1.5*y, '-.g', hold='on') |
|---|
| 43 | plot(0.8*y, ':b', hold='on') |
|---|
| 44 | plot(1.2*y, '--c', hold='on') |
|---|
| 45 | xscale('log') |
|---|
| 46 | yscale('log') |
|---|
| 47 | |
|---|
| 48 | # plot properties and return lines |
|---|
| 49 | lines = plot([ws2], 0, '-r') # solid (default) |
|---|
| 50 | lines = plot([ws, ws2], 0, '-.c') # dash-dotted |
|---|
| 51 | lines = plot(ws, 0, '--m') # dashed |
|---|
| 52 | lines = plot(ws, [0,1], ':g') # dotted |
|---|
| 53 | lines = plot(loq, [100, 104], tool='plot_spectrum', linestyle='-.', marker='*', color='red') |
|---|
| 54 | lines[0].get_xdata() |
|---|
| 55 | lines[0].get_ydata() |
|---|
| 56 | fig = lines[0].figure() |
|---|
| 57 | fig.suptitle('Example figure title') |
|---|
| 58 | |
|---|
| 59 | # functions |
|---|
| 60 | title('Test plot of LOQ') |
|---|
| 61 | xlabel('ToF') |
|---|
| 62 | ylabel('Counts') |
|---|
| 63 | ylim(0, 8) |
|---|
| 64 | xlim(1e3, 4e4) |
|---|
| 65 | xscale('log') |
|---|
| 66 | grid('on') |
|---|
| 67 | savefig('example_saved_figure.png') |
|---|
| 68 | |
|---|
| 69 | # hold |
|---|
| 70 | lines = plot(loq, [100, 102], linestyle='-.', color='red') |
|---|
| 71 | lines = plot(loq, 100, linestyle='-.', color='red') |
|---|
| 72 | lines = plot(loq, 102, linestyle='-.', color='blue', hold='on') |
|---|
| 73 | lines = plot(loq, 103, linestyle=':', color='m', hold='on') |
|---|
| 74 | lines = plot(loq, 104, linestyle=':', color='k', hold='on') |
|---|
| 75 | |
|---|
| 76 | # multi-plot |
|---|
| 77 | plot(ws, [100, 101], 'r', ws, [200, 201], 'b', tool='plot_spectrum') |
|---|
| 78 | plot(ws, [100, 101], 'm', mar, [50, 41], 'b', tool='plot_spectrum') |
|---|
| 79 | |
|---|
| 80 | # other examples, used to fail |
|---|
| 81 | ws = CreateWorkspace([1,2,3], [1.1,2.8,3.2]) |
|---|
| 82 | lines = plot([ws], [0], '--r', [ws], [0], 'g') |
|---|
| 83 | lines = plot([ws], [0], 'r', [ws], [0], 'g') |
|---|
| 84 | title('myplot_1') |
|---|
| 85 | xlabel('x') |
|---|
| 86 | figure(0) |
|---|
| 87 | title('myplot_0') |
|---|
| 88 | xlabel('x') |
|---|
| 89 | print dir(lines[0]) |
|---|
| 90 | |
|---|
| 91 | # Axes |
|---|
| 92 | lines = plot(mar,[3, 500, 800]) |
|---|
| 93 | fig = lines[0].figure() |
|---|
| 94 | all_ax = fig.axes() # fig.axes() returns in principle a list |
|---|
| 95 | ax = all_ax[0] # but we only use one axes |
|---|
| 96 | ax.set_ylabel('--- Counts ---') |
|---|
| 97 | ax.set_xlabel('--- ToF ---') |
|---|
| 98 | ax.set_ylim(0, 25) |
|---|
| 99 | ax.set_xlim(1e2, 4e4) |
|---|
| 100 | ax.set_xscale('log') |
|---|
| 101 | ax.set_yscale('log') |
|---|
| 102 | ax.set_yscale('linear') |
|---|
| 103 | |
|---|