import numpy as np from matplotlib_venn import venn2, venn2_circles, venn2_unweighted from matplotlib_venn import venn3, venn3_circles from matplotlib import pyplot as plt plt.title(print("Shared",Signature_1, 'and',Signature_2, 'and',Signature_3)) venn3(subsets = (len(NameA), len(NameB), len(shared_A_B), len(NameC), len(shared_A_C), len(shared_C_B), len(shared_A_B_C)), set_labels = (Signature_1, Signature_2, Signature_3), alpha = 0.5) plt.show()此代码仅生成 jupyter Notebook 中绘图的标题。当我在 Anaconda 提示符下运行 .py 脚本时,只有绘图可见。我该如何让标题出现在绘图窗口中?我意识到因为这些格式被格式化为采用变量 [plt.title(print("title",variable,etc.)] 他们不能在命令行中工作。任何建议将不胜感激
1 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
您可以使用该.format方法将变量包含到打印/标题中。
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,10)
y = x**2
plt.plot(x,y)
variable ='IamVar'
Signature_1='one'
Signature_2='two'
Signature_3='three'
# \n stands for newline
plt.suptitle("Moving title - {} and {},{} \n set=({},{})".format(Signature_1,Signature_2,Signature_3,len(x),len(y))
,size=8,x=0.3, y=0.6)
plt.show()
添加回答
举报
0/150
提交
取消