为什么我不能将标签放在一行内?

huangapple go评论92阅读模式
英文:

Why I can't put the lable in one line?

问题

  1. 我尝试绘制拟合线并添加标签:
  2. ```python
  3. plt.plot(Tem, fitK[0] * Tem + fitK[1], label=('拟合动能 \n $E\_{k}^{拟合}=$ ' + fun1), color='red')

这是结果:

为什么我不能将标签放在一行内?

我可以让第二行和第三行出现在同一行吗?

  1. <details>
  2. <summary>英文:</summary>
  3. I tried to plot the fitted line and add a label:
  4. ```python
  5. plt.plot(Tem, fitK[0] * Tem + fitK[1], label = (&#39;fitted kinetic energy \n $E\_{k}^{fitted}=$ &#39; + fun1), color = &#39;red&#39;)

Here is the result:

为什么我不能将标签放在一行内?

Can I make the second and third rows appear on the same line?

答案1

得分: 0

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. x = np.arange(1,11,1)
  4. y = np.arange(1,11,1)
  5. plt.plot(x, y, label='非常长的字符串在这里被截断\n而且没有其他地方有换行,即使有像 $E_{k}^{fitted}=$ 和其他字符串附加在它后面')
  6. plt.legend()
  7. plt.show()
英文:
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. x = np.arange(1,11,1)
  4. y = np.arange(1,11,1)
  5. plt.plot(x,y, label=&#39;incredibly long string that is broken here \n and nowhere else at all even with terms like $E_{k}^{fitted}=$ &#39; + &#39;or even other strings attached to it&#39;)
  6. plt.legend()
  7. plt.show()

There is no second new line for me, no matter how long the string is. Does your fun1 contain a \n?

huangapple
  • 本文由 发表于 2023年4月19日 16:25:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052273.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定