Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Best way to alter plot JSON in real-time?

I’m writing an application in Python in which I’d like users to be able to alter Plotly plots directly from the Python interpreter. Based on what I’ve read in the documentation and source, I need to create functions that get and set JSON attributes. What is the best way to do this so as to be portable across all the plotly APIs? Like I said, I’m initially going to be developing this in Python, but I’d eventually like to provide the same functionality for Matlab, Javascript, R, etc.

Based on my initial exploration, it looks like each trace object has associated “get” and “set” methods that allow for inspecting and updating of the JSON. Is this the preferred way of doing this? If so, is there a way that I can allow changes to propagate to the HTML plot immediately, as in the realtime JSON editor demo here:, or does this require a call to plotly.offline.plot() each time a change is made?

I also had a question about the Plotly REST API. Is this only for applications that want to interface with plots stored in the user accounts on Plotly’s servers, or can its use also be applied to offline plots?

Thanks for your help!

  • Daniel

The REST API is used to make requests to our servers, and thus do not affect offline plots. Note that on the json chart editor that you linked, it is done in javascript and plotly.js, and thus everything occurs in the browser. What this also means is that you aren’t utilizing the REST API, and thus this can be done offline (as long as you have a local version of plotly.js). To mimic this behaviour, you may try to utilize shiny in R ( and ipywidgets in Python (

Thanks for the info. I did indeed manage to create interactive behavior by writing Javascript code that calls on methods such as Plotly.restyle() and Plotly.relayout() from the Plotly.js library. Is there any way that I can wrap calls to these Javascript functions with Python, or are there comparable restyling and relayout methods for the Python API? I’d like to be able to change the plot by issuing commands from the Python interpreter without reloading the page. From what I can gather from the source, the plot method works by writing Javascript to a file.

Hi dmcneela,I’m new to plotly, I have the same needs like you. Do you find some methods to resolve this problem?