Skip to content

"matches" attribute interfering with autorange #5095

Closed
@kricka91

Description

@kricka91

When I use two matching axes in my diagram, autorange doesn't seem to work properly.

<head>
	<!-- Load plotly.js into the DOM -->
	<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
</head>
<body>
	<div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>
var trace0 = {
  x: [0,1,2],
  y: [1,2,1],
  //y: [-2,3,8],
  yaxis:"y"
}

var data = [
  trace0,
  {yaxis: "y2"}
]

var layout = {
    width: 800,
    title: "matches interfering with autorange",
    yaxis2: {
      matches: "y",
      side: "right",
      overlaying: "y",
    },
}

Plotly.newPlot('myDiv', data, layout)

The range should automatically adapt to the y values and be around [1,2] (+ some margin), but it instead becomes [-1,4], which I believe is some hard coded default range. When I change the y values to below -1 and/or above 4, the autorange is computed correctly and extends to a larger range to fit all the points. When the matches attribute is removed, or when the empty data set linked to the second y axis is removed, the autorange works also for the original smaller range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions