Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def scatter3d(x,y,z, cs, colorsMap='jet'):
- cm = plt.get_cmap(colorsMap)
- cNorm = matplotlib.colors.Normalize(vmin=min(cs), vmax=max(cs))
- scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
- fig = plt.figure()
- ax = Axes3D(fig)
- ax.scatter(x, y, z,c=scalarMap.to_rgba(cs))
- ax.set_xlabel('Thita1')
- ax.set_ylabel('Thita2')
- ax.set_zlabel('Fairness (%)')
- scalarMap.set_array(cs)
- fig.colorbar(scalarMap,label='Error Rate (%)')
- plt.show()
- def surfacePlot(x,y,z, cs, colorsMap='jet'):
- cm = plt.get_cmap(colorsMap)
- cNorm = matplotlib.colors.Normalize(vmin=min(cs), vmax=max(cs))
- scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- ax.plot_surface(x, y, z, facecolors=scalarMap.to_rgba(cs))
- ax.set_xlabel('Thita1')
- ax.set_ylabel('Thita2')
- ax.set_zlabel('Fairness')
- scalarMap.set_array(cs)
- fig.colorbar(scalarMap,label='Error Rate (%)')
- plt.show()
- grid_x, grid_y = np.meshgrid(x, y)
- # I'm assuming that your data is already mesh-like, which it looks like it is.
- # The data would also need to be appropriately sorted for `reshape` to work.
- # `dx` here is number of unique x values, and `dy` is number unique y values.
- grid_z = z.reshape(dy, dx)
- ax.plot_scatter(grid_x, grid_y, grid_z)
- from scipy.interpolate import griddata
- xy = np.column_stack([x, y])
- grid_x, grid_y = np.mgrid[0:1:100j, 0:1:100j] # grid you create
- grid_z = griddata(xy, z, (grid_x, grid_y))
- ax.plot_scatter(grid_x, grid_y, grid_z)
Add Comment
Please, Sign In to add comment