Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I put an arrow near my x/ylabel?

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

like image 865
Hubschr Avatar asked Mar 07 '14 09:03

Hubschr


1 Answers

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

like image 51
Bonlenfum Avatar answered Sep 23 '22 06:09

Bonlenfum