I'm a new user of plotly. My plot's x-axis (label/tick) values do not match the data specified for the x axis.
import pandas as pd
import psycopg2 as odb
import plotly.express as px
from urllib.parse import quote_plus
from sqlalchemy import create_engine
connection = odb.connect(...)
q = """select SOMEATTR, OTHERATTR, SOMETYPE from SOMETABLE...."""
uri = f"postgresql+psycopg2://{quote_plus(user)}:{quote_plus(pw)}@{host}:{port}/{db}"
alchemyEngine = create_engine(uri)
df = pd.read_sql(q, connection)
fig = px.bar(df, x="SOMEATTR", y="OTHERATTR", color="SOMETYPE", orientation='h')
fig.update_xaxes(rangemode="normal")
fig.write_html('first_figure.html', auto_open=True)
SOMEATTR values range from 0 to 7.2808 in my example. The plot shows a label of 900 near the end of the bar chart.
I would expect axis labels/ticks ranging from 0 to 7 or 8, not 0-900.
Can someone help me get my x-axis values to represent the actual "x" data value range (0, 1, 2...8 etc.)? Is there a way to add a secondary axis to achieve this?


fig.update_xaxes(tickvals=[x for x in range(0,1000,100)], ticktext=[str(x) for x in range(0,10,1)])