| import matplotlib.pyplot as plt |
| import numpy as np |
| from matplotlib import font_manager |
|
|
| font_path = '/Users/yuheng/Library/Fonts/Carlito-Bold.ttf' |
| prop = font_manager.FontProperties(fname=font_path) |
|
|
| |
| fig = plt.figure(figsize=(6, 4)) |
| ax = fig.add_subplot(projection='3d') |
|
|
| |
| xpos = np.array([0, 0, 0, 0, 0, 0]) |
| ypos = np.array([0, 0.5, 1.3, 1.8, 2.3, 2.8]) |
| zpos = np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5]) |
|
|
| |
| dx = np.array([0.2, 0.2, 0.2, 0.2, 0.2, 0.2]) |
| dy = np.array([0.4, 0.4, 0.4, 0.4, 0.4, 0.4]) |
| dz = np.array([0.3669, 0.3356, 0.3125, 0.3439, 0.317, 0.338]) |
|
|
| |
| |
| colors = ['#D77071', '#D77071', '#6888F5', '#6888F5', '#6888F5', '#6888F5'] |
| |
|
|
| for i in range(6): |
| ax.bar3d(xpos[i], ypos[i], zpos[i], dx[i], dy[i], dz[i], |
| color=colors[i], alpha=0.8, edgecolor='black', linewidth=1) |
|
|
| |
| ax.view_init(elev=10, azim=10) |
| ax.set_box_aspect([1, 4, 4]) |
|
|
| |
| ax.set_xlim(-0, 0.2) |
| ax.set_ylim(-0, 3.2) |
| ax.set_zlim(0.5, 1) |
|
|
| |
| ax.set_xticks([]) |
|
|
| |
| ax.set_yticks([0, 0.5, 1.3, 1.8, 2.3, 2.8]) |
| ax.set_yticklabels(["BG", "FG", "0.3%", "1%", "10%", "90%"]) |
|
|
| |
| ax.set_zticks([0.5, 0.6, 0.7, 0.8, 0.9, 1.0]) |
|
|
| for tick in ax.get_xticklabels(): |
| tick.set_fontproperties(prop) |
| tick.set_fontsize(14) |
|
|
| for tick in ax.get_yticklabels(): |
| tick.set_fontproperties(prop) |
| tick.set_fontsize(14) |
|
|
| for tick in ax.get_zticklabels(): |
| tick.set_fontproperties(prop) |
| tick.set_fontsize(14) |
|
|
| |
| ax.grid(True) |
|
|
| |
| ax.xaxis.pane.fill = False |
| ax.yaxis.pane.fill = False |
| ax.zaxis.pane.fill = False |
|
|
| |
| ax.xaxis.pane.set_edgecolor('gray') |
| ax.yaxis.pane.set_edgecolor('gray') |
| ax.zaxis.pane.set_edgecolor('gray') |
|
|
| |
| from mpl_toolkits.mplot3d.art3d import Poly3DCollection |
|
|
| |
| vertices_fg_bg = [[(0, 0, 0.5), (0, 1.2, 0.5), (0, 1.2, 1.0), (0, 0, 1.0)]] |
| poly_fg_bg = Poly3DCollection(vertices_fg_bg, alpha=0.2, facecolor='red', edgecolor='red') |
| ax.add_collection3d(poly_fg_bg) |
|
|
| |
| vertices_other = [[(0, 1.2, 0.5), (0, 3.2, 0.5), (0, 3.2, 1.0), (0, 1.2, 1.0)]] |
| poly_other = Poly3DCollection(vertices_other, alpha=0.2, facecolor='blue', edgecolor='blue') |
| ax.add_collection3d(poly_other) |
|
|
| |
| |
| for z in [0.5, 0.6, 0.7, 0.8, 0.9, 1.0]: |
| ax.plot([0, 0], [0, 1.2], [z, z], color='red', alpha=0.0, linewidth=1) |
|
|
| |
| for z in [0.5, 0.6, 0.7, 0.8, 0.9, 1.0]: |
| ax.plot([0, 0], [1.2, 3.2], [z, z], color='blue', alpha=0.0, linewidth=1) |
|
|
| |
| for y in [0, 0.5, 1.3, 1.8, 2.3, 2.8]: |
| if y <= 1.2: |
| ax.plot([0, 0], [y, y], [0.5, 1.0], color='red', alpha=0.0, linewidth=1) |
| else: |
| ax.plot([0, 0], [y, y], [0.5, 1.0], color='blue', alpha=0.0, linewidth=1) |
|
|
| plt.tight_layout() |
| |
| plt.savefig("fig/motivation.pdf", dpi=1200) |