Autoscale issues


I update my previous post because i think i am near to the problem.

I have debugged and i saw this:

When I add a new annotation to any plot I add this annotation to a general array and then I loop over all the plots to add the new annotation. Each annotation has a Y value that is the mid of the Y axis of the plot. In every plot is different.

One annotation looks like this:

var annotation = {
	x : date,
	xref : 'x',
	yref : 'y',
	text : textToShow,
	fullText : text,
	userAnnotations : userAnnotationArray,
	textangle : 270,
	showarrow : false,
	arrowhead : 3,
	arrowwidth : 0.1,
	arrowcolor : 'white',
	standoff : 100,
	xshift : 10,
	y : layout.midValue,		
	textposition : 'bottom',

At this time im getting the Y value from a custom property i setted in the layout called midValue.

At the time of the relayout loop i get the annotations from a global array and then i set the Y value with the midValue of the current layout.

It all works fine until i use autoscale, then it places all the annotations with the Y value of the latest plot.

Looks like some field is getting mutated.

Would you mind sharing a reproducible example to help us debug?


I made a pen with the minimum for work. Another issue is if you double click it make a little resize… How can i get rid of that?

When you click on the add annotation button it will add the annotations in the right place, but if you double click in the first plot it will use the Y value of the last relayouted plot.

Thanks for your time:

Plotly.newPlot(gd, data, layout, {
  doubleClick: 'reset'
  // the default value is 'reset+autosize'

I see. Your code is a little difficult to read - which makes a little outside the scope of these free forums. If you can try isolating the problem, I’ll gladly look at the issue again. Thank you.

Hi ettiene,

Thanks for your time, i’ve tried to simplify but i can’t.

Problably i enter myself into a hell.

I will try to fix by myself. Actually i’ve been trying different approach to this, but it seems to use the Y of the latest relayouted plot in the others plots that are actually relayouted.

Even if i use yanchor: ‘middle’ it sets the Y of the plots to the Y of the latest relayouted plot.

Ok, i solved it.

I was a suspecting it was about pointers.

I created a new copy of the layout object and passed it to the relayout function:

var annotationsGood = jQuery.extend(true, {}, annotationsForLayout[ly.sampleType]);

Thanks for your time and sorry for the inconvenience.

1 Like