我曾尝试在Python中制作一个带有字符串类别(即神经网络的激活函数和求解器)的三维散点图,其中x轴和y轴为字符串类别,z轴为浮点数(即NN的准确性得分)。
以下示例引发错误: ValueError: could not convert string to float: 'str1'
我按照此文档进行了3D绘图:https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html 有什么想法,可能是什么问题吗? 非常感谢!
以下示例引发错误: ValueError: could not convert string to float: 'str1'
我按照此文档进行了3D绘图:https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html 有什么想法,可能是什么问题吗? 非常感谢!
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xs=['str1', 'str2']
print(type(xs))
ys=['str3', 'str4']
print(type(ys))
zs=[1,2]
ax.scatter(xs, ys, zs)
len(xs)
不等于len(ys)
,那么yticks=range(len(xs)), yticklabels=xs
中是否有错别字? - Lei Yang