Skip to content

Commit 368452d

Browse files
updating autotype documentation
1 parent 8d4032e commit 368452d

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

doc/python/axes.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,17 @@ The axis type is auto-detected by looking at data from the first [trace](/python
6060

6161
* First check for `multicategory`, then `date`, then `category`, else default to `linear` (`log` is never automatically selected)
6262
* `multicategory` is just a shape test: is the array nested?
63-
* `date` and `category`: require **more than twice as many distinct date or category strings** as distinct numbers or numeric strings in order to choose that axis type.
63+
* `date` and `category`: require **more than twice as many distinct date or category strings as distinct numbers** in order to choose that axis type.
6464
* Both of these test an evenly-spaced sample of at most 1000 values
65-
* Small detail: the `category` test sorts every value into either number or category, whereas for dates, 2- and 4-digit integers count as both dates and numbers.
6665

6766

6867
### Forcing an axis to be categorical
6968

70-
If you pass string values for the `x` or `y` parameter, plotly will automatically set the corresponding axis type to `category`, *except if enough of these strings contain numbers* as detailed above, in which case the axis is automatically set to `linear`. It is however possible to force the axis type by setting explicitely `xaxis_type` to be `category`.
69+
It is possible to force the axis type by setting explicitely `xaxis_type`. In the example below the automatic X axis type would be `linear` (because there are not more than twice as many unique strings as unique numbers) but we force it to be `category`.
7170

7271
```python
7372
import plotly.express as px
74-
fig = px.bar(x=[1, 2, 4, 10], y =[8, 6, 11, 5])
73+
fig = px.bar(x=["a", "a", "b", 3], y = [1,2,3,4])
7574
fig.update_xaxes(type='category')
7675
fig.show()
7776
```

doc/python/categorical-axes.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,16 @@ The axis type is auto-detected by looking at data from the first [trace](/python
5050

5151
* First check for `multicategory`, then `date`, then `category`, else default to `linear` (`log` is never automatically selected)
5252
* `multicategory` is just a shape test: is the array nested?
53-
* `date` and `category`: require **more than twice as many distinct date or category strings** as distinct numbers or numeric strings in order to choose that axis type.
53+
* `date` and `category`: require **more than twice as many distinct date or category strings as distinct numbers** in order to choose that axis type.
5454
* Both of these test an evenly-spaced sample of at most 1000 values
55-
* Small detail: the `category` test sorts every value into either number or category, whereas for dates, 2- and 4-digit integers count as both dates and numbers.
56-
5755

5856
### Forcing an axis to be categorical
5957

60-
If you pass string values for the `x` or `y` parameter, plotly will automatically set the corresponding axis type to `category`, *except if enough of these strings contain numbers* as detailed above, in which case the axis is automatically set to `linear`. It is however possible to force the axis type by setting explicitely `xaxis_type` to be `category`.
58+
It is possible to force the axis type by setting explicitely `xaxis_type`. In the example below the automatic X axis type would be `linear` (because there are not more than twice as many unique strings as unique numbers) but we force it to be `category`.
6159

6260
```python
6361
import plotly.express as px
64-
fig = px.bar(x=[1, 2, 4, 10], y =[8, 6, 11, 5])
62+
fig = px.bar(x=["a", "a", "b", 3], y = [1,2,3,4])
6563
fig.update_xaxes(type='category')
6664
fig.show()
6765
```

0 commit comments

Comments
 (0)