# Reversed x axis

**URL:** https://community.plotly.com/t/reversed-x-axis/623
**Category:** plotly.js
**Created:** [March 6, 2016, 11:43pm UTC](https://community.plotly.com/t/reversed-x-axis/623 "2016-03-06T23:43:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![JonLikesToast](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@JonLikesToast](https://community.plotly.com/u/JonLikesToast)
#### Post date: [March 6, 2016, 11:43pm UTC](https://community.plotly.com/t/reversed-x-axis/623/1 "2016-03-06T23:43:11Z")

</div>

I’m plotting some data and the x axis keeps reversing.

The bigger values of the x axis are on the left and the smaller values are on the right hand side

I’m just plotting 4 scatter graphs with error bars

x,y,error\_y,error\_x

Fourmond1978.tot  
6.70000E-08,170.0,20.0,0.0  
Fourmond1978A001.tot  
7.20000E-08,1340.0,40.0,0.0  
Jarczyk1961.tot  
2.53000E-08,0.048,0.015,0.0  
Mughabghab2006.tot  
2.53000E-08,0.0385,0.003,0.0

is there any way of forcing the axis to stay with the smallest numbers on the left and the largest on the right?

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/718a8188a064a0946bcb774fb0eef5d8aa6cc25b.png)

---

<div class="post-metadata">

### Author: ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)
#### Post date: [March 7, 2016, 1:55pm UTC](https://community.plotly.com/t/reversed-x-axis/623/2 "2016-03-07T13:55:14Z")

</div>

This looks strange.

Could you provide a reproducible code snippet?

---

<div class="post-metadata">

### Author: ![JonLikesToast](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@JonLikesToast](https://community.plotly.com/u/JonLikesToast)
#### Post date: [March 7, 2016, 2:25pm UTC](https://community.plotly.com/t/reversed-x-axis/623/3 "2016-03-07T14:25:30Z")

</div>

Thanks for the response.

The graph reads CSV values from a server and passes the values to a function to plot.

I’m still a beginner with JS however the x,y,error\_x ,error\_y and legend text are passed to a function for plotting.

this is the function

function makeScatterPlotly( x, y ,dy,dx,legend ){  
var plotDiv = document.getElementById(“plot”);  
var traces2 = [{  
x: x,  
y: y,  
mode: ‘markers’,  
error\_y: {  
type: ‘data’,  
array: dy,  
visible: true  
},  
error\_x: {  
type: ‘data’,  
array: dx,  
visible: true  
},  
type: ‘scatter’,  
name: legend,  
marker: {  
size: 8  
},  
}];  
var layout = {  
showlegend: true,  
autosize: true,  
width: w,  
height: h/1.5,  
margin: {  
t: 20  
},  
xaxis: {  
type: log\_x,  
title: xaxis\_title,  
borderwidth: ‘50’,  
exponentformat: ‘e’,  
showline: true,  
rangemode: ‘tozero’,  
linecolor: ‘#969696’,  
linewidth: 4,  
autorange: true,  
mirror: true,  
zeroline: false  
},  
yaxis: {  
type: log\_y,  
title: ‘Cross section (barns)’,  
exponentformat: ‘e’,  
showexponent: ‘All’,  
borderwidth: ‘50’,  
showline: true,  
rangemode: ‘nonnegative’,  
linecolor: ‘#969696’,  
linewidth: 4,  
autorange: true,  
mirror: true,  
zeroline: false  
}  
};

```
  Plotly.plot('myDiv', traces2,layout,{displayModeBar: true},{showLink: false});
};
```

---

<div class="post-metadata">

### Author: ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)
#### Post date: [March 7, 2016, 2:57pm UTC](https://community.plotly.com/t/reversed-x-axis/623/4 "2016-03-07T14:57:27Z")

</div>

I suspect that something is wrong with how you specified the `xaxis` type. What’s the value of `log_x` ?

Here’s a working example: http ://codepen.io/etpinard/pen/vGLJRo

---

<div class="post-metadata">

### Author: ![JonLikesToast](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@JonLikesToast](https://community.plotly.com/u/JonLikesToast)
#### Post date: [March 7, 2016, 8:59pm UTC](https://community.plotly.com/t/reversed-x-axis/623/6 "2016-03-07T20:59:21Z")

</div>

I think it might have been the rangemode: ‘tozero’, setting which was struggling, I guess this makes sense with a log scale plot. Many thanks for the help again

---

<div class="post-metadata">

### Author: ![JonLikesToast](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@JonLikesToast](https://community.plotly.com/u/JonLikesToast)
#### Post date: [March 7, 2016, 8:59pm UTC](https://community.plotly.com/t/reversed-x-axis/623/7 "2016-03-07T20:59:53Z")

</div>

the log\_x and log\_y variables are set to ‘log’
