|
| 1 | +"""This script has been used in Qiqi Duan's Ph.D. Dissertation (HIT&SUSTech). |
| 2 | +
|
| 3 | + Chinese: 该绘图脚本被段琦琦的博士论文(哈工大与南科大联合培养)所使用。 |
| 4 | +""" |
| 5 | +import matplotlib |
| 6 | +import matplotlib.pyplot as plt |
| 7 | + |
| 8 | +from pypop7.benchmarks.rotated_functions import ellipsoid |
| 9 | +from pypop7.benchmarks.rotated_functions import generate_rotation_matrix |
| 10 | +from pypop7.benchmarks.utils import generate_xyz |
| 11 | + |
| 12 | + |
| 13 | +matplotlib.rcParams['font.family'] = 'sans-serif' |
| 14 | +matplotlib.rcParams['font.sans-serif'] = 'SimSun' |
| 15 | +matplotlib.rcParams['axes.unicode_minus'] = False |
| 16 | +matplotlib.rcParams['font.size'] = 10 # 对应5号字体 |
| 17 | + |
| 18 | + |
| 19 | +if __name__ == '__main__': |
| 20 | + generate_rotation_matrix(ellipsoid, 2, 72) |
| 21 | + bound = [-10.0, 10.0] |
| 22 | + fig = plt.figure(figsize=(2.5, 2.5)) |
| 23 | + ax = fig.add_subplot(1, 1, 1, projection='3d') |
| 24 | + x, y, z = generate_xyz(ellipsoid, bound, bound, 500) |
| 25 | + ax.plot_surface(x, y, z, cmap='cool', |
| 26 | + rstride=100, cstride=100, alpha=0.7) |
| 27 | + ax.set_title('病态函数', fontsize=10) |
| 28 | + ax.set_xlim(bound) |
| 29 | + ax.set_ylim(bound) |
| 30 | + ax.set_xticks([-10.0, -5.0, 0.0, 5.0, 10.0], fontsize=10) |
| 31 | + ax.set_yticks([-10.0, -5.0, 0.0, 5.0, 10.0], fontsize=10) |
| 32 | + ax.set_zticks([0.0e8, 0.5e8, 1.5e8], ['0.0e8', '0.5e8', '1.5e8'], fontsize=10) |
| 33 | + ax.set_xlabel('维度1', fontsize=10) |
| 34 | + ax.set_ylabel('维度2', fontsize=10) |
| 35 | + ax.set_zlabel('适应值', fontsize=10, rotation='vertical') |
| 36 | + plt.savefig('3d_ellipsoid.png', dpi=700, bbox_inches='tight') |
| 37 | + plt.show() |
0 commit comments