英文:
Why I can't put the lable in one line?
问题
我尝试绘制拟合线并添加标签:
```python
plt.plot(Tem, fitK[0] * Tem + fitK[1], label=('拟合动能 \n $E\_{k}^{拟合}=$ ' + fun1), color='red')
这是结果:
我可以让第二行和第三行出现在同一行吗?
<details>
<summary>英文:</summary>
I tried to plot the fitted line and add a label:
```python
plt.plot(Tem, fitK[0] * Tem + fitK[1], label = ('fitted kinetic energy \n $E\_{k}^{fitted}=$ ' + fun1), color = 'red')
Here is the result:
Can I make the second and third rows appear on the same line?
答案1
得分: 0
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(1,11,1)
y = np.arange(1,11,1)
plt.plot(x, y, label='非常长的字符串在这里被截断\n而且没有其他地方有换行,即使有像 $E_{k}^{fitted}=$ 和其他字符串附加在它后面')
plt.legend()
plt.show()
英文:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(1,11,1)
y = np.arange(1,11,1)
plt.plot(x,y, label='incredibly long string that is broken here \n and nowhere else at all even with terms like $E_{k}^{fitted}=$ ' + 'or even other strings attached to it')
plt.legend()
plt.show()
There is no second new line for me, no matter how long the string is. Does your fun1
contain a \n
?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论