3D Plotting in Matplotlib for Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: Code sharing (https://python-forum.io/forum-5.html) +--- Thread: 3D Plotting in Matplotlib for Python (/thread-17693.html) |
3D Plotting in Matplotlib for Python - pabloanm - Apr-20-2019 Hi everyone, I'm very new with Python. I found this code and I would like to change the color of a specific position in this 3d-matrix. Thanks in advance, Regards, from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') z = [8,7,6,7,9,10,9,8,10,8,9,10,9,8,10,8,9,10,9,8,10,8,9,10] x = [1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4] y = [1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6] ax.scatter(x, y, z, c='r', marker='o') ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show() RE: 3D Plotting in Matplotlib for Python - scidam - Apr-21-2019 As it could be seen from the official docs, c parameter in the scatter function could be a vector, consisting ofcorresponding colors to each point. # changes in your code colored_inds = [10, 12, 15] # points #10, 12 and 15 will be blue. colors = ['r' if j not in colored_inds else 'b' for j in range(len(x))] ax.scatter(x, y, z, c=colors, marker='o') |