我正在尝试使用带有德语数字格式的plotly.js显示数据,例如:" 1.234,0"
layout = { yaxis:{ tickformat:',。' } }
但它对我不起作用。
我找到了工作示例:
我如何实现这一目标?
非常感谢帮助。
答案 0 :(得分:0)
为此,您应该在布局中使用separators属性,如下所示:
layout = {
separators = ',.',
yaxis: { hoverformat = '.1f' }
}
其中第一个字符是小数点分隔符,第二个字符是千位分隔符。有关详细信息,请参阅https://plot.ly/javascript-graphing-library/reference/#layout-separators。
对于数字格式,您应该在layout.xaxis或layout.yaxis中使用hoverformat。因此,要解决您的问题,您可以使用以下内容:
"""
read the matrix values from excel spreadsheet, and converts the values to a matrix, shape = (28, 28)
"""
RMatrix=(pd.read_excel("C:\\...Data.xlsx", sheetname='TestModel', skiprows=0)).as_matrix()
"""
read the initialAmount values from excel spreadsheet, and converts the values to a matrix, shape = (28, 1)
"""
initialAmount = (pd.read_excel("C:\\...Data.xlsx", sheetname="TMI", skiprows=0)).as_matrix()
xdata = [4, 46, 67, 106, 158, 162, 201, 220, 249, 277, 309, 336, 371, 4453, 550, 687, 704, 737, 760, 795, 823]
ydata = [0.0054, 0.003, 0.00079, 0.00106, 0.00091759999999999997, 0.00014, 0.0006845, 0.0004995, 0.000865, 0.00083, 8.325e-05, 0.000149, 0.002738, 0.0007, 0.00059, 0.000185, 0.00048, 0.000369, 0.000925, 0.0015169, 0.000185]
def urinary_excretion(x, a, b, c, d, e, f, g):
initialAmount[0,0] = a #Replace the 0,0th element of initialMatrix with 'a'
initialAmount[1,0] = b # Replace the 1,0th element of initialMatrix with 'b'
initialAmount[2,0] = c #and so on
RMatrix[0,2] = d #Replace the 0,2th element of RMatrix with 'd'
RMatrix[0,1] = e # and so on
RMatrix[1,0] = f
RMatrix[1,2] = g
RMatrix[np.isnan(RMatrix)]=0 #converts NaN (Not a number) to 0
row,col = np.diag_indices_from(RMatrix) #get row and column indices of diagonal elements
RMatrix[row,col] = -(RMatrix.sum(axis=1)-RMatrix[row,col])-Lambda #assign the sum of each row except the diagonal elements into diagonal positions, takes care of decay constant
AMatrix = RMatrix.T # Transpose the RMatrix
def content(t):
expMatrix = scipy.linalg.expm(t*AMatrix)
return numpy.dot(expMatrix, initialAmount)
return content(x).item(20) - content(x-1).item(20)
popt, pcov = scipy.optimize.curve_fit(urinary_excretion, xdata, ydata)
希望这有帮助。