Add data to an existing trace using fileopt='extend'

I went to the above link and tried to implement the given code for “Add data to an existing trace”. I just copy pasted the code, used my api keys, and put in some different values and ran the program several times. I cannot get the fileopt=‘extend’ option to work as it is supposed to. I have tried it numerous ways. How does this functionality work? How do I implement it correctly in the simplest way possible?

My goal is to update a simple graph with new data without losing the existing data.

Thanks

1 Like

Hi @mr.berry the link page is a legacy documentation page for using plotly on the cloud (online), we should have taken it down, sorry for the confusion. I expect you’re using a version of plotly >= 4.x, which works locally (no need for cloud access). Could you please explain more about what you want to do? Do you create a figure, display it, and later (as a consequence of which event?) you want to add new data?

1 Like

What I am trying to do is send new data to my graph and extend the trace. I create a graph out of some data, and then some time later I decide that more data should be added so I want to add that data but I don’t want to lose the data from earlier, I just want to extend the trace. This way, I don’t have to upload all the data at once every time because plotly limits upload sizes to 524.288 KB uploads at one time. I want to do incremental uploads that are all one continuous graph. The following is my code:

import Data as d
import plotly
import chart_studio.plotly as py
import plotly.graph_objs as go
import chart_studio

chart_studio.tools.set_credentials_file(username='zzzzzzzzzz', api_key='zzzzzzzzzzzzzzzzzzzzzz')

data_var = d.Data()

trace1 = go.Scatter(
    x=data_var.get_julian_date(),
    y=data_var.get_Ar(),
    xaxis='x1',
    yaxis='y1',
    marker=go.scatter.Marker(
        color='rgb(26, 118, 255)'
    )
)

data = [trace1]

layout = go.Layout(
    plot_bgcolor='#cbd0d6',
    paper_bgcolor='#cbd0d6',
    title=go.layout.Title(
        text=data_var.Ar,
        xref='paper',
        font=dict(
            family='Open Sans, sans-serif',
            size=22,
            color='#000000'
        )
    ),
    xaxis=go.layout.XAxis(
        title=go.layout.xaxis.Title(
            text='Julian Date',
            font=dict(
                family='Open Sans, sans-serif',
                size=18,
                color='#000000'
            )
        )
    ),
    yaxis=go.layout.YAxis(
        showexponent='all',
        exponentformat='e',
        title=go.layout.yaxis.Title(
            text='Ar',
            font=dict(
                family='Open Sans, sans-serif',
                size=18,
                color='#000000'
            )
        )
    )
)



fig = go.Figure(data=data, layout=layout)
py.plot(fig, filename='Ar')