How can I combine different tickformats in my Plotly.js chart?

31 Views Asked by At

We're developing an AngularJS application with Plotly.js. What I need to do is format the numbers on the y axis tick marks with two specifications: 1) limit the number of digits to 3, and 2) suppress decimal expansions.

I can limit the number of digits to 3 with the following:

var layout = {
    yaxis: {
        tickformat: '3s'
    }
}

Before applying this, the graph looks like this:

enter image description here

After, it looks like this:

enter image description here

I can suppress the decimal expansion with the following:

var layout = {
    yaxis: {
        tickformat: '.0f'
    }
}

Before applying this, the graph looks like this:

enter image description here

After, it looks like this:

enter image description here

But I can't seem to figure out how to combine them together. Is it like this: 3s .0f? Is it like this: 3s.0f? Is it like this: 3s,.0f? <-- I've tried all of these and more and none of them work. How do you combine multiple formats in the tickformat layout property?

Thanks!

0

There are 0 best solutions below