Skip to content

Instantly share code, notes, and snippets.

@Tony363
Created September 16, 2021 12:31
Show Gist options
  • Save Tony363/a73d5ad19422b800289efce52c662420 to your computer and use it in GitHub Desktop.
Save Tony363/a73d5ad19422b800289efce52c662420 to your computer and use it in GitHub Desktop.
def graph_sim(values,fig):
plt.clf()
spec = gridspec.GridSpec(ncols=3, nrows=2, figure=fig)
ax_tl = fig.add_subplot(spec[0,0], projection='3d')
ax_br = fig.add_subplot(spec[1,0], projection='3d')
ax_tl_side = fig.add_subplot(spec[0,1], projection='3d')
ax_br_side = fig.add_subplot(spec[1,1], projection='3d')
ax_Y0 = fig.add_subplot(spec[0,2], projection='3d')
ax_Y1 = fig.add_subplot(spec[1,2], projection='3d')
ax_tl.view_init(90, -90)
ax_br.view_init(90, -90)
ax_tl_side.view_init(0, -90)
ax_br_side.view_init(0, -90)
ax_Y0.view_init(0, -90)
ax_Y1.view_init(0, 0)
# ax_tl = fig[0].add_subplot(projection ='3d')
# ax_br = fig[1].add_subplot(projection ='3d')
# ax_Y0 = fig[2].add_subplot(projection ='3d')
# ax_Y1 = fig[3].add_subplot(projection ='3d')
ax_tl.scatter(values['in_x0'], values['in_x1'], values['in_tl'],s=30,edgecolor='g',facecolor='green')
ax_tl.scatter(values['out_x0'], values['out_x1'], values['out_tl'],s=5,edgecolor='k',facecolor='black')
ax_tl.scatter(values['est_xis'][0],values['est_xis'][1],values['red_tl_sqrt'],s=100,edgecolor='r',facecolor='red')
ax_tl.scatter(values['new_xis'][0], values['new_xis'][1], values['blue_tl_sqrt'],s=100,edgecolor='b',facecolor='blue')
ax_tl.set_title('top_left')
ax_tl.set_xlabel("X0")
ax_tl.set_ylabel('X1')
ax_tl.set_zlabel('X0_sigma')
ax_br.scatter(values['in_x0'], values['in_x1'], values['in_br'],s=30,edgecolor='g',facecolor='green')
ax_br.scatter(values['out_x0'], values['out_x1'], values['out_br'],s=5,edgecolor='k',facecolor='black')
ax_br.scatter(values['est_xis'][0],values['est_xis'][1],values['red_br_sqrt'],s=100,edgecolor='r',facecolor='red')
ax_br.scatter(values['new_xis'][0], values['new_xis'][1], values['blue_br_sqrt'],s=100,edgecolor='b',facecolor='blue')
ax_br.set_title('bottom_right')
ax_br.set_xlabel("X0")
ax_br.set_ylabel('X1')
ax_br.set_zlabel('X1_sigma')
ax_tl_side.scatter(values['in_x0'], values['in_x1'], values['in_tl'],s=30,edgecolor='g',facecolor='green')
ax_tl_side.scatter(values['out_x0'], values['out_x1'], values['out_tl'],s=5,edgecolor='k',facecolor='black')
ax_tl_side.scatter(values['est_xis'][0],values['est_xis'][1],values['red_tl_sqrt'],s=100,edgecolor='r',facecolor='red')
ax_tl_side.scatter(values['new_xis'][0], values['new_xis'][1], values['blue_tl_sqrt'],s=100,edgecolor='b',facecolor='blue')
ax_tl_side.set_title('top_left_side')
ax_tl_side.set_xlabel("X0")
ax_tl_side.set_ylabel('X1')
ax_tl_side.set_zlabel('X0_sigma')
ax_br_side.scatter(values['in_x0'], values['in_x1'], values['in_br'],s=30,edgecolor='g',facecolor='green')
ax_br_side.scatter(values['out_x0'], values['out_x1'], values['out_br'],s=5,edgecolor='k',facecolor='black')
ax_br_side.scatter(values['est_xis'][0],values['est_xis'][1],values['red_br_sqrt'],s=100,edgecolor='r',facecolor='red')
ax_br_side.scatter(values['new_xis'][0], values['new_xis'][1], values['blue_br_sqrt'],s=100,edgecolor='b',facecolor='blue')
ax_br_side.set_title('bottom_right_side')
ax_br_side.set_xlabel("X0")
ax_br_side.set_ylabel('X1')
ax_br_side.set_zlabel('X1_sigma')
ax_Y0.scatter(values['in_x0'], values['in_x1'], values['in_Y0'],s=30,edgecolor='g',facecolor='green')
ax_Y0.scatter(values['out_x0'], values['out_x1'], values['out_Y0'],s=5,edgecolor='k',facecolor='black')
ax_Y0.scatter(values['est_xis'][0],values['est_xis'][1],values['Y+epsilon'][0],s=100,edgecolor='r',facecolor='red')
ax_Y0.scatter(values['new_xis'][0], values['new_xis'][1], values['Y'][0],s=100,edgecolor='b',facecolor='blue')
ax_Y0.set_title('Response_graph_Y0')
ax_Y0.set_xlabel("X0")
ax_Y0.set_ylabel('X1')
ax_Y0.set_zlabel('Y0')
ax_Y1.scatter(values['in_x0'], values['in_x1'], values['in_Y1'],s=30,edgecolor='g',facecolor='green')
ax_Y1.scatter(values['out_x0'], values['out_x1'], values['out_Y1'],s=5,edgecolor='k',facecolor='black')
ax_Y1.scatter(values['est_xis'][0],values['est_xis'][1],values['Y+epsilon'][1],s=100,edgecolor='r',facecolor='red')
ax_Y1.scatter(values['new_xis'][0], values['new_xis'][1], values['Y'][1],s=100,edgecolor='b',facecolor='blue')
ax_Y1.set_title('Response_graph_Y1')
ax_Y1.set_xlabel("X0")
ax_Y1.set_ylabel('X1')
ax_Y1.set_zlabel('Y1')
# plt.draw()
# plt.pause(2)
# plt.waitforbuttonpress()
fig.canvas.draw()
fig.canvas.flush_events()
fig.waitforbuttonpress()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment