Ask Your Question

How to put fractions in legends?

asked 2017-01-22 15:31:33 +0200

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 16:01:31 +0200

mforets gravatar image

updated 2017-01-22 16:04:52 +0200

  • 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 16:35:36 +0200 )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 15:31:33 +0200

Seen: 328 times

Last updated: Jan 22 '17