# Why plotly go see my strings as integer?

**URL:** <https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107>\
**Category:** 📊 Plotly Python\
**Created:** [December 11, 2020, 5:21am UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107 "2020-12-11T05:21:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilallozdemir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/bilallozdemir/32/19945_2.png) [@bilallozdemir](https://community.plotly.com/u/bilallozdemir)\
**Post date:** [December 11, 2020, 5:21am UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107/1 "2020-12-11T05:21:49Z")

</div>

Hi,  
I realized something with go.bar.  
As you see, on x axis there must be “x\_variables” but some of them looks like integer and plotly go act like this. Why 😕

> ```
> import pandas as pd
> import plotly.graph_objects as go
> df=pd.DataFrame({"x_variables":['94508', 'a0780', 'b8360', '19c35', '80021', '77593'],
> "y1":[100,100,100,100,100,100],
> "y2":[150,150,150,150,150,150]})
> 
> btrace1 = go.Bar(
> x=df["x_variables"],
> y=df["y1"]
> )
> btrace2 = go.Bar(
> x=df["x_variables"],
> y=df["y1"]
> )
> bdata = [btrace1, btrace2]
> blayout = go.Layout(
> barmode='stack',
> plot_bgcolor='rgba(0,0,0,0)'
> )
> 
> barp = go.Figure(data=bdata, layout=blayout)
> barp
> 
> ```

My graph is this. You can check with codes.  
 ![aaaaaaaaaaaa](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/0/0249db16d45ae31c618b3296e9095b288c61ac94.png)

---

<div class="post-metadata">

**Author:** ![bilallozdemir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/bilallozdemir/32/19945_2.png) [@bilallozdemir](https://community.plotly.com/u/bilallozdemir)\
**Post date:** [December 11, 2020, 5:41am UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107/2 "2020-12-11T05:41:59Z")

</div>

Now i realisez this:

- If i update x axises like this

```auto
df["x_variables"].astype(str)+"_"

```

there is no problem an I can see my graph like I expected. But this is not the one I want. Because I have a live stream data and I have so much unique id (like in the x axis). And this type of things could not be good for dashboard.

If you have any other option, I wanna hear this.

---

<div class="post-metadata">

**Author:** ![bilallozdemir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/bilallozdemir/32/19945_2.png) [@bilallozdemir](https://community.plotly.com/u/bilallozdemir)\
**Post date:** [December 11, 2020, 11:28am UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107/3 "2020-12-11T11:28:09Z")

</div>

Hi again,

I didnt solve this issue but I have new question.

I have other 10 variables. And I wanna see as hover info some of them.

My go.bar structure is same as top. And i use this for 1 variable info and it work well.

> hovertext=df[“TimeStamp”],

i add this to both of the traces. But when i tried this:

> hovertext=[df[“TimeStamp”],df[“anotherVar”],"df[“andAnother”]],

It is not working. I want some advice.

---

<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:** [December 11, 2020, 8:38pm UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107/4 "2020-12-11T20:38:01Z")

</div>

Regarding your initial question, if you upgrade to `plotly` version 4.14 the axis auto-detection code should do what you expect.

Regarding your other question, you can use `px.bar(df, x="var", y="var", hover_data=["var", "var", "var"])` to do this more easily than having to build up your chart from `go.Bar()` objects.

---

<div class="post-metadata">

**Author:** ![bilallozdemir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/bilallozdemir/32/19945_2.png) [@bilallozdemir](https://community.plotly.com/u/bilallozdemir)\
**Post date:** [December 12, 2020, 6:56am UTC](https://community.plotly.com/t/why-plotly-go-see-my-strings-as-integer/48107/5 "2020-12-12T06:56:31Z")

</div>

Hi,

Thanks for answer. But second answer didn’t work well. Because my graph is looks like top.

I have 2 traces, and i use them both with stack bar. I use for this go.Figure(data=data,layout=layout) data=[trace1,trace2] and both my traces are created with go.Bar.

So I’m trying to say, my structure “go” based. If i make one of them with “px” my structure boom.

If you have an advice. I want to hear this.
