| 34 | |
| 35 | |
| 36 | def plot3D(X, Y, Z, c='black', ls='', marker='o', fillstyle=None, label=None, ax=None, file=None, show=False, |
| 37 | show_legend=False, bounds=None,title=None): |
| 38 | if ax is None: |
| 39 | _, ax = plt.subplots(subplot_kw={"projection": "3d"}) |
| 40 | ax.plot(X, Y, Z, c=c, ls=ls, marker=marker, label=label,fillstyle=fillstyle) |
| 41 | ax.set_xlabel('$f_1(\mathbf{x})$', fontsize=13) |
| 42 | ax.set_ylabel('$f_2(\mathbf{x})$', fontsize=13) |
| 43 | ax.set_zlabel('$f_3(\mathbf{x})$', fontsize=13) |
| 44 | ax.tick_params(axis='both', labelsize=13) |
| 45 | |
| 46 | if show or file is not None: |
| 47 | plt.grid() |
| 48 | if show_legend: |
| 49 | plt.legend() |
| 50 | if bounds is not None: |
| 51 | ax.set_xlim((bounds[0, 0], bounds[0, 1])) |
| 52 | ax.set_ylim((bounds[1, 0], bounds[1, 1])) |
| 53 | ax.set_zlim((bounds[2, 0], bounds[2, 1])) |
| 54 | if title: |
| 55 | plt.title(title) |
| 56 | if file is not None: |
| 57 | plt.savefig(file, format='pdf') |
| 58 | if show: |
| 59 | plt.show() |
| 60 | if file is None and show is False: |
| 61 | return ax |
| 62 | return None |
| 63 | |
| 64 | |
| 65 | def surface3D(X_grid, Y_grid, cmap=cm.Blues, ax=None, file=None, show=False,label=None): |