I have a code that gives me a scatter plot of predicted vs actual values as a function of concentration. The data is pulled from an excel csv spreadsheet.
This is the code:
import matplotlib.pyplot as plt
from numpy import loadtxt
dataset = loadtxt("ColorPlot.csv", delimiter=',')
x = dataset[:,0]
y = dataset[:,1]
z = dataset[:,2]
scaled_z = (z - z.min()) / z.ptp()
colors = plt.cm.viridis(scaled_z)
sc=plt.scatter(x, y, c=colors)
plt.clim(0, 100)
plt.colorbar()
plt.xlabel("Actual")
plt.ylabel("Predicted")
plt.show()
Run Code Online (Sandbox Code Playgroud)
And with this I get a nice …
我正在尝试使用此方法更改 mpl_toolkits.mplot3d 图中的气候:
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection='3d')
p = ax.scatter(x_, y_, z_, c='gray', s=0.25, alpha='0.5')
cbar = fig.colorbar(p)
cbar.set_clim(0,1)
Run Code Online (Sandbox Code Playgroud)
这不起作用并给出弃用警告:MatplotlibDeprecationWarning:set_clim 函数在 Matplotlib 3.1 中已弃用,并将在 3.3 中删除。改用 ScalarMappable.set_clim。
有没有人想出如何更改 Axes3D 图中的颜色条限制?
提前致谢!