yhat / ggpy

ggplot port for python
http://yhat.github.io/ggpy/
BSD 2-Clause "Simplified" License
3.7k stars 572 forks source link

latex support? #202

Open nbecker opened 10 years ago

nbecker commented 10 years ago

ggplot2 couldn't replace mpl for me without LaTeX support. Any plans for this?

jankatins commented 10 years ago

Can you give an example what you expect (and does not work yet)? something selfcontained... Ideally also an example in plain matplotlib...

Is suspect that we simple have to set a parameter somewhere...

nbecker commented 10 years ago

Actually, I haven't tried ggplot2 yet - I'm just looking at it.

I'm referring to e.g.,

plt.title (r'This is a nice title $x^2 = y + 2$')

this is the simple way of using LaTeX in matplotlib strings. There is a more complex and complete way http://matplotlib.org/users/pgf.html

Is this possible with ggplot2?

jankatins commented 10 years ago

If that's everything it takes to get latex in the tile, then I think it should be possible via +ggtitle(r'...'). Usually we just pass the string through.

bwillers commented 10 years ago

This works for me:

ggplot(diamonds, aes(x='price', color='cut')) + \
    geom_density(fill=True, alpha=0.5) + \
    ggtitle(r'This is a nice title $x^2 = y + 2\sin(\pi)$')

The font is different for latex strings, it uses presumably your default tex font (in my case its CM), rather than the ggplot font settings. Otherwise it seems to work fine.