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!

How to add values to y2axis in multiple yaxis

Hello can any one tell me how to set values for yaxis. Present now it is picking default values.
Here is the example

var trace1 = {
x: [1, 2, 3],
y: [40, 50, 60],
name: ‘yaxis data’,
type: ‘scatter’

var trace2 = {
x: [2, 3, 4],
y: [4, 5, 6],
name: ‘yaxis2 data’,
yaxis: ‘y2’, // Here I need to set the values same as we did it in ‘y’, so that to show y2axis values dynamically
type: ‘scatter’

var data = [trace1, trace2];

var layout = {
title: ‘Double Y Axis Example’,
yaxis: {title: ‘yaxis title’},
yaxis2: {
title: ‘yaxis2 title’,
titlefont: {color: ‘rgb(148, 103, 189)’},
tickfont: {color: ‘rgb(148, 103, 189)’},
overlaying: ‘y’,
side: ‘right’
Plotly.newPlot(‘myDiv’, data, layout);

Thanks for writing in.

Can you clarify your question?

What do you mean by set the values for yaxis?

In, from my eyes, the y values are set to [40,50,60] and the y2 value to [4,5,6].

Are you referring the value displayed on the ticks? Do you want to update the y values?

Hi Please find screeshot. which i want exactly

You can do so using yaxis2.tickvals. I’ve updated the above example: