我制作了一个情节,我想添加一个带有一些文字的图例.
https://plot.ly/~smirnod1/4/roc-curve/
这是一个例子 - 一个ROC曲线,我想把AUC放在图例中,但我找不到关于微调图例内容的文档.
我正在尝试保存我使用 seaborn 生成的图像。图像是 4x4 混淆矩阵('confmat' np.array)。我了解到,当我以矢量格式保存图像时,某些查看器会出现问题,导致颜色条上出现白线,引用自 matplotlib 参考:
众所周知,某些矢量图形查看器(svg 和 pdf)会在颜色条的各个部分之间呈现白色间隙。这是由于查看器中的错误而不是 matplotlib。作为一种解决方法,可以使用重叠段渲染颜色条:
cbar = 颜色条()
cbar.solids.set_edgecolor("face")
画()
但是,我无法执行建议的操作。
这是我所做的:
import seaborn as sns
import matplotlib.pyplot as plt
cmap=plt.cm.Blues
fig, ax = plt.subplots()
ax = sns.heatmap(confmat, annot=True, cmap=cmap)
ax.set_title('title')
ax.tick_params(
axis='both', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom='off', # ticks along the bottom edge are off
top='off', # ticks along the top edge are off
labelbottom='off', # labels along the bottom edge …Run Code Online (Sandbox Code Playgroud) 我正在尝试一件非常基本的事情 - 在数据库中查找用户并返回特定找到记录的字段之一。我想使用承诺,部分是出于教育目的。
var username = "user1" // assuming this exists: User({username: "user1", city: "London"})
function getUser(username) {
var promise = User.findOne({username: username}).exec();
var output = promise.then( function(user) {
return user.city;
}).catch(function(err) {
console.log(err);
});
return output;
}
Run Code Online (Sandbox Code Playgroud)
根据上面给出的代码,假设有一个用户拥有给定的数据,则输出变量仍然是一个承诺。我怎样才能得到它的实际价值?我有预感,我的问题是 return 语句不是异步的,即我在实际解决之前返回输出。返回值的正确方法是什么?