【问题标题】:Why am I getting invalid syntax when adding second plot to plt.plot为什么将第二个绘图添加到 plt.plot 时语法无效
【发布时间】:2018-03-22 01:03:35
【问题描述】:

您好,第 6 行的语法无效

x = []
y = []
x2 = []
y2 = []
plt.plot(x,y,label=(+str(incur1)+ '/' +str(incur2))
plt.plot(x2,y2,label=(+str(incur2)+ '/' +str(incur1))
plt.xlabel ('Time')
plt.ylabel ('Ex Rate')
plt.title (+incur1+ '/' +incur2+ '/nEx Rate Data')
plt.legend()

以后会这样添加数据和日期时间

time = t.datetime
x.append(time)
y.append(first_exRtRate1)  

尝试制作字符串

label1 = (incur1+ '/' +incur2)
label2 = (incur2+ '/' +incur1)

然后

plt.plot(x,y,label=(+str(label1))

还是错误 被告知缺少一个) 试过了

plt.plot(x,y,label=(+str(incur1)+ '/' +str(incur2)))

还是错误

【问题讨论】:

  • 您缺少)
  • 最后是什么?在末尾添加了一个 ) 现在错误已向下移动了一行
  • 编辑帖子比将信息放在评论中要好。
  • 抱歉总是忘记\

标签: python-3.x matplotlib


【解决方案1】:

解决了

label1 = (incur1+ '/' +incur2)

plt.plot(x, y, label = label1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    • 2018-03-14
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多