如何在我的x/ylabel附近放一个箭头? [英] how can I put an arrow near my x/ylabel?

查看:51
本文介绍了如何在我的x/ylabel附近放一个箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 matplotlib,我想在我的轴图例"旁边有一个箭头.但是我不知道如何.在示例中,我要的箭头用红色绘制.谢谢

解决方案

您可以使用

matplotlib 中文本的局部着色 处理多色字符串,在LaTeX数学模式下显示更多箭头

Im working with matplotlib and I want an arrow beside my "axis-legend". But I have no idea how. In the example, the arrows I want are drawn in red. thanks

解决方案

You can generate arrows as shown in your example figure by using the TeX renderer built into matplotlib. Coloring is an option for the whole strings, although generating multiple colors in a single text string is more work.

This will give you the mathematical symbols plus the arrows (I've shown different lengths on each axis label):

import matplotlib.pyplot as plt 
fig, ax = plt.subplots(1, 1)
# plot your data here ...

ax.set_xlabel(r'$\rho/\rho_{ref}\;\rightarrow$', color='red')
ax.set_ylabel(r'$\Delta \Theta / \omega \longrightarrow$')

plt.show()
plt.close()

Resulting in:

Partial coloring of text in matplotlib deals with multi-color strings, and this solution describes how to use the latex engine with multiple colors. However, it does not color what is rendered in the interactive graph, so it depends on your exact needs.

More arrows in LaTeX math mode

这篇关于如何在我的x/ylabel附近放一个箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆