# Facet row and Facet columns are not organized as ascending/descending sequence of values

**URL:** <https://community.plotly.com/t/facet-row-and-facet-columns-are-not-organized-as-ascending-descending-sequence-of-values/39256>\
**Category:** 📊 Plotly Python\
**Created:** [May 11, 2020, 8:56pm UTC](https://community.plotly.com/t/facet-row-and-facet-columns-are-not-organized-as-ascending-descending-sequence-of-values/39256 "2020-05-11T20:56:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alamjhilam](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@alamjhilam](https://community.plotly.com/u/alamjhilam)\
**Post date:** [May 11, 2020, 8:56pm UTC](https://community.plotly.com/t/facet-row-and-facet-columns-are-not-organized-as-ascending-descending-sequence-of-values/39256/1 "2020-05-11T20:56:03Z")

</div>

I have a dataset stored in a pandas dataframe. I plot them using plotly.express. My code is given below.

As you can see the facet columns are not organized as per ascending/descending value of the “Vov” field. The same is true for facet row. I look for the unique values of “Vov” and “T” field from the dataframe. It turns out that plotly is just following the sequence that comes from the data[‘Vov’].unique() command.

I also checked, the datatype of both the “Vov” field and “T” field is float64, not str.

How can I organize the facet rows and columns in a right sequence?

fig = px.scatter(data, x=“x”, y=“y”, color=round(np.log10(data[“z”])), facet\_col=data[“Vov”],facet\_row=‘T’)  
fig.update\_layout(coloraxis\_colorbar=dict(title=“Z”,))  
fig.update\_yaxes(type=“log”)  
fig.update\_xaxes(type=“log”)  
fig.show()

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

---

<div class="post-metadata">

**Author:** ![nicolaskruchten](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/nicolaskruchten/32/7018_2.png) [@nicolaskruchten](https://community.plotly.com/u/nicolaskruchten)\
**Post date:** [May 11, 2020, 9:10pm UTC](https://community.plotly.com/t/facet-row-and-facet-columns-are-not-organized-as-ascending-descending-sequence-of-values/39256/2 "2020-05-11T21:10:03Z")

</div>

PX sorts by data frame order by default but this is overrideable, so you can either pre-sort your dataframe, or you can manually force the sequence using the `category_orders` parameter. There are some examples here: [https://plotly.com/python/styling-plotly-express/](https://plotly.com/python/styling-plotly-express/)

---

<div class="post-metadata">

**Author:** ![alamjhilam](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@alamjhilam](https://community.plotly.com/u/alamjhilam)\
**Post date:** [May 11, 2020, 9:27pm UTC](https://community.plotly.com/t/facet-row-and-facet-columns-are-not-organized-as-ascending-descending-sequence-of-values/39256/3 "2020-05-11T21:27:48Z")

</div>

Thanks you 🙂  
It works as I wanted.
