|
10 | 10 | upper_level=("/").join(upper_level_list)
|
11 | 11 | class_loc=upper_level+"/src"
|
12 | 12 | sys.path.insert(0, class_loc)
|
| 13 | +try: |
| 14 | + from PIL import Image |
| 15 | + resize=True |
| 16 | +except: |
| 17 | + resize=False |
13 | 18 | from single_e_class_unified import single_electron
|
14 | 19 | from harmonics_plotter import harmonics
|
15 | 20 | import pints.plot
|
|
64 | 69 | fourier_times=[ramp_time_results, time_results]
|
65 | 70 | fourier_currents=[ramped_cmaes_time, cmaes_time]
|
66 | 71 | harm_xlabels=["Time(s)", "Voltage(V)"]
|
67 |
| -fig=multiplot(2, 4, **{"harmonic_position":3, "num_harmonics":num_harms, "fourier_position":2,"orientation":"portrait", "plot_width":6, "col_spacing":2}) |
| 72 | +fig=multiplot(2, 4, **{"harmonic_position":3, "num_harmonics":num_harms, "fourier_position":2,"orientation":"portrait", "plot_width":6, "col_spacing":2, "font_size":15}) |
68 | 73 | keys=sorted(fig.axes_dict.keys())
|
69 | 74 |
|
70 | 75 | fig.axes_dict["col1"][0].plot(ramp_time_results, ramp_voltage_results)
|
|
82 | 87 | for i in range(0, 2):
|
83 | 88 | for j in range(0, 2):
|
84 | 89 | pos=(i*2)+j
|
85 |
| - fig.axes_dict["col3"][pos].set_xlabel("Frequency(Hz)") |
| 90 | + if j==1: |
| 91 | + fig.axes_dict["col3"][pos].set_xlabel("Frequency(Hz)") |
86 | 92 | fig.axes_dict["col3"][pos].set_ylabel(fourier_ylabels[j])
|
87 | 93 | if j==0:
|
88 | 94 | fig.axes_dict["col3"][pos].set_xticks([])
|
|
91 | 97 | for j in range(0, num_harms):
|
92 | 98 | if i==0:
|
93 | 99 | x=ramp_time_results
|
| 100 | + if j==3: |
| 101 | + fig.axes_dict["col4"][pos].set_ylabel("Current($\\mu A$)") |
94 | 102 | else:
|
95 | 103 | x=voltage_results
|
| 104 | + if j==4: |
| 105 | + fig.axes_dict["col4"][pos].set_ylabel("Current($\\mu A$)") |
96 | 106 | pos=(i*num_harms)+j
|
97 | 107 | fig.axes_dict["col4"][pos].plot(x, all_harms[i][j,:]*1e3)
|
| 108 | + |
98 | 109 | twiny=fig.axes_dict["col4"][pos].twinx()
|
99 | 110 | twiny.set_ylabel(j+1, rotation=0)
|
100 |
| - twiny.set_yticks([]) |
| 111 | + twiny.set_yticklabels([]) |
101 | 112 | if j==num_harms-1:
|
102 | 113 | fig.axes_dict["col4"][pos].set_xlabel(harm_xlabels[i])
|
103 | 114 | else:
|
104 | 115 | fig.axes_dict["col4"][pos].set_xticks([])
|
105 |
| - if j==num_harms//2: |
106 |
| - fig.axes_dict["col4"][pos].set_ylabel("Current($\\mu A$)") |
| 116 | + ticks=fig.axes_dict["col4"][pos].get_yticks() |
| 117 | + fig.axes_dict["col4"][pos].set_yticks([ticks[1], ticks[-2]]) |
| 118 | + |
107 | 119 | letter_count=0
|
108 | 120 | y_pos=[1.1, 1.1, 1.195, 1.58]
|
109 | 121 | for i in range(0, len(keys)):
|
|
120 | 132 | plt.subplots_adjust(left=0.05, bottom=0.05, right=0.99, top=0.94, wspace=0.29, hspace=0.2)
|
121 | 133 | plt.show()
|
122 | 134 | save_path="experiment_comparison.png"
|
123 |
| -#fig.savefig(save_path, dpi=500) |
124 |
| -plt.show() |
| 135 | +fig.savefig(save_path, dpi=500) |
| 136 | + img = Image.open(save_path) |
| 137 | + basewidth = float(img.size[0])//2 |
| 138 | + wpercent = (basewidth/float(img.size[0])) |
| 139 | + hsize = int((float(img.size[1])*float(wpercent))) |
| 140 | + img = img.resize((int(basewidth),hsize), Image.ANTIALIAS) |
| 141 | + img.save(save_path, "PNG", quality=95, dpi=(500, 500)) |
0 commit comments