Last tick not showing

Hi all,

I want to be able to set my own tick markers, and I figured I was able to do that using tickvals. However… I noticed that the last tick will only go as high as the max value on the graph. For example, I have tickvals array = [0,1,2,3,4,5] for the y-axis. The highest value in my y values is ~4.5. On the graph, I am expecting to see 0,1,2,3,4,5 on the y axis ticks but it only goes up to 4 (0,1,2,3,4). I’m thinking this is becuase the max value of my y values is at 4. Is there any way to show all the values despite the max value being lower than the max tickval?


1 Like

Hi @kennyhuynh125 where you able to get this working? i am facing the same problem and the solution i have come up with is not very nice or good.

1 Like

Hey @kennyhuynh125

I would also like to implement this in a project I am currently working on.

If you find a solution could you please share it with us as I am unable to find an alternative solution elsewhere on this community forum or on any other Plotly JS resource.


1 Like

I think you need to set the range of your x axis manually, like here:

This way you force plotly to render the ticks AFAIK.

Hi Chiaki,

I’m looking for a method of setting the range without having to parse through the data I intend to plot.

So if I have a data set like, for example, this: [10, 4, 6, 7, 5]

I don’t want my max tick to be 10. I want to be able to see the next tick value; 11 in this example.

Manually setting the range works but it isn’t an ideal solution as it requires parsing through the entire data set.

Ideally I would like some way of telling Plotly that I want my ticks drawn in the range [0, max + 1]

Thanks for the reply but I do not think this is the best solution for my use case in my particular project.


You can use this:

Thanks :slight_smile:

Hi @darrenjwhite i was wondering if the solution @Chiaki provided helped you as this was something i tried in our project however the end result was not what we wanted as we still needed to parse through the data.

What exactly do you guys mean by “parse through the data”? If you’re talking about looking through the data with a machine: there’s no way around it. The program needs to find the highest value in the array and for this it has to “parse” through the whole array to find it. Afterwards you can add +1 to this found value as described above and get what you want.

If you meant looking through the data with a human eye: Holy moly, no you don’t need to do that. Just use Math.max as described above.

Hi Lee,

This solution does not work.

I have a bar chart that can display multiple traces of data. I have an user interface built around this bar chart that allows an end user to switch between grouped and stacked modes.

For grouped mode:
The solution you mentioned above will work to an extent. I get the max value from each trace and add 1. Although I want the ticks between the first and last tick to be plotted as whole integers. So this, to the best of my knowledge, requires intensive conditional logic to determine a valid dtick value.

For stacked mode:
In stack mode your solution will simply not work. We need to calculate the max by adding the elements from each respective index from each of our traces. So if we have two traces to be plotted on a bar chart in stacked mode; we would need to add traceOne[0] + traceTwo[0] and traceOne[1] + traceTwo[1] etc, push all these values to a new array then get the max from this new array then perform our conditional logic mentioned above to set the dticks value.

So as you can see, as simple as your solution is, it becomes very intensive in my use case. We have many more use cases where this is applicable.

My question was: Is there any simpler way of telling Plotly you want to see max + n?

I know post render (after you call Plotly.newPlot()) you can access properties for the plot such as max and min values as well as many more. I’m just hesitant to be performing these calculations more than required.

@Chiaki, please either take a step back and try to look at things from our perspective or just leave this discussion as copying and pasting the first link you find from a google search is counter intuitive at this stage. I’m quite capable of doing so myself. Don’t be so patronising. Thanks for your input thus far regardless.

Your help is much appreciated.


Hi @darrenjwhite your situation sounds very similar to mine I was also hoping for a way to get the values generated from plotly otherwise for me, due to the extreme differences in the data we work with, I have to set some crazy conditional logic. The only other thing I was leaning towards was delving into the plotly library which I do not want to do. If you do come up with a way of achieving this I would be most grateful to you if there was a way you could let me know.

Hi @Chiaki Thanks for your input however I had previously looked into the suggestions you made and as much other stuff I could find relating to the topic before coming here.

Hi @darrenjwhite @Leemull, I am facing same problem. Did you find any solution to this?