Pergunta

Been loving the new ggplot module in Python but I haven't been able to format my y labels as percent instead of decimals. The below code produces the following image. Note that the labels = 'percent' code does not produce the intended format.

plot = ggplot(aes(x='Date', y='return', color='Stocks'),data=rx) +\
geom_line() +\
scale_x_date(breaks=date_breaks('1 day'), labels='%b %d %Y') +\
scale_y_continuous(labels= 'percent') +\
ylab('Cumulative Return') + ggtitle('S&P Sector Performance') 

enter image description here

Foi útil?

Solução

This is now available in version 0.5.3 (I just pushed this).

>>> from ggplot import *
>>> import numpy as np
>>> import pandas as pd
>>> df = pd.DataFrame({ "x": np.arange(0, 10), "y": np.arange(0, 1, 0.1) })
>>> ggplot(df, aes(x='x', y='y')) +\
... geom_point() +\
... scale_y_continuous(labels='percent')

ggplot scale_x_continuous percent

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top