# Plotly.extendTraces() can extend error\_x and error\_y?

**URL:** <https://community.plotly.com/t/plotly-extendtraces-can-extend-error-x-and-error-y/12299>\
**Category:** plotly.js\
**Created:** [August 1, 2018, 3:20pm UTC](https://community.plotly.com/t/plotly-extendtraces-can-extend-error-x-and-error-y/12299 "2018-08-01T15:20:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leofaber](https://avatars.discourse-cdn.com/v4/letter/l/f0a364/32.png) [@Leofaber](https://community.plotly.com/u/Leofaber)\
**Post date:** [August 1, 2018, 3:20pm UTC](https://community.plotly.com/t/plotly-extendtraces-can-extend-error-x-and-error-y/12299/1 "2018-08-01T15:20:23Z")

</div>

Hi,

I am using Plotly in a real-time streaming scenario and I need to display a scatter plot with statistical error bars. This is my trace object:  
var trace = {  
type: ‘scatter’,  
mode: ‘markers’,  
hoverinfo: ‘text’,  
text: [],  
x: [],  
y: [],  
marker: {  
size:8,  
symbol: [‘circle’]  
},  
error\_x: {  
array: [],  
arrayminus: [],  
symmetric: false,  
type: ‘data’,  
visible: true,  
width: 0,  
thickness : 1  
},  
error\_y: {  
array: [],  
arrayminus: [],  
symmetric: false,  
type: ‘data’,  
visible: true,  
width: 0,  
thickness : 1  
},  
};

Currently I am using the react() function in order to redraw the points each time new data arrive, but the performance decreases linearly as the number of points increases (with 300 points I have 0,4 s delay).

The extendTraces() function is what I should use to increment the performance, but apparently I can extend only the “x”, “y” and “text” (“trace-root-level”) arrays but not the “array” and “arrayminus” arrays that are located inside the error\_x object.

This function call works,  
Plotly.extendTraces(p, {text: [[newText]], y: [[newY]], x: [[newX]]}, [0])

I try to call the extendTraces() function with this other signature but it doesnt work:  
Plotly.extendTraces(p, {text: [[newText]], y: [[newY]], x: [[newX]], error\_x: { array: [[newXError]] } }, [0])

plotly.min.js:7 Uncaught Error: attribute error\_x must be an array of length equal to indices array length

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [August 1, 2018, 9:59pm UTC](https://community.plotly.com/t/plotly-extendtraces-can-extend-error-x-and-error-y/12299/2 "2018-08-01T21:59:00Z")

</div>

> [@Leofaber](#):
>
> Plotly.extendTraces(p, {text: [[newText]], y: [[newY]], x: [[newX]], error\_x: { array: [[newXError]] } }, [0])

`extendTraces` does not understand nested object, you need to use attribute strings. So something like:

```js
Plotly.extendTraces(p, {text: [[newText]], y: [[newY]], x: [[newX]], 'error_x.array': [[newXError]] }, [0])

```

should work.

---

<div class="post-metadata">

**Author:** ![Leofaber](https://avatars.discourse-cdn.com/v4/letter/l/f0a364/32.png) [@Leofaber](https://community.plotly.com/u/Leofaber)\
**Post date:** [August 1, 2018, 10:28pm UTC](https://community.plotly.com/t/plotly-extendtraces-can-extend-error-x-and-error-y/12299/3 "2018-08-01T22:28:47Z")

</div>

> [@etienne](#):
>
> error\_x.array

Thank you for the response. It works like a charm.  
I have another question: I am highlighting certain “upper limit” points with an arrow facing down, using annotations.  
Currently, I am pushing new annotations in the layout.annotations array and I use react() to display them.  
This approach redraw all the annotations from scratch. Is there a way to draw only the last new annotation and dont delete (and redraw) the old ones? This also could improve the performarce…

Thank you for the response,  
Cheers.
