X Axis Values Not displaying properly


When i am trying to give Years in X axis. X axis range is determined automatically. Example if i have X axis value as 2015,2016 X axis value is setting as 2014.5 ,2015,2015.5,2016,2016.5 Which is wrong. My X Axis should display only 2015,2016. Can you please help me on this. Below is the codepen for the same.

Making your xaxis a type 'category' should do the trick:

Thanks Its works for me.

Hi I’m new to Plot.ly

Sorry I have the same problem with my x-axis, but i can only find “linear” or “log” in axis type in Plot.ly

Can anyone please help? thank you so much!

Hi wendyt4,

the reference of plotly.js shows you the possibilities: https://plot.ly/javascript/reference/#layout-xaxis-type:

xaxis-type (enumerated: “-” | “linear” | “log” | “date” | “category” )
default: "-"
Sets the axis type. By default, plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question.

Thank you philschka.

i found it can be changed in JSON. Thank you :slight_smile: