# Axes format/sorting bug

**URL:** <https://community.plotly.com/t/axes-format-sorting-bug/20184>\
**Category:** 📊 Plotly Python\
**Created:** [February 27, 2019, 5:24am UTC](https://community.plotly.com/t/axes-format-sorting-bug/20184 "2019-02-27T05:24:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsm](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jsm](https://community.plotly.com/u/jsm)\
**Post date:** [February 27, 2019, 5:24am UTC](https://community.plotly.com/t/axes-format-sorting-bug/20184/1 "2019-02-27T05:24:23Z")

</div>

I’m trying to plot a dual Y axis plot with a mm:ss on the Y1 axis.

As you can see in the graph, plotly isn’t sorting the hh:mm:ss values correctly.

If i leave the data as “seconds”, it will display fine.

If I convert seconds to a python timedelta and put into the list as a str and format as a date on the axis, I get this bizarre result. 1:49 gets sorted as the lowest value instead of where it belongs.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/2/22a880b93dbea8b350c14ffa673dd6f43f519dd7.png)

I’m looking for a way to have seconds display as mm:ss on a y access via the python API.

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 27, 2019, 11:23am UTC](https://community.plotly.com/t/axes-format-sorting-bug/20184/2 "2019-02-27T11:23:14Z")

</div>

Hi @jsm,

Plotly.py doesn’t have specific support for the `timedelta` type. I think you could use a `datetime` array and then format the ticks to only display hh:mm:ss (using the `yaxis.tickformat` property).

Feel free to add a reproducible example if you’d like help working through the details,

-Jon

---

<div class="post-metadata">

**Author:** ![jsm](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jsm](https://community.plotly.com/u/jsm)\
**Post date:** [February 27, 2019, 2:37pm UTC](https://community.plotly.com/t/axes-format-sorting-bug/20184/3 "2019-02-27T14:37:28Z")

</div>

Jon,

Thanks! That did the trick. White iterating over the values in the CSV, I just used this:

```auto
Pace.append(datetime.datetime.fromtimestamp(1514764800+int(row['Current_Pace'])))
Time.append(datetime.datetime.fromtimestamp(1514764800+float(row['Time'])))

```

and formatted the axis with:

```auto
yaxis=dict(
    title='Split',
    tickformat='%M:%S',
    range=[min(Pace)-datetime.timedelta(seconds=20), max(Pace) + datetime.timedelta(seconds=20)]
),

```

and everything worked as expected.
