python: plotly bar graph using y0 and dy offset

Viewed 1241

I'm investigating using plotly to replace some graphing I currently do in matplotlib.

I need to control a bar graph to have the bottom and top of each bar start and end at arbitrary vlaues.

In matplotlib this is fairly straight forward:

import matplotlib.pyplot as plt

plt.bar(0.5, height=4,bottom=2)
plt.ylim(0, 8)
plt.xlim(0, 2)

plt.show()

enter image description here

The docs for plotly seem to indicate I can do something similar by using y0 and dy arguments in the Bar object like so:

import plotly.offline as py
import plotly.graph_objs as go

trace1 = go.Bar(
    x=['x'],
    y0=2,
    dy=6,
)

fig = go.Figure(data=[trace1])
py.iplot(fig)

But this just gives me an empty plot?!

enter image description here

I also tried feeding the above matplotlib object into plotly's py.plot_mpl() but this raises PlotlyEmptyDataError.

thanks JP

1 Answers
Related