【问题标题】:Text annotations in matplotlib on next line (linebreak) using '\n' give a square box instead of a line breakmatplotlib 中的文本注释在下一行(换行符)使用 \'\\n\' 给出一个方框而不是换行符
【发布时间】:2022-08-06 01:37:29
【问题描述】:

我试图在matplotlib使用\\n, 在绘图而不是换行符上显示一个方框

 \"Fault location:\" + str(sc) + \"\\nI_sc=\" + str(fault)

我想将故障位置和 I_sc 放在单独的行中,例如

Fault location: 1
I_sc=2

标签: matplotlib plot-annotations


【解决方案1】:

可能的解决方案如下:

import matplotlib.pyplot as plt

sc = 1
fault = 2

plt.annotate(f'Fault location: {str(sc)}\nI_sc={str(fault)}', xy=(0.5, 0.5))
plt.show()

退货

【讨论】:

    猜你喜欢
    • 2015-09-22
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多