Skip to content

big batch of layout.geo docs #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ plotly/tests/test_orca/images/*/tmp
temp-plot.html
.vscode
doc/python/.ipynb_checkpoints
doc/python/.mapbox_token
35 changes: 16 additions & 19 deletions doc/python/axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jupyter:
text_representation:
extension: .md
format_name: markdown
format_version: '1.2'
format_version: "1.2"
jupytext_version: 1.3.0
kernelspec:
display_name: Python 3
Expand All @@ -22,7 +22,8 @@ jupyter:
pygments_lexer: ipython3
version: 3.7.3
plotly:
description: How to adjust axes properties in python. Includes examples of linear
description:
How to adjust axes properties in python. Includes examples of linear
and logarithmic axes, axes titles, styling and coloring axes and grid lines,
and more.
display_as: file_settings
Expand All @@ -34,23 +35,24 @@ jupyter:
thumbnail: thumbnail/axes.png
---

This tutorial explain how to set the properties of Cartesian axes, namely [`go.layout.XAxis`](/python/reference/#layout-xaxis) and [`go.layout.YAxis`](python/reference/#layout-xaxis). Other kinds of axes are described in other tutorials:
This tutorial explain how to set the properties of 2-dimensional Cartesian axes, namely [`go.layout.XAxis`](/python/reference/#layout-xaxis) and [`go.layout.YAxis`](python/reference/#layout-xaxis). Other kinds of axes are described in other tutorials:

- [3D axes](/python/3d-axes) The axis object is [`go.layout.Scene`](/python/reference/#layout-scene)
- [Polar axes](/python/polar-chart/). The axis object is [`go.layout.Polar`](/python/reference/#layout-polar)
- [Ternary axes](/python/ternary-plots). The axis object is [`go.layout.Ternary`](/python/reference/#layout-ternary)
- For Geo axes, see [this choropleth example](/python/choropleth-maps/#world-choropleth-map). The axis object is [`go.layout.Geo`](/python/reference/#layout-geo)
- For Mapbox axes, see the different mapbox tutorials in the [Maps page](/python/maps/). The axis object is [`go.layout.Mapbox`](/python/reference/#layout-mapbox)
- Color axes are described in the [color scales tutorial](/python/colorscales/).
- [Geo axes](/python/map-configuration/). The axis object is [`go.layout.Geo`](/python/reference/#layout-geo)
- [Mapbox axes](/python/mapbox-layers/). The axis object is [`go.layout.Mapbox`](/python/reference/#layout-mapbox)
- [Color axes](/python/colorscales/). The axis object is [`go.layout.Coloraxis`](/python/reference/#layout-coloraxis).

**See also** the tutorials on [subplots](/python/subplots) and [multiple axes](/python/multiple-axes/).

The different types of Cartesian axes are
The different types of Cartesian axes are

- 'linear'
- 'log' (see the [example below](#logarithmic-axes))
- 'date' (see the [tutorial on timeseries](/python/time-series/))
- 'category' (see for example [Bar Charts](/python/bar-charts/))
- 'multicategory' (see the [example below](#subcategory-(multicategory)-axes) ))

- 'multicategory' (see the [example below](<#subcategory-(multicategory)-axes>))

#### Logarithmic Axes

Expand Down Expand Up @@ -92,7 +94,7 @@ fig.show()

### Forcing an axis to be categorical

If you pass string values for the `x` or `y` parameter, plotly will automatically set the corresponding axis type to `category`, with the exception of string of numbers, in which case the axis is linear. It is however possible to force the axis type by setting explicitely `xaxis_type` to be `category`.
If you pass string values for the `x` or `y` parameter, plotly will automatically set the corresponding axis type to `category`, with the exception of string of numbers, in which case the axis is linear. It is however possible to force the axis type by setting explicitely `xaxis_type` to be `category`.

```python
import plotly.express as px
Expand Down Expand Up @@ -150,17 +152,16 @@ fig.update_layout(title_text="Multi-category axis",)
fig.show()
```


#### Toggling Axes Lines, Ticks, Labels, and Autorange

The different groups of Cartesian axes properties are
The different groups of Cartesian axes properties are

- tick values (locations of tick marks) and tick labels. Tick labels are placed at tick values.
- lines: grid lines (passing through tick values), axis lines, zero lines
- title of the axis
- range of the axis
- domain of the axis


#### Tick Placement, Color, and Style

##### Toggling axis tick marks
Expand All @@ -169,7 +170,6 @@ Axis tick marks are disabled by default for the default `plotly` theme, but they

Here is an example of turning on inside x-axis and y-axis ticks in a faceted figure created using Plotly Express. Note how the `col` argument to `update_yaxes` is used to only turn on the y-axis ticks for the left-most subplot.


```python
import plotly.express as px
df = px.data.iris()
Expand Down Expand Up @@ -265,7 +265,6 @@ fig.update_yaxes(showticklabels=False)
fig.show()
```


##### Set axis label rotation and font

The orientation of the axis tick mark labels is configured using the `tickangle` axis property. The value of `tickangle` is the angle of rotation, in the clockwise direction, of the labels from vertical in units of degrees. The font family, size, and color for the tick labels are stored under the `tickfont` axis property.
Expand Down Expand Up @@ -324,7 +323,6 @@ fig.update_layout(title_text="Apple Stock Price")
fig.show()
```


### Axis lines: grid and zerolines

##### Toggling Axis grid lines
Expand Down Expand Up @@ -534,7 +532,6 @@ fig.update_yaxes(range=[3, 9])
fig.show()
```


### Fixed Ratio Axes

The `scaleanchor` and `scaleratio` axis properties can be used to force a fixed ratio of pixels per unit between two axes.
Expand Down Expand Up @@ -593,7 +590,7 @@ fig.show()

##### Decreasing the domain spanned by an axis

In the example below, the x and y axis are anchored together, and the range of the `xaxis` is set manually. By default, plotly extends the range of the axis (overriding the `range` parameter) to fit in the figure `domain`. You can restrict the `domain` to force the axis to span only the set range, by setting `constrain='domain'` as below.
In the example below, the x and y axis are anchored together, and the range of the `xaxis` is set manually. By default, plotly extends the range of the axis (overriding the `range` parameter) to fit in the figure `domain`. You can restrict the `domain` to force the axis to span only the set range, by setting `constrain='domain'` as below.

```python
import plotly.graph_objects as go
Expand Down Expand Up @@ -687,7 +684,7 @@ fig.show()

### Axis range for log axis type

If you are using a `log` type of axis and you want to set the range of the axis, you have to give the `log10` value of the bounds when using `fig.update_xaxes` or `fig.update_layout`. However, with `plotly.express` functions you pass directly the values of the range bounds (`plotly.express` then computes the appropriate values to pass to the figure layout).
If you are using a `log` type of axis and you want to set the range of the axis, you have to give the `log10` value of the bounds when using `fig.update_xaxes` or `fig.update_layout`. However, with `plotly.express` functions you pass directly the values of the range bounds (`plotly.express` then computes the appropriate values to pass to the figure layout).

```python
import plotly.express as px
Expand Down
4 changes: 4 additions & 0 deletions doc/python/bubble-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jupyter:
thumbnail: thumbnail/bubble-map.jpg
---

#### Base Map Configuration

Plotly figures made with `px.scatter_geo`, `px.line_geo` or `px.choropleth` functions or containing `go.Choropleth` or `go.Scattergeo` graph objects have a `go.layout.Geo` object which can be used to [control the appearance of the base map](/python/map-configuration/) onto which data is plotted.

### Bubble map with Plotly Express

[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). With `px.scatter_geo`, each line of the dataframe is represented as a marker point. The column set as the `size` argument gives the size of markers.
Expand Down
Loading