# xarray.indexes.RangeIndex.linspace

#### *classmethod* RangeIndex.linspace(start, stop, num=50, endpoint=True, , coord_name=None, dim, dtype=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/indexes/range_index.py#L299-L364)

Create a new RangeIndex from given start / stop values and number of
values.

* **Parameters:**
  * **start** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Start of interval. The interval includes this value.
  * **stop** ([`float`](https://docs.python.org/3/builtins/functions.html#float), *optional*) – End of interval. The interval includes this value if `endpoint=True`.
  * **num** ([`float`](https://docs.python.org/3/builtins/functions.html#float), *optional*) – Number of values in the interval, i.e., dimension size (default: 50).
  * **endpoint** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True (default), the `stop` value is included in the interval.
  * **coord_name** (`Hashable`, *optional*) – Name of the (lazy) coordinate variable that will be created and
    associated with the new index. If `None`, the coordinate is named
    as the dimension name.
  * **dim** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Dimension name.
  * **dtype** ([`dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype), *optional*) – The dtype of the coordinate variable (default: float64).

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('f855035e-06f6-4f2a-a12d-7cb96f6942f8','186f1077-fc3c-4195-a82d-17df2baacbc5','ac879285-a7d0-49ea-848c-5001ab93780b','../lite/tree/../notebooks/index.html?path=5ef34198_80c1_466c_abe2_c974e065c649.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> from xarray.indexes import RangeIndex
```

```pycon
>>> index = RangeIndex.linspace(0.0, 1.0, 5, dim="x")
>>> ds = xr.Dataset(coords=xr.Coordinates.from_xindex(index))
```

```pycon
>>> ds
<xarray.Dataset> Size: 40B
Dimensions:  (x: 5)
Coordinates:
  * x        (x) float64 40B 0.0 0.25 0.5 0.75 1.0
Data variables:
    *empty*
Indexes:
    x        RangeIndex (start=0, stop=1.25, step=0.25)
```

<div id="ac879285-a7d0-49ea-848c-5001ab93780b" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('f855035e-06f6-4f2a-a12d-7cb96f6942f8','ac879285-a7d0-49ea-848c-5001ab93780b')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('f855035e-06f6-4f2a-a12d-7cb96f6942f8','ac879285-a7d0-49ea-848c-5001ab93780b')">Open In Tab</button></div><div id="186f1077-fc3c-4195-a82d-17df2baacbc5" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
