import plotly.plotly as py
import plotly.tools as tls
url = 'https://plot.ly/~vijayn/1212'
tls.embed(url)
vijay1212 = py.get_figure(url)
vijay1212['layout']['yaxis2']
{'autorange': True, 'overlaying': u'y', 'rangemode': u'tozero', 'showgrid': False, 'side': u'right', 'title': u'Take Rate %'}
vijay1212['layout']['yaxis2'].update(
autorange=False, # must turn off autorange to make 'range' have an effect
range=[0, 1.5]
)
py.iplot(vijay1212, filename='for-vijay')
Unfortunately Plotly date axes are not fully configurable yet. Setting autotick
to False
can lead to unwanted results in some situations.
vijay1212['layout']['xaxis']
{'autotick': False, 'tickfont': {'color': u'black', 'size': 10}, 'ticks': u'outside'}
vijay1212['layout']['xaxis'].update(
autotick=True
)
py.iplot(vijay1212, filename='for-vijay-2')
The above graph isn't bad. But there is currently no easy way to tell plotly to show every month value in dates. Some alternatives include
category
¶vijay1212['layout']['xaxis'].update(
type='category'
)
py.iplot(vijay1212, validate=False, filename='for-vijay-3')
vijay1212['layout']['xaxis'].update(
tickmode='array',
tickvals=vijay1212['data'][0]['x'],
ticktext=['Jan 2015', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', '' , '']
)
py.iplot(vijay1212, validate=False, filename='for-vijay-4')