我输入了我正在使用的类,但它给出了此消息错误:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap, BoundaryNorm
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Line3DCollection
%matplotlib notebook
# Generate random data
np.random.seed(1)
n = 20 # number of data points
#set x,y,z data
x = np.random.uniform(0, 1, n)
y = np.random.uniform(0, 1, n)
z = np.arange(0,n)
# Create a colormap for red, green and blue and a norm to color
# f' < -0.5 red, f' > 0.5 blue, and the rest green
cmap = ListedColormap(['r', 'g', 'b'])
norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
#################
### 3D Figure ###
#################
# Create a set of line segments
points = np.array([x, y, z]).T.reshape(-1, 1, 3)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
# Create the 3D-line collection object
lc = Line3DCollection(segments, cmap=plt.get_cmap('copper'),
norm=plt.Normalize(0, n))
lc.set_array(z)
lc.set_linewidth(2)
#plot
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_zlim(0, max(z))
plt.title('3D-Figure')
ax.add_collection3d(lc, zs=z, zdir='z')
#save plot
plt.savefig('3D_Line.png', dpi=600, facecolor='w', edgecolor='w',
orientation='portrait')
我的课程:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method translate(String, String, String) in the type LanguageTranslation is not applicable for the arguments (String, Language, Language)
at ibm.Cognitive.Translate(Cognitive.java:20)
at Teste.Watson.main(Watson.java:16)
我该如何解决这个问题?
答案 0 :(得分:0)
免责声明:我没有使用过Watson的API。但是,根据您获得的错误判断,翻译服务似乎需要(string, string, string)
个参数。
我会尝试修复,如果我正在编码:
Language.ENGLISH.toString()
和Language.SPANISH.toString()
作为参数。 "ENGLISH"
,"SPANISH"
作为语言的参数,从而将字符串文字输入到函数中。