要在 matplotlib 中使用 unicode 符号,我们可以采取以下步骤。
设置图形大小并调整子图之间和周围的填充。
text()使用带有 unicode 符号的方法将文本添加到图形。在这里,我们使用了具有字符代码 (0394)的 Unicode 字符(Δ )。
要显示图形,请使用Show()方法。
importmatplotlib.pyplotas plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Unicode symbol plt.text(0.5, 0.5, s=u"\u0394", fontsize=50) # Display the plot plt.show()输出结果
它将产生以下输出 -
现在,让我们使用另一个 Unicode 字符 (\u2734)。
它将产生以下输出 -