🏥 🏭 Working on the COVID-19 response in Canada? Plotly & the Canadian government can help you and your organization. Learn more and get in touch.

Change y-axis legend to text in the bar graph

Hello everyone,

I want to know if I can change the legend of the y-axis of a bar graph to text, according to a certain standard.

Example: value 1 = bad; value 2 = good; value 3 = excellent

In the image below is the graphic I want to change

Hi @ivanildolb welcome to the forum! Yes, you can change the text of the yticks using the tickvals and ticktext attributes or layout.yaxis, see https://plot.ly/javascript/tick-formatting/#layout-attributes-with-respect-to-formatting-ticks and https://plot.ly/javascript/tick-formatting/#tickmode---array .

1 Like

Great !! That was exactly what I needed. Thanks !!

Now, in xaxis, I would like to leave only one date under each column, and not as it appears in the image below:

this is my code:

       var trace = {
            x: datas,
            y: realeiras,
            text: realeiras,
            textposition: 'auto',
            hoverinfo: "x",
            type: 'bar'
        };

        var layout = {
            title: 'Quantidade de Realeiras',
            xaxis: {
                tickformat: '%d/%m/%Y'
            }
        };
       
       var dados = [trace];
       Plotly.newPlot('myDiv', dados, layout);