Ask Your Question

How to put fractions in legends?

asked 2017-01-22 08:31:33 -0500

Romuald_314 gravatar image


I've, for example, a plot of a function with a legend. I want to put a fraction or some advanced LaTeX code within the legend block, but I can't. How can I do? Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-22 09:01:31 -0500

mforets gravatar image

updated 2017-01-22 09:04:52 -0500

  • use double backslash, as in legend_label='function equation: $y(x)= \\frac{1}{x}$', or
  • use a "raw string literal" flag, r, as in legend_label=r'function equation: $y(x)= \frac{1}{x}$'.
edit flag offensive delete link more


Seems to work fine. Thank you, now I'm aware of this tip!

Romuald_314 gravatar imageRomuald_314 ( 2017-01-22 09:35:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-01-22 08:31:33 -0500

Seen: 52 times

Last updated: Jan 22