(save_path, lowDWeights, labels)
| 93 | |
| 94 | |
| 95 | def plot_with_domains(save_path, lowDWeights, labels): |
| 96 | import matplotlib.pyplot as plt |
| 97 | padding_rate = 0.1 |
| 98 | plt.cla() |
| 99 | X, Y = lowDWeights[:, 0], lowDWeights[:, 1] |
| 100 | unique = np.unique(labels) |
| 101 | |
| 102 | num_type_color = 7 |
| 103 | colors = sns.color_palette("viridis", n_colors=num_type_color) |
| 104 | # label2color_dict = {l: cmap(i) for i, l in enumerate(unique)} |
| 105 | box_alpha = 0.3 |
| 106 | for x, y, s in zip(X, Y, labels): |
| 107 | if s >= 0 and s < 100: |
| 108 | plt.text(x, y, s, fontsize=1, |
| 109 | ha='center', va='center', # 水平居中,垂直居中 |
| 110 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 111 | ec=colors[0], # 边框颜色 |
| 112 | fc=colors[0] # 填充颜色 |
| 113 | )) |
| 114 | elif s >= 100 and s < 200: |
| 115 | plt.text(x, y, s, fontsize=1, |
| 116 | ha='center', va='center', # 水平居中,垂直居中 |
| 117 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 118 | ec=colors[1], # 边框颜色 |
| 119 | fc=colors[1] # 填充颜色 |
| 120 | )) |
| 121 | elif s >= 200 and s < 300: |
| 122 | plt.text(x, y, s, fontsize=1, |
| 123 | ha='center', va='center', # 水平居中,垂直居中 |
| 124 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 125 | ec=colors[2], # 边框颜色 |
| 126 | fc=colors[2] # 填充颜色 |
| 127 | )) |
| 128 | elif s >= 300 and s < 400: |
| 129 | plt.text(x, y, s, fontsize=1, |
| 130 | ha='center', va='center', # 水平居中,垂直居中 |
| 131 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 132 | ec=colors[3], # 边框颜色 |
| 133 | fc=colors[3] # 填充颜色 |
| 134 | )) |
| 135 | elif s >= 400 and s < 500: |
| 136 | plt.text(x, y, s, fontsize=1, |
| 137 | ha='center', va='center', # 水平居中,垂直居中 |
| 138 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 139 | ec=colors[4], # 边框颜色 |
| 140 | fc=colors[4] # 填充颜色 |
| 141 | )) |
| 142 | else: |
| 143 | plt.text(x, y, s, fontsize=5, |
| 144 | ha='center', va='center', # 水平居中,垂直居中 |
| 145 | bbox=dict(boxstyle='circle', alpha=box_alpha, # 圆圈 |
| 146 | ec=colors[5], # 边框颜色 |
| 147 | fc=colors[5] # 填充颜色 |
| 148 | )) |
| 149 | # plt.xlim(X.min()-padding_rate*X.min(), X.max()+padding_rate*X.max()) |
| 150 | # plt.ylim(Y.min()-padding_rate*Y.min(), Y.max()+padding_rate*Y.max()) |
| 151 | # plt.legend() |
| 152 | plt.xlim(X.min(), X.max()) |
nothing calls this directly
no outgoing calls
no test coverage detected