From 391568b03bd4fa0324ee70996c53ac1a1999b90c Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 27 Apr 2022 13:57:05 -0400 Subject: [PATCH 01/21] Update axes.md - Add minor ticks example - Add griddash example --- doc/python/axes.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/doc/python/axes.md b/doc/python/axes.md index 6ab2d89681d..edcf13ac71c 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -380,6 +380,39 @@ fig.update_layout(title_text="Apple Stock Price") fig.show() ``` +#### Adding minor ticks +You can add minor ticks to an axis by specifying with `minor`. This takes a `dict` of properties for the minor ticks. + +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside `minor = {'ticks':'outside'}`. On the xaxis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the xaxis minor ticks using `showgrid`. + + +```python +import plotly.express as px +import pandas as pd + +df = px.data.tips() +fig = px.scatter(df, x="total_bill", y="tip", color="sex") + + +fig.update_layout( + xaxis = dict( + minor = { + "ticklen": 6, + "tickcolor": "black", + "showgrid" : True + }, + ) +) + +fig.update_layout( + yaxis = dict( + minor = {'ticks':'outside'} + ) +) + +fig.show() +``` + ### Axis lines: grid and zerolines ##### Toggling Axis grid lines @@ -464,6 +497,19 @@ fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='LightPink') fig.show() ``` +By default grid lines are `solid`. Set the `griddash` property to change them. In this example we display the x-axis grid lines as `dot`. It can also be set to `dash`, `longdash`, `dashdot`, or `longdashdot`. + +```python +import plotly.express as px +df = px.data.iris() + +fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species") +fig.update_xaxes(showgrid=True, gridwidth=1, gridcolor='LightPink', griddash='dot') +fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='LightPink') + +fig.show() +``` + ##### Styling zero lines The width and color of axis zero lines are controlled by the `zerolinewidth` and `zerolinecolor` axis properties. From adc59022135adc2b53f781b142667ee6640ce87d Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 27 Apr 2022 14:01:33 -0400 Subject: [PATCH 02/21] Minor edit --- doc/python/axes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index edcf13ac71c..53f18bf2178 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -381,9 +381,9 @@ fig.show() ``` #### Adding minor ticks -You can add minor ticks to an axis by specifying with `minor`. This takes a `dict` of properties for the minor ticks. +You can add minor ticks to an axis by specifying with the `minor` property. This takes a `dict` of properties to apply to minor ticks. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside `minor = {'ticks':'outside'}`. On the xaxis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the xaxis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {'ticks':'outside'}`. On the xaxis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. ```python From 50367ce7e5df2dbba5e445fda850a11d2856cae3 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 27 Apr 2022 14:09:41 -0400 Subject: [PATCH 03/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 53f18bf2178..625836bcce6 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -383,7 +383,7 @@ fig.show() #### Adding minor ticks You can add minor ticks to an axis by specifying with the `minor` property. This takes a `dict` of properties to apply to minor ticks. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {'ticks':'outside'}`. On the xaxis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {'ticks':'outside'}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. ```python From 08dfbf03ce380a9940a0434d9f591b40cf698519 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 27 Apr 2022 14:11:27 -0400 Subject: [PATCH 04/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 625836bcce6..1d4cfc51b51 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -497,7 +497,7 @@ fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='LightPink') fig.show() ``` -By default grid lines are `solid`. Set the `griddash` property to change them. In this example we display the x-axis grid lines as `dot`. It can also be set to `dash`, `longdash`, `dashdot`, or `longdashdot`. +By default grid lines are `solid`. Set the `griddash` property to change this style. In this example we display the x-axis grid lines as `dot`. It can also be set to `dash`, `longdash`, `dashdot`, or `longdashdot`. ```python import plotly.express as px From b077b877999c2413ecaa1feedc9f8111e93e0bfa Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 27 Apr 2022 14:17:51 -0400 Subject: [PATCH 05/21] Update axes.md --- doc/python/axes.md | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 1d4cfc51b51..2aceec3cb67 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -383,7 +383,7 @@ fig.show() #### Adding minor ticks You can add minor ticks to an axis by specifying with the `minor` property. This takes a `dict` of properties to apply to minor ticks. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {'ticks':'outside'}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. ```python @@ -394,21 +394,8 @@ df = px.data.tips() fig = px.scatter(df, x="total_bill", y="tip", color="sex") -fig.update_layout( - xaxis = dict( - minor = { - "ticklen": 6, - "tickcolor": "black", - "showgrid" : True - }, - ) -) - -fig.update_layout( - yaxis = dict( - minor = {'ticks':'outside'} - ) -) +fig.update_xaxes(minor = {"ticklen": 6, "tickcolor": "black", "showgrid" : True}) +fig.update_yaxes(minor = {"ticks":"outside"}) fig.show() ``` From 5c3e9fb236a6ff6cfb6e98ff42669d92d639ebad Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 2 May 2022 10:47:47 -0400 Subject: [PATCH 06/21] Update time-series.md --- doc/python/time-series.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/python/time-series.md b/doc/python/time-series.md index a3cc8f03f91..7a0be4c0318 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.3' + jupytext_version: 1.13.7 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.7 + version: 3.9.0 plotly: description: How to plot date and time in python. display_as: financial @@ -135,6 +135,26 @@ fig.update_xaxes( fig.show() ``` +### Adding Minor Ticks + +_new in 5.8_ + +You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. + +In this example, we've added minor ticks to the inside of the x-axis and turned on gridlines. + +```python +import pandas as pd +import plotly.express as px + +df = px.data.stocks() +fig = px.line(df, x='date', y="GOOG") + +fig.update_xaxes(minor = {"ticks": "inside", "showgrid" : True}) + +fig.show() +``` + ### Summarizing Time-series Data with Histograms Plotly [histograms](/python/histograms/) are powerful data-aggregation tools which even work on date axes. In the figure below, we pass in daily data and display it as monthly averages by setting `histfunc="avg` and `xbins_size="M1"`. From 847468c76d5695944c53679a258a5125fcc1c8b7 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 2 May 2022 10:49:35 -0400 Subject: [PATCH 07/21] Update time-series.md --- doc/python/time-series.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/time-series.md b/doc/python/time-series.md index 7a0be4c0318..b2571d7ef7f 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -141,7 +141,7 @@ _new in 5.8_ You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. -In this example, we've added minor ticks to the inside of the x-axis and turned on gridlines. +In this example, we've added minor ticks to the inside of the x-axis and turned on grid lines. ```python import pandas as pd From cb24bbbbc7c155b34314e0103bc91b9c30db1c37 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 2 May 2022 11:09:53 -0400 Subject: [PATCH 08/21] Update axes.md --- doc/python/axes.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 2aceec3cb67..5d5af3462b4 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -381,10 +381,14 @@ fig.show() ``` #### Adding minor ticks -You can add minor ticks to an axis by specifying with the `minor` property. This takes a `dict` of properties to apply to minor ticks. + +_new in 5.8_ + +You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +Note: Minor ticks and grid lines are not supported on multi-categorical, log, or 3D axes, or on color bars, ternary plots, polar charts, or geo. ```python import plotly.express as px @@ -395,7 +399,7 @@ fig = px.scatter(df, x="total_bill", y="tip", color="sex") fig.update_xaxes(minor = {"ticklen": 6, "tickcolor": "black", "showgrid" : True}) -fig.update_yaxes(minor = {"ticks":"outside"}) +fig.update_yaxes(minor = {"ticks": "outside"}) fig.show() ``` @@ -484,6 +488,8 @@ fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='LightPink') fig.show() ``` +_new in 5.8_ + By default grid lines are `solid`. Set the `griddash` property to change this style. In this example we display the x-axis grid lines as `dot`. It can also be set to `dash`, `longdash`, `dashdot`, or `longdashdot`. ```python From 6e02e5213d755fb729922bb23895a903aa55396e Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 2 May 2022 11:13:11 -0400 Subject: [PATCH 09/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 5d5af3462b4..638e0c837de 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -388,7 +388,7 @@ You can add minor ticks to an axis with `minor`. This takes a `dict` of properti In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. -Note: Minor ticks and grid lines are not supported on multi-categorical, log, or 3D axes, or on color bars, ternary plots, polar charts, or geo. +Note: Minor ticks and grid lines are not supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, log, or 3D axes. ```python import plotly.express as px From 32e5b53a5f40e10981116764bcbaa0b910a32506 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 09:53:38 -0400 Subject: [PATCH 10/21] add log plot example --- doc/python/log-plot.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/python/log-plot.md b/doc/python/log-plot.md index 7cd2d64932e..879c955f1da 100644 --- a/doc/python/log-plot.md +++ b/doc/python/log-plot.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.3' + jupytext_version: 1.13.7 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.7 + version: 3.9.0 plotly: description: How to make Log plots in Python with Plotly. display_as: scientific @@ -60,6 +60,24 @@ fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country", fig.show() ``` +#### Adding minor ticks + +_new in 5.8_ + +You can position and style minor ticks using `minor`. This takes a `dict` of properties to apply to minor ticks. In this example we set the tick length with `ticklen`, add the ticks on the inside with `"ticks": "inside"`, and turn grid lines on with `showgrid: True`. + +```python +import plotly.express as px +df = px.data.gapminder().query("year == 2007") + +fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country", + log_x=True, range_x=[1,100000], range_y=[0,100]) + +fig.update_xaxes(minor = {"ticks": "inside", "ticklen": 6, "showgrid": True}) + +fig.show() +``` + ### Logarithmic Axes with Graph Objects If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Figure` class from `plotly.graph_objects`](/python/graph-objects/). From b0a051fabee1d85531e2bf98ef12180600755af1 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 09:55:16 -0400 Subject: [PATCH 11/21] Update axes.md --- doc/python/axes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 638e0c837de..41d5fab3e76 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -384,11 +384,11 @@ fig.show() _new in 5.8_ -You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. +You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. -Note: Minor ticks and grid lines are not supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, log, or 3D axes. +Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, log, or 3D axes. ```python import plotly.express as px From f1f234815bc6ca97695969867575d5e5bea39c7c Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 09:56:29 -0400 Subject: [PATCH 12/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 41d5fab3e76..5f45221582b 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -384,7 +384,7 @@ fig.show() _new in 5.8_ -You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. +You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. From dde19124770e6ea5b6decb14183285440473bc35 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 09:58:43 -0400 Subject: [PATCH 13/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 5f45221582b..b01a00635a6 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -398,7 +398,7 @@ df = px.data.tips() fig = px.scatter(df, x="total_bill", y="tip", color="sex") -fig.update_xaxes(minor = {"ticklen": 6, "tickcolor": "black", "showgrid" : True}) +fig.update_xaxes(minor = {"ticklen": 6, "tickcolor": "black", "showgrid": True}) fig.update_yaxes(minor = {"ticks": "outside"}) fig.show() From 028c77915a79236dc11ef52d7c24aa5624d69f3e Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 10:01:08 -0400 Subject: [PATCH 14/21] Update log-plot.md --- doc/python/log-plot.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/python/log-plot.md b/doc/python/log-plot.md index 879c955f1da..00de8511123 100644 --- a/doc/python/log-plot.md +++ b/doc/python/log-plot.md @@ -64,7 +64,9 @@ fig.show() _new in 5.8_ -You can position and style minor ticks using `minor`. This takes a `dict` of properties to apply to minor ticks. In this example we set the tick length with `ticklen`, add the ticks on the inside with `"ticks": "inside"`, and turn grid lines on with `showgrid: True`. +You can position and style minor ticks using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. + +In this example we set the tick length with `ticklen`, add the ticks on the inside with `"ticks": "inside"`, and turn grid lines on with `showgrid: True`. ```python import plotly.express as px From dc12a25a236474007c566da43b94d9d69c3991e3 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 10:01:59 -0400 Subject: [PATCH 15/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index b01a00635a6..0948e5fdce2 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -388,7 +388,7 @@ You can position and style minor ticks on a Cartesian axis using `minor`. This t In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. -Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, log, or 3D axes. +Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, or 3D axes. ```python import plotly.express as px From ad71fab9a32fc5b8d30b56f5d4a01194377a3625 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 10:03:50 -0400 Subject: [PATCH 16/21] Update axes.md --- doc/python/axes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 0948e5fdce2..01f5581b194 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -386,7 +386,7 @@ _new in 5.8_ You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've spcified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've specified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, or 3D axes. From 0c236ba7aed03e338bef34fbc51a49e76cab4901 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 10:05:08 -0400 Subject: [PATCH 17/21] Update time-series.md --- doc/python/time-series.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/time-series.md b/doc/python/time-series.md index b2571d7ef7f..518981b47aa 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -139,7 +139,7 @@ fig.show() _new in 5.8_ -You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. +You can add minor ticks to an axis with `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. In this example, we've added minor ticks to the inside of the x-axis and turned on grid lines. From 0c419c768c9d99b062dcab2a24a2818c48fc8cdb Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 10:05:26 -0400 Subject: [PATCH 18/21] Update time-series.md --- doc/python/time-series.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/time-series.md b/doc/python/time-series.md index 518981b47aa..3321107a5aa 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -150,7 +150,7 @@ import plotly.express as px df = px.data.stocks() fig = px.line(df, x='date', y="GOOG") -fig.update_xaxes(minor = {"ticks": "inside", "showgrid" : True}) +fig.update_xaxes(minor = {"ticks": "inside", "showgrid": True}) fig.show() ``` From 94197f92218accda0b0e0dbfd29f9e504d47e7e4 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 3 May 2022 11:41:36 -0400 Subject: [PATCH 19/21] update to dict( convention --- doc/python/axes.md | 6 +++--- doc/python/log-plot.md | 4 ++-- doc/python/time-series.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 01f5581b194..42b40760d45 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -386,7 +386,7 @@ _new in 5.8_ You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `minor = {"ticks":"outside"}`. On the x-axis we've specified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `ticks="outside"`. On the x-axis we've specified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, or 3D axes. @@ -398,8 +398,8 @@ df = px.data.tips() fig = px.scatter(df, x="total_bill", y="tip", color="sex") -fig.update_xaxes(minor = {"ticklen": 6, "tickcolor": "black", "showgrid": True}) -fig.update_yaxes(minor = {"ticks": "outside"}) +fig.update_xaxes(minor=dict(ticklen=6, tickcolor="black", showgrid=True)) +fig.update_yaxes(minor=dict(ticks="outside")) fig.show() ``` diff --git a/doc/python/log-plot.md b/doc/python/log-plot.md index 00de8511123..83f993d4220 100644 --- a/doc/python/log-plot.md +++ b/doc/python/log-plot.md @@ -66,7 +66,7 @@ _new in 5.8_ You can position and style minor ticks using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. -In this example we set the tick length with `ticklen`, add the ticks on the inside with `"ticks": "inside"`, and turn grid lines on with `showgrid: True`. +In this example we set the tick length with `ticklen`, add the ticks on the inside with `ticks="inside"`, and turn grid lines on with `howgrid=True`. ```python import plotly.express as px @@ -75,7 +75,7 @@ df = px.data.gapminder().query("year == 2007") fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country", log_x=True, range_x=[1,100000], range_y=[0,100]) -fig.update_xaxes(minor = {"ticks": "inside", "ticklen": 6, "showgrid": True}) +fig.update_xaxes(minor=dict(ticks="inside", ticklen=6, showgrid=True))# {"ticks": "inside", "ticklen": 6, "showgrid": True}) fig.show() ``` diff --git a/doc/python/time-series.md b/doc/python/time-series.md index 3321107a5aa..1b53fef61aa 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -150,7 +150,7 @@ import plotly.express as px df = px.data.stocks() fig = px.line(df, x='date', y="GOOG") -fig.update_xaxes(minor = {"ticks": "inside", "showgrid": True}) +fig.update_xaxes(minor=dict(ticks="inside", showgrid=True)) fig.show() ``` From 8dcd351483fea3d24c53877406c2d83be1c7c1d5 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 4 May 2022 19:17:17 -0400 Subject: [PATCH 20/21] Update axes.md --- doc/python/axes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python/axes.md b/doc/python/axes.md index 42b40760d45..4f3525cee77 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -386,7 +386,7 @@ _new in 5.8_ You can position and style minor ticks on a Cartesian axis using `minor`. This takes a `dict` of properties to apply to minor ticks. Available properties include: `tickmode`, `tickvals`, `tickcolor`, `ticklen`, `tickwidth`, `dtick`, `tick0`, `nticks`, `ticks`, `showgrid`, `gridcolor`, `griddash`, and `gridwidth`. -In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the outside: `ticks="outside"`. On the x-axis we've specified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. +In the following example, we add minor ticks to the x-axis and then to the y-axis. For the y-axis we add ticks on the inside: `ticks="inside"`. On the x-axis we've specified some additional properties to style the minor ticks, setting the length of the ticks with `ticklen` and the color with `tickcolor`. We've also turned on grid lines for the x-axis minor ticks using `showgrid`. Note: Minor ticks and grid lines are not currently supported on color bars, ternary plots, polar charts, geo plots, or on multi-categorical, or 3D axes. @@ -399,7 +399,7 @@ fig = px.scatter(df, x="total_bill", y="tip", color="sex") fig.update_xaxes(minor=dict(ticklen=6, tickcolor="black", showgrid=True)) -fig.update_yaxes(minor=dict(ticks="outside")) +fig.update_yaxes(minor=dict(ticks="inside")) fig.show() ``` From f10e818da95447bd4c143f6dc478bb981fb93925 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 9 May 2022 12:10:48 -0400 Subject: [PATCH 21/21] Update time-series.md --- doc/python/time-series.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/python/time-series.md b/doc/python/time-series.md index 1b53fef61aa..df9e2b33bd2 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -155,6 +155,25 @@ fig.update_xaxes(minor=dict(ticks="inside", showgrid=True)) fig.show() ``` +#### Monthly Period Labels With Weekly Minor Ticks + +_new in 5.8_ + +You can set `dtick` on `minor` to control the spacing for minor ticks and grid lines. In the following example, by setting `dtick=7*24*3.6e6` (the number of milliseconds in a week) and setting `tick0="2016-07-04"` (the first Monday in our data), a minor tick and grid line is displayed for the start of each week. When zoomed out, we can see where each month and week begins and ends. + +```python +import pandas as pd +import plotly.express as px + +df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') +df = df.loc[(df["Date"] >= "2016-07-01") & (df["Date"] <= "2016-12-01")] + +fig = px.line(df, x='Date', y='AAPL.High') +fig.update_xaxes(ticks= "outside", ticklabelmode= "period", tickcolor= "black", tickwidth=2, ticklen=10, minor=dict(ticks="outside", dtick=7*24*3.6e6, tick0="2016-07-04", griddash='dot', gridcolor='pink')) + +fig.show() +``` + ### Summarizing Time-series Data with Histograms Plotly [histograms](/python/histograms/) are powerful data-aggregation tools which even work on date axes. In the figure below, we pass in daily data and display it as monthly averages by setting `histfunc="avg` and `xbins_size="M1"`.