# Get the limits/range of the xaxis (or yaxis)

**URL:** <https://community.plotly.com/t/get-the-limits-range-of-the-xaxis-or-yaxis/40134>\
**Category:** 📊 Plotly Python\
**Created:** [May 27, 2020, 2:23am UTC](https://community.plotly.com/t/get-the-limits-range-of-the-xaxis-or-yaxis/40134 "2020-05-27T02:23:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayveesea](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jayveesea](https://community.plotly.com/u/jayveesea)\
**Post date:** [May 27, 2020, 2:23am UTC](https://community.plotly.com/t/get-the-limits-range-of-the-xaxis-or-yaxis/40134/1 "2020-05-27T02:23:30Z")

</div>

I’d like to get the limits of the xaxis but I’m struggling to find a method to do this. If `fig.update_layout(xaxis=dict(range=[x1,x2]))` has been called then `fig.layout.xaxis.range` will return the range (but not really useful because its already known).

If I try:

```auto
import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Scatter(x=[10, 20, 40], y=[4, 6, 5,])
)
print(fig.layout.xaxis.range)

fig.show()

```

it returns `None` for `print(fig.layout.xaxis.range)`. Is there a way to get this range for an axis?

thx!

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [May 27, 2020, 7:13am UTC](https://community.plotly.com/t/get-the-limits-range-of-the-xaxis-or-yaxis/40134/2 "2020-05-27T07:13:40Z")

</div>

Hi @jayveesea, in order to do this you need the Javascript figure object to communicate back to Python the value of its axis range. From Python you define the specification of a Javascript figure but after creating the figure it “lives its own life” in Javascript-land, without passing information back to Python. If you’re working in a Jupyter notebook environment you can create a `FigureWidget` which would print the axis range on relayout events, and register a callaback to `fig.layout.on_change` (like in [https://plotly.com/python/click-events/](https://plotly.com/python/click-events/) but for a different kind of events). Or you can use a Dash application [with a callback listening to `relayoutData`](https://dash.plotly.com/interactive-graphing).
