Black Lives Matter. Please consider donating to Black Girls Code today.

Unable to Display error bars

Hi everyone
I am pltting a simple graph using plotly(offline) . I want to display y axis values corresponding to x axis values along with error bars in y axis . I am using error_y to plot the errors . However I am able to plot the x,y coordinates but I am not getting the error bars in in my final result . I am using following code :

`   graphs = [     
      dict(     
          data=[
              go.Scatter(
               x=[1, 2, 3],
               y=[2, 1, 3],
               error_y=dict(
               type='data',
               array=[1, 2, 3],
               visible=True
                )
             )
         ],
        layout=dict(
            title=''  
        )
    )
]`

Then I am converting to JSON using follwing and sending Json to front end for dispay ;

ids = ['graph-{}'.format(i) for i, _ in enumerate(graphs)] graphJSON = json.dumps(graphs, cls=plotly.utils.PlotlyJSONEncoder)

Can someone help me :frowning:

graphJSON looks like :
[{"layout": {"title": ""}, "data": [{"type": "scatter", "y": [2, 1, 3], "error_y": {"type": "data", "array": [1, 2, 3], "visible": true}, "x": [1, 2, 3]}]}]

That’s strange.

Can you replicate the example shown on this page https://plot.ly/python/error-bars/ ?

Actually I have copied the same code from over there … In my index.html (that i am using to display plot) I am u sing the following code . This might make myself clear !

`

 <div class="hello" id="section" >

<script type="text/javascript">
    
    var graphs = {{graphJSON | safe}};
    var ids = {{ids | safe}};
    for(var i in graphs) {
      
        Plotly.plot("section", // the id of the div, created above
                    graphs[i].data,
                    graphs[i].layout || {});
    }


 </script>  </div>

Do You find anything wrong over here :frowning:
I am new to plotly :slight_smile:

You might need to brush on up on your JavaScript.

That filename='basic-error-bar' won’t work.

Oh I am really sorry , actually I have removed that from original code … But still it doesnot work for me :frowning:
I have edited my above comment accordingly :slight_smile:

Can you your browser console and see if any errors are getting logged?

No there are no errors :frowning:

can you add a console.log(graphs) before the Plotly.plot call and while at it, add a console.log(Plotly.version) too ?