10

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. example thanks

Hubschr
  • 1,285
  • 6
  • 18
  • 35

1 Answers1

16

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

Herpes Free Engineer
  • 2,425
  • 2
  • 27
  • 34
Bonlenfum
  • 19,101
  • 2
  • 53
  • 56
  • 2
    oh... Im an idiot :D I made the example myself, ofcourse using LaTex at the labels... but dont know why I didnt thought of the arrows from LaTex... thx a lot :D – Hubschr Mar 07 '14 at 10:01
  • no problem! don't forget that using raw strings is often needed for rendering latex (`r'\rho'` for example) – Bonlenfum Mar 07 '14 at 10:28