为什么我的积积图多了一条线?

时间:2019-10-18 15:03:32

标签: python plotly

我有一个数据框tx_user_type_revenue: enter image description here

我使用plotly创建了一个绘图,但是由于某种原因,它显示了额外的一行。这段代码可以很好地处理其他数据。

enter image description here

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

#filtering the dates and plot the result
tx_user_type_revenue = tx_user_type_revenue.query("InvoiceYearMonth > 201601 and InvoiceYearMonth < 201901")
plot_data = [
    go.Scatter(
        x=tx_user_type_revenue.query("UserType == 'Existing'")['InvoiceYearMonth'],
        y=tx_user_type_revenue.query("UserType == 'Existing'")['Revenue'],
        name = 'Existing'
    ),
    go.Scatter(
        x=tx_user_type_revenue.query("UserType == 'New'")['InvoiceYearMonth'],
        y=tx_user_type_revenue.query("UserType == 'New'")['Revenue'],
        name = 'New'
    )
]

plot_layout = go.Layout(
        xaxis={"type": "category"},
        title='New vs Existing Customers Revenue'
    )
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)

0 个答案:

没有答案