diff --git a/python/3d-bubble-charts.md b/python/3d-bubble-charts.md index 466f4725e..627b67a51 100644 --- a/python/3d-bubble-charts.md +++ b/python/3d-bubble-charts.md @@ -37,7 +37,7 @@ jupyter: title: Python 3D Bubble Charts | plotly --- -### 3d Bubble chart with plotly express +### 3d Bubble chart with Plotly Express ```python import plotly.express as px diff --git a/python/3d-line-plots.md b/python/3d-line-plots.md index 252968f37..fd183cf00 100644 --- a/python/3d-line-plots.md +++ b/python/3d-line-plots.md @@ -36,7 +36,7 @@ jupyter: title: 3D Line Plots in Python | plotly --- -### 3D Line plot with plotly express +### 3D Line plot with Plotly Express ```python import plotly.express as px diff --git a/python/3d-scatter-plots.md b/python/3d-scatter-plots.md index 4d4f04967..cab06d7bf 100644 --- a/python/3d-scatter-plots.md +++ b/python/3d-scatter-plots.md @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.6.8 plotly: description: How to make 3D scatter plots in Python with Plotly. display_as: 3d_charts @@ -37,9 +37,11 @@ jupyter: v4upgrade: true --- -## 3D scatter plot with plotly express +## 3D scatter plot with Plotly Express -Like the [2D scatter plot](https://plot.ly/python/line-and-scatter/) `px.scatter`, the 3D function `px.scatter_3d` plots individual data in three-dimensional space. +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). + +Like the [2D scatter plot](https://plot.ly/python/line-and-scatter/) `px.scatter`, the 3D function `px.scatter_3d` plots individual data in three-dimensional space. ```python import plotly.express as px @@ -78,7 +80,7 @@ fig.update_layout(margin=dict(l=0, r=0, b=0, t=0)) #### Basic 3D Scatter Plot -When data are not available as tidy dataframes, it is also possible to use the more generic `go.Scatter3D` from `plotly.graph_objs`. +If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Scatter3D` from `plotly.graph_objs`. Like the [2D scatter plot](https://plot.ly/python/line-and-scatter/) `go.Scatter`, `go.Scatter3d` plots individual data in three-dimensional space. ```python diff --git a/python/animations.md b/python/animations.md index aef9daa1b..186d08481 100644 --- a/python/animations.md +++ b/python/animations.md @@ -27,10 +27,10 @@ jupyter: v4upgrade: true --- -#### Animated figures with plotly express -Several plotly express functions support the creation of animated figures through the `animation_frame` and `animation_group` arguments. +#### Animated figures with Plotly Express +Several Plotly Express functions support the creation of animated figures through the `animation_frame` and `animation_group` arguments. -Here is an example of an animated scatter plot creating using plotly express +Here is an example of an animated scatter plot creating using Plotly Express ```python import plotly.express as px diff --git a/python/axes.md b/python/axes.md index a09a523d4..a5e383355 100644 --- a/python/axes.md +++ b/python/axes.md @@ -94,12 +94,12 @@ fig.update_yaxes(showgrid=False, zeroline=False) fig.show() ``` -##### Toggle grid and zerolines for figure created with plotly express +##### Toggle grid and zerolines for figure created with Plotly Express -An advantage of using the `update_xaxis` and `update_yaxis` methods is that these updates will (by default) apply to all axes in the figure. This is especially useful when customizing figures created using plotly express, figure factories, or `make_subplots`. +An advantage of using the `update_xaxis` and `update_yaxis` methods is that these updates will (by default) apply to all axes in the figure. This is especially useful when customizing figures created using Plotly Express, figure factories, or `make_subplots`. -Here is an example of disabling all grid and zero lines in a faceted figure created by plotly express. +Here is an example of disabling all grid and zero lines in a faceted figure created by Plotly Express. ```python import plotly.express as px @@ -115,7 +115,7 @@ fig.show() ##### Toggling axis tick marks Axis tick marks are disabled by default for the default `plotly` theme, but they can easily be turned on by setting the `ticks` axis property to `"inside"` (to place ticks inside plotting area) or `"outside"` (to place ticks outside the plotting area). -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. +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 @@ -131,7 +131,7 @@ fig.show() ##### Toggling axis labels The axis tick mark labels can be disabled by setting the `showticklabels` axis property to `False`. -Here is an example of disabling tick labels in all subplots for a faceted figure created using plotly express. +Here is an example of disabling tick labels in all subplots for a faceted figure created using Plotly Express. ```python import plotly.express as px @@ -149,7 +149,7 @@ fig.show() ##### Set number of tick marks The approximate number of ticks displayed for an axis can be specified using the `nticks` axis property. -Here is an example of updating the y-axes of a figure created using plotly express to display approximately 20 ticks. +Here is an example of updating the y-axes of a figure created using Plotly Express to display approximately 20 ticks. ```python import plotly.express as px @@ -164,7 +164,7 @@ fig.show() ##### Set start position and distance between ticks The `tick0` and `dtick` axis properties can be used to control to placement of axis ticks as follows: If specified, a tick will fall exactly on the location of `tick0` and additional ticks will be added in both directions at intervals of `dtick`. -Here is an example of updating the y axis of a figure created using plotly express to position the ticks at intervals of 0.5, starting at 0.25. +Here is an example of updating the y axis of a figure created using Plotly Express to position the ticks at intervals of 0.5, starting at 0.25. ```python import plotly.express as px @@ -179,7 +179,7 @@ fig.show() ##### Set exact location of axis ticks It is possible to configure an axis to display ticks at a set of predefined locations by setting the `tickvals` property to an array of positions. -Here is an example of setting the exact location of ticks on the y axes of a figure created using plotly express. +Here is an example of setting the exact location of ticks on the y axes of a figure created using Plotly Express. ```python import plotly.express as px @@ -196,7 +196,7 @@ As discussed above, tick marks are disabled by default in the default `plotly` t The appearance of these tick marks can be customized by setting their length (`ticklen`), width (`tickwidth`), and color (`tickcolor`). -Here is an example of enabling and styling the tick marks of a faceted figure created using plotly express. Note how the `col` argument to `update_yaxes` is used to only turn on and style the y-axis ticks for the left-most subplot. +Here is an example of enabling and styling the tick marks of a faceted figure created using Plotly Express. Note how the `col` argument to `update_yaxes` is used to only turn on and style the y-axis ticks for the left-most subplot. ```python import plotly.express as px @@ -227,7 +227,7 @@ fig.show() ``` ##### Set axis title font -Here is an example that configures the font family, size, and color for the axis titles in a figure created using plotly express. +Here is an example that configures the font family, size, and color for the axis titles in a figure created using Plotly Express. ```python import plotly.express as px @@ -243,7 +243,7 @@ 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. -Here is an example of rotating the x-axis tick labels by 45 degrees, and customizing their font properties, in a faceted histogram figure created using plotly express. +Here is an example of rotating the x-axis tick labels by 45 degrees, and customizing their font properties, in a faceted histogram figure created using Plotly Express. ```python import plotly.express as px @@ -261,7 +261,7 @@ fig.show() ##### Styling axis lines The `showline` axis property controls the visibility of the axis line, and the `linecolor` and `linewidth` axis properties control the color and width of the axis line. -Here is an example of enabling the x and y axis lines, and customizing their width and color, for a faceted histogram created with plotly express. +Here is an example of enabling the x and y axis lines, and customizing their width and color, for a faceted histogram created with Plotly Express. ```python import plotly.express as px @@ -277,7 +277,7 @@ fig.show() ##### Mirroring axis lines Axis lines can be mirrored to the opposite side of the plotting area by setting the `mirror` axis property to `True`. -Here is an example of mirroring the x and y axis lines in a faceted histogram created using plotly express. +Here is an example of mirroring the x and y axis lines in a faceted histogram created using Plotly Express. ```python import plotly.express as px @@ -293,7 +293,7 @@ fig.show() ##### Styling grid lines The width and color of axis grid lines are controlled by the `gridwidth` and `gridcolor` axis properties. -Here is an example of customizing the grid line width and color for a faceted scatter plot created with plotly express +Here is an example of customizing the grid line width and color for a faceted scatter plot created with Plotly Express ```python import plotly.express as px @@ -327,7 +327,7 @@ fig.show() #### Setting the Range of Axes Manually The visible x and y axis range can be configured manually by setting the `range` axis property to a list of two values, the lower and upper boundary. -Here's an example of manually specifying the x and y axis range for a faceted scatter plot created with plotly express. +Here's an example of manually specifying the x and y axis range for a faceted scatter plot created with Plotly Express. ```python import plotly.express as px @@ -444,7 +444,7 @@ fig.show() #### Reversed Axes You can tell plotly's automatic axis range calculation logic to reverse the direction of an axis by setting the `autorange` axis property to `"reversed"`. -Here is an example of reversing the direction of the y axes for a faceted scatter plot created using plotly express. +Here is an example of reversing the direction of the y axes for a faceted scatter plot created using Plotly Express. ```python import plotly.express as px @@ -459,7 +459,7 @@ fig.show() #### Reversed Axes with Range ( Min/Max ) Specified The direction of an axis can be reversed when manually setting the range extents by specifying a list containing the upper bound followed by the lower bound (rather that the lower followed by the upper) as the `range` axis property. -Here is an example of manually setting the reversed range of the y axes in a faceted scatter plot figure created using plotly express. +Here is an example of manually setting the reversed range of the y axes in a faceted scatter plot figure created using Plotly Express. ```python import plotly.express as px @@ -477,7 +477,7 @@ The axis auto-range calculation logic can be configured using the `rangemode` ax If `rangemode` is `"normal"` (the default), the range is computed based on the min and max values of the input data. If `"tozero"`, the the range will always include zero. If `"nonnegative"`, the range will not extend below zero, regardless of the input data. -Here is an example of configuring a faceted scatter plot created using plotly express to always include zero for both the x and y axes. +Here is an example of configuring a faceted scatter plot created using Plotly Express to always include zero for both the x and y axes. ```python import plotly.express as px diff --git a/python/bar-charts.md b/python/bar-charts.md index 7a32f1c02..a1eebd6e4 100644 --- a/python/bar-charts.md +++ b/python/bar-charts.md @@ -6,7 +6,7 @@ jupyter: extension: .md format_name: markdown format_version: '1.1' - jupytext_version: 1.2.1 + jupytext_version: 1.1.1 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.3 + version: 3.6.8 plotly: description: How to make Bar Charts in Python with Plotly. display_as: basic @@ -37,10 +37,12 @@ jupyter: v4upgrade: true --- -### Bar chart with plotly express +### Bar chart with Plotly Express -In a bar plot, each row of the DataFrame is represented as a rectangular mark. +[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.bar`, each row of the DataFrame is represented as a rectangular mark. ```python import plotly.express as px @@ -53,7 +55,7 @@ fig.show() data_canada ``` -### Customize bar chart with plotly express +### Customize bar chart with Plotly Express The bar plot can be customized using keyword arguments. @@ -103,7 +105,7 @@ To learn more, see the *link to px.bar reference page*. #### Basic Bar Chart with plotly.graph_objects -When data are not available as tidy dataframes, it is also possible to use the more generic `go.Bar` function from `plotly.graph_objects`. +If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Bar` function from `plotly.graph_objects`. ```python import plotly.graph_objects as go @@ -327,7 +329,7 @@ fig.show() ### Bar Chart with Sorted or Ordered Categories -Set `categoryorder` to "category ascending/descending" for the alphanumerical order of the category names or "total ascending/descending" for numerical order of values. [categoryorder](https://plot.ly/python/reference/#layout-xaxis-categoryorder) for more information. +Set `categoryorder` to "category ascending/descending" for the alphanumerical order of the category names or "total ascending/descending" for numerical order of values. [categoryorder](https://plot.ly/python/reference/#layout-xaxis-categoryorder) for more information. ```python import plotly.graph_objects as go diff --git a/python/box-plots.md b/python/box-plots.md index 51d853d3f..e3fa51ee8 100644 --- a/python/box-plots.md +++ b/python/box-plots.md @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.6.8 plotly: description: How to make Box Plots in Python with Plotly. display_as: statistical @@ -40,7 +40,9 @@ jupyter: A [box plot](https://en.wikipedia.org/wiki/Box_plot) is a statistical representation of numerical data through their quartiles. The ends of the box represent the lower and upper quartiles, while the median (second quartile) is marked by a line inside the box. For other statistical representations of numerical data, see [other statistical charts](https://plot.ly/python/statistical-charts/). -## Box Plot with plotly express +## Box Plot 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/). In a box plot created by `px.box`, the distribution of the column given as `y` argument is represented. @@ -89,7 +91,7 @@ fig.show() ## Box plot with go.Box -When data are not available as tidy dataframes, it is also possible to use the more generic `go.Box` function from `plotly.graph_objects`. All available options for `go.Box` are described in the reference page https://plot.ly/python/reference/#box. +If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Box` function from `plotly.graph_objects`. All available options for `go.Box` are described in the reference page https://plot.ly/python/reference/#box. ### Basic Box Plot ### diff --git a/python/bubble-charts.md b/python/bubble-charts.md index a464f801b..42e84abd0 100644 --- a/python/bubble-charts.md +++ b/python/bubble-charts.md @@ -42,7 +42,7 @@ jupyter: A [bubble chart](https://en.wikipedia.org/wiki/Bubble_chart) is a scatter plot in which a third dimension of the data is shown through the size of markers. For other types of scatter plot, see the [line and scatter page](https://plot.ly/python/line-and-scatter/). -We first show a bubble chart example using plotly express. [Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). The size of markers is set from the dataframe column given as the `size` parameter. +We first show a bubble chart example using 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/). The size of markers is set from the dataframe column given as the `size` parameter. ```python import plotly.express as px @@ -56,7 +56,7 @@ fig.show() ## Bubble Chart with plotly.graph_objects -When data are not available as tidy dataframes, it is also possible to use the more generic `go.Scatter` from `plotly.graph_objects`, and define the size of markers to create a bubble chart. All of the available options are described in the scatter section of the reference page: https://plot.ly/python/reference#scatter. +If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Scatter` from `plotly.graph_objects`, and define the size of markers to create a bubble chart. All of the available options are described in the scatter section of the reference page: https://plot.ly/python/reference#scatter. ### Simple Bubble Chart diff --git a/python/bubble-maps.md b/python/bubble-maps.md index 31666fb95..ee8c5b2ef 100644 --- a/python/bubble-maps.md +++ b/python/bubble-maps.md @@ -36,9 +36,9 @@ jupyter: v4upgrade: true --- -### Bubble map with plotly express +### Bubble map with Plotly Express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). 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. +[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. ```python import plotly.express as px diff --git a/python/choropleth-maps.md b/python/choropleth-maps.md index 9a1fe5e72..640ae63fb 100644 --- a/python/choropleth-maps.md +++ b/python/choropleth-maps.md @@ -29,10 +29,12 @@ jupyter: A [Choropleth Map](https://en.wikipedia.org/wiki/Choropleth_map) is a heatmap using geographical boundaries. It is used to represent spatial variations of a quantity. See also the [index of other geographical charts](../maps/). -Below we show how to create Choropleth Maps using either `px.choropleth` (one-liner function call for data as tidy pandas DataFrame) or for the more generic case `go.Choropleth`. +Below we show how to create Choropleth Maps using either Plotly Express' `px.choropleth` or the lower-level `go.Choropleth`. ### Choropleth 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/). + ```python import plotly.express as px diff --git a/python/colorscales.md b/python/colorscales.md index 3d83596d8..9ad77426c 100644 --- a/python/colorscales.md +++ b/python/colorscales.md @@ -37,10 +37,10 @@ jupyter: v4upgrade: true --- -### Predefined colorscales in plotly express +### Predefined colorscales in Plotly Express A collection of predefined sequential colorscales is provided in the `plotly.express.colors.sequential` module. -Here is an example that creates a scatter plot using plotly express, with points colored using the Viridis colorscale. +Here is an example that creates a scatter plot using Plotly Express, with points colored using the Viridis colorscale. ```python import plotly.express as px diff --git a/python/creating-and-updating-figures.md b/python/creating-and-updating-figures.md index 43a23bc92..639d45641 100644 --- a/python/creating-and-updating-figures.md +++ b/python/creating-and-updating-figures.md @@ -30,7 +30,7 @@ jupyter: name: Creating and Updating Figures page_type: example_index permalink: python/creating-and-updating-figures/ - redirect_from: + redirect_from: - python/user-guide/ - python/user-g/ thumbnail: thumbnail/creating-and-updating-figures.png @@ -171,7 +171,7 @@ fig.add_trace(go.Bar(x=[1, 2, 3], y=[1, 3, 2])) fig.show() ``` -You can also add traces to a figure produced by a figure factory or plotly express. +You can also add traces to a figure produced by a figure factory or Plotly Express. ```python import plotly.express as px @@ -199,7 +199,7 @@ fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=2) fig.show() ``` -This also works for figures created by plotly express using the `facet_row` and or `facet_col` arguments. +This also works for figures created by Plotly Express using the `facet_row` and or `facet_col` arguments. ```python import plotly.express as px @@ -426,7 +426,7 @@ fig.update_traces(marker=dict(color="RoyalBlue"), fig.show() ``` -The `update_traces` method can also be used on figures produced by figure factories or plotly express. Here's an example of updating the regression lines produced by plotly express to be dotted. +The `update_traces` method can also be used on figures produced by figure factories or Plotly Express. Here's an example of updating the regression lines produced by Plotly Express to be dotted. ```python import pandas as pd @@ -444,7 +444,7 @@ Suppose the updates that you want to make to a collection of traces depend on th As its first argument, the `for_each_trace` method accepts a function that accepts and updates one trace at a time. Like `update_traces`, `for_each_trace` also accepts `selector`, `row`, and `col` arguments to control which traces should be considered. -Here is an example of using `for_each_trace` to replace the equal-sign with a colon in the legend name of each trace in a figure produced by plotly express. +Here is an example of using `for_each_trace` to replace the equal-sign with a colon in the legend name of each trace in a figure produced by Plotly Express. ```python import pandas as pd @@ -460,7 +460,7 @@ fig.show() ``` #### The update axis methods -Graph object figures support `update_xaxes` and `update_yaxes` methods that may be used to update multiple nested properties of one or more of a figure's axes. Here is an example of using `update_xaxes` to disable the vertical grid lines across all subplots in a figure produced by plotly express. +Graph object figures support `update_xaxes` and `update_yaxes` methods that may be used to update multiple nested properties of one or more of a figure's axes. Here is an example of using `update_xaxes` to disable the vertical grid lines across all subplots in a figure produced by Plotly Express. ```python import pandas as pd @@ -477,7 +477,7 @@ There are also `for_each_xaxis` and `for_each_yaxis` methods that are analogous #### Chaining figure operations All of the figure update operations described above are methods that return a reference to the figure being modified. This makes it possible the chain multiple figure modification operations together into a single expression. -Here is an example of a chained expression that creates a faceted scatter plot with OLS trend lines using plotly express, sets the title font size using `update_layout`, disables vertical grid lines using `update_xaxes`, updates the width and dash pattern of the trend lines using `update_traces`, and then displays the figure using `show`. +Here is an example of a chained expression that creates a faceted scatter plot with OLS trend lines using Plotly Express, sets the title font size using `update_layout`, disables vertical grid lines using `update_xaxes`, updates the width and dash pattern of the trend lines using `update_traces`, and then displays the figure using `show`. ```python import plotly.express as px diff --git a/python/distplot.md b/python/distplot.md index e261b8d97..74b7f18c1 100644 --- a/python/distplot.md +++ b/python/distplot.md @@ -40,7 +40,7 @@ jupyter: Several representations of statistical distributions are available in plotly, such as [histograms](https://plot.ly/python/histograms/), [violin plots](https://plot.ly/python/violin/), [box plots](https://plot.ly/python/box-plots/) (see [the complete list here](https://plot.ly/python/statistical-charts/)). It is also possible to combine several representations in the same plot. -For example, the `plotly.express` function `px.histogram` can add a subplot with a different statistical representation than the histogram, given by the parameter `marginal`. [Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). +For example, the `plotly.express` function `px.histogram` can add a subplot with a different statistical representation than the histogram, given by the parameter `marginal`. [Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px diff --git a/python/dot-plots.md b/python/dot-plots.md index 16dcefed6..5b2b94448 100644 --- a/python/dot-plots.md +++ b/python/dot-plots.md @@ -39,10 +39,12 @@ jupyter: #### Basic Dot Plot -Dot plots (also known as [Cleveland dot plots](https://en.wikipedia.org/wiki/Dot_plot_(statistics))) show changes between two (or more) points in time or between two (or more) conditions. Compared to a [bar chart](../bar-charts/), dot plots can be less cluttered and allow for an easier comparison between conditions. +Dot plots (also known as [Cleveland dot plots](https://en.wikipedia.org/wiki/Dot_plot_(statistics))) show changes between two (or more) points in time or between two (or more) conditions. Compared to a [bar chart](../bar-charts/), dot plots can be less cluttered and allow for an easier comparison between conditions. For the same data, we show below how to create a dot plot using either `px.scatter` (for a tidy pandas DataFrame) or `go.Scatter`. +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). + ```python import plotly.express as px import pandas as pd diff --git a/python/error-bars.md b/python/error-bars.md index 99fc35ee0..06ab0a18b 100644 --- a/python/error-bars.md +++ b/python/error-bars.md @@ -37,9 +37,9 @@ jupyter: v4upgrade: true --- -### Error Bars with plotly express +### Error Bars with Plotly Express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). For functions representing 2D data points such as [`px.scatter`](https://plot.ly/python/line-and-scatter/), [`px.line`](https://plot.ly/python/line-charts/), [`px.bar`](https://plot.ly/python/bar-charts/) etc., error bars are given as a column name which is the value of the `error_x` (for the error on x position) and `error_y` (for the error on y position). +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). For functions representing 2D data points such as [`px.scatter`](https://plot.ly/python/line-and-scatter/), [`px.line`](https://plot.ly/python/line-charts/), [`px.bar`](https://plot.ly/python/bar-charts/) etc., error bars are given as a column name which is the value of the `error_x` (for the error on x position) and `error_y` (for the error on y position). ```python import plotly.express as px @@ -50,7 +50,7 @@ fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", fig.show() ``` -#### Asymmetric Error Bars with plotly express +#### Asymmetric Error Bars with Plotly Express ```python import plotly.express as px diff --git a/python/filled-area-plots.md b/python/filled-area-plots.md index 6819eb9e2..d345090d7 100644 --- a/python/filled-area-plots.md +++ b/python/filled-area-plots.md @@ -42,7 +42,7 @@ This example shows how to fill the area enclosed by traces. ## Filled area plot with plotly.express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). `px.area` creates a stacked area plot. Each filled area corresponds to one value of the column given by the `line_group` parameter. diff --git a/python/histograms.md b/python/histograms.md index 8387fa1c1..a3e70fa19 100644 --- a/python/histograms.md +++ b/python/histograms.md @@ -38,11 +38,11 @@ jupyter: v4upgrade: true --- -## Histogram with plotly express +## Histogram with Plotly Express In statistics, a [histogram](https://en.wikipedia.org/wiki/Histogram) is representation of the distribution of numerical data, where the data are binned and the count for each bin is represented. More generally, in plotly a histogram is an aggregated bar chart, with several possible aggregation functions (e.g. sum, average, count...). Also, the data to be binned can be numerical data but also categorical or date data. -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px @@ -130,7 +130,7 @@ fig.show() ## Histograms with go.Histogram -When data are not available as tidy dataframes, it is also possible to use the more generic `go.Histogram` from `plotly.graph_objects`. All of the available histogram options are described in the histogram section of the reference page: https://plot.ly/python/reference#histogram. +If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Histogram` from `plotly.graph_objects`. All of the available histogram options are described in the histogram section of the reference page: https://plot.ly/python/reference#histogram. ### Basic Histogram ### diff --git a/python/horizontal-bar-charts.md b/python/horizontal-bar-charts.md index 55497fdd8..7d062a117 100644 --- a/python/horizontal-bar-charts.md +++ b/python/horizontal-bar-charts.md @@ -40,12 +40,12 @@ jupyter: See more examples of bar charts (including vertical bar charts) and styling options [here](https://plot.ly/python/bar-charts/). -### Horizontal Bar Chart with plotly express +### Horizontal Bar Chart with Plotly Express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). For a horizontal bar char, use the `px.bar` function with `orientation='h'`. +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). For a horizontal bar char, use the `px.bar` function with `orientation='h'`. -#### Basic Horizontal Bar Chart with plotly express +#### Basic Horizontal Bar Chart with Plotly Express ```python diff --git a/python/hover-text-and-formatting.md b/python/hover-text-and-formatting.md index f73fd7d14..4e58b79bb 100644 --- a/python/hover-text-and-formatting.md +++ b/python/hover-text-and-formatting.md @@ -36,10 +36,10 @@ jupyter: v4upgrade: true --- -#### Hover text with plotly express -Many plotly express functions support configurable hover text. The `hover_data` argument accepts a list of column names to be added to the hover tooltip. The `hover_name` property controls which column is displayed in bold as the tooltip title. +#### Hover text with Plotly Express +Many Plotly Express functions support configurable hover text. The `hover_data` argument accepts a list of column names to be added to the hover tooltip. The `hover_name` property controls which column is displayed in bold as the tooltip title. -Here is an example that creates a scatter plot using plotly express with custom hover data and a custom hover name. +Here is an example that creates a scatter plot using Plotly Express with custom hover data and a custom hover name. ```python import plotly.express as px diff --git a/python/line-and-scatter.md b/python/line-and-scatter.md index 2e8160da0..fcf5c9e7e 100644 --- a/python/line-and-scatter.md +++ b/python/line-and-scatter.md @@ -6,7 +6,7 @@ jupyter: extension: .md format_name: markdown format_version: '1.1' - jupytext_version: 1.2.3 + jupytext_version: 1.1.1 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.3 + version: 3.6.8 plotly: description: How to make scatter plots in Python with Plotly. display_as: basic @@ -38,7 +38,9 @@ jupyter: v4upgrade: true --- -## Scatter plot with plotly express +## Scatter plot 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``, each data point is represented as a marker point, which location is given by the `x` and `y` columns. @@ -69,7 +71,7 @@ fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", fig.show() ``` -## Line plot with plotly express +## Line plot with Plotly Express ```python import plotly.express as px @@ -90,7 +92,7 @@ fig.show() ## Scatter and line plot with go.Scatter -When data are not available as tidy dataframes, it is possible to use the more generic `go.Scatter` function from `plotly.graph_objects`. Whereas `plotly.express` has two functions `scatter` and `line`, `go.Scatter` can be used both for plotting points (makers) or lines, depending on the value of `mode`. The different options of `go.Scatter` are documented in its [reference page](https://plot.ly/python/reference/#scatter ). +If Plotly Express does not provide a good starting point, it is possible to use the more generic `go.Scatter` function from `plotly.graph_objects`. Whereas `plotly.express` has two functions `scatter` and `line`, `go.Scatter` can be used both for plotting points (makers) or lines, depending on the value of `mode`. The different options of `go.Scatter` are documented in its [reference page](https://plot.ly/python/reference/#scatter ). #### Simple Scatter Plot diff --git a/python/line-charts.md b/python/line-charts.md index 5d21bb146..675719c4e 100644 --- a/python/line-charts.md +++ b/python/line-charts.md @@ -40,7 +40,7 @@ jupyter: ### Line Plot with plotly.express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). With ``px.line``, each data point is represented as a vertex (which location is given by the `x` and `y` columns) of a **polyline mark** in 2D space. +[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.line``, each data point is represented as a vertex (which location is given by the `x` and `y` columns) of a **polyline mark** in 2D space. For more examples of line plots, see the [line and scatter notebook](https://plot.ly/python/line-and-scatter/). @@ -75,7 +75,7 @@ fig.show() ### Line Plot with go.Scatter -When data are not available as tidy dataframes, it is possible to use the more generic `go.Scatter` function from `plotly.graph_objects`. Whereas `plotly.express` has two functions `scatter` and `line`, `go.Scatter` can be used both for plotting points (makers) or lines, depending on the value of `mode`. The different options of `go.Scatter` are documented in its [reference page](https://plot.ly/python/reference/#scatter ). +If Plotly Express does not provide a good starting point, it is possible to use the more generic `go.Scatter` function from `plotly.graph_objects`. Whereas `plotly.express` has two functions `scatter` and `line`, `go.Scatter` can be used both for plotting points (makers) or lines, depending on the value of `mode`. The different options of `go.Scatter` are documented in its [reference page](https://plot.ly/python/reference/#scatter ). #### Simple Line Plot diff --git a/python/lines-on-mapbox.md b/python/lines-on-mapbox.md index d93c483e3..99d1098df 100644 --- a/python/lines-on-mapbox.md +++ b/python/lines-on-mapbox.md @@ -40,7 +40,7 @@ jupyter: To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information. -To draw a line on your map, you either can use [`px.line_mapbox()`](https://www.plotly.express/plotly_express/#plotly_express.line_mapbox) in plotly express, or [`Scattermapbox`](https://plot.ly/python/reference/#scattermapbox) traces. Below we show you how to draw a line on Mapbox using plotly express. +To draw a line on your map, you either can use [`px.line_mapbox()`](https://www.plotly.express/plotly_express/#plotly_express.line_mapbox) in Plotly Express, or [`Scattermapbox`](https://plot.ly/python/reference/#scattermapbox) traces. Below we show you how to draw a line on Mapbox using Plotly Express. ### Lines on Mapbox maps using Plotly Express @@ -70,22 +70,22 @@ import plotly.graph_objects as go fig = go.Figure(go.Scattermapbox( mode = "markers+lines", - lon = [10, 20, 30], - lat = [10, 20,30], + lon = [10, 20, 30], + lat = [10, 20,30], marker = {'size': 10})) fig.add_trace(go.Scattermapbox( - mode = "markers+lines", - lon = [-50, -60,40], - lat = [30, 10, -20], + mode = "markers+lines", + lon = [-50, -60,40], + lat = [30, 10, -20], marker = {'size': 10})) fig.update_layout( margin ={'l':0,'t':0,'b':0,'r':0}, mapbox = { 'center': {'lon': 10, 'lat': 10}, - 'style': "stamen-terrain", - 'center': {'lon': -20, 'lat': -20}, + 'style': "stamen-terrain", + 'center': {'lon': -20, 'lat': -20}, 'zoom': 1}) fig.show() diff --git a/python/lines-on-maps.md b/python/lines-on-maps.md index 83a1ee251..ec02d59b5 100644 --- a/python/lines-on-maps.md +++ b/python/lines-on-maps.md @@ -39,15 +39,17 @@ jupyter: For other geographical and map charts see [the maps index page](../maps/). -Below we show how to create geographical line plots using either plotly express with `px.line_geo` (for data available as tidy pandas DataFrame) or `go.Scattergeo` for the generic case. +Below we show how to create geographical line plots using either Plotly Express with `px.line_geo` or the lower-level `go.Scattergeo`. -## Lines on Maps with plotly express +## Lines on Maps 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/). ```python import plotly.express as px gapminder = px.data.gapminder().query("year == 2007") -fig = px.line_geo(gapminder, locations="iso_alpha", - color="continent", # "continent" is one of the columns of gapminder +fig = px.line_geo(gapminder, locations="iso_alpha", + color="continent", # "continent" is one of the columns of gapminder projection="orthographic") fig.show() ``` diff --git a/python/marker-style.md b/python/marker-style.md index 06fa827c2..f804371c0 100644 --- a/python/marker-style.md +++ b/python/marker-style.md @@ -40,7 +40,7 @@ jupyter: In order to make markers look more distinct, you can add a border to the markers. This can be achieved by adding the line property to the marker object. -Here is an example of adding a marker border to a faceted scatter plot created using plotly express. +Here is an example of adding a marker border to a faceted scatter plot created using Plotly Express. ```python import plotly.express as px diff --git a/python/parallel-coordinates-plot.md b/python/parallel-coordinates-plot.md index 0653d23bd..6852ae313 100644 --- a/python/parallel-coordinates-plot.md +++ b/python/parallel-coordinates-plot.md @@ -39,9 +39,9 @@ jupyter: v4upgrade: true --- -## Parallel Coordinates plot with plotly express +## Parallel Coordinates plot with Plotly Express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). In a parallel coordinates plot with `px.parallel_coordinates`, each row of the DataFrame is represented by a polyline mark which traverses a set of parallel axes, one for each of the dimensions. For other representations of multivariate data, also see [radar charts](../radar-chart/) and [scatterplot matrix (SPLOM)](../splom/). +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). In a parallel coordinates plot with `px.parallel_coordinates`, each row of the DataFrame is represented by a polyline mark which traverses a set of parallel axes, one for each of the dimensions. For other representations of multivariate data, also see [radar charts](../radar-chart/) and [scatterplot matrix (SPLOM)](../splom/). ```python import plotly.express as px diff --git a/python/polar-chart.md b/python/polar-chart.md index a05cd7c5f..3e31e09ef 100644 --- a/python/polar-chart.md +++ b/python/polar-chart.md @@ -37,9 +37,13 @@ jupyter: v4upgrade: true --- -## Polar chart with plotly express +## Polar chart with Plotly Express -A polar chart represents data along radial and angular axes. With plotly express, it is possible to represent polar data as scatter markers with `px.scatter_polar`, and as lines with `px.line_polar`. [Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). For other types of arguments, see the section below using `go.Scatterpolar`. +A polar chart represents data along radial and angular axes. With Plotly Express, it is possible to represent polar data as scatter markers with `px.scatter_polar`, and as lines with `px.line_polar`. + +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). + + For other types of arguments, see the section below using `go.Scatterpolar`. The radial and angular coordinates are given with the `r` and `theta` arguments of `px.scatter_polar`. In the example below the `theta` data are categorical, but numerical data are possible too and the most common case. @@ -77,7 +81,7 @@ See also the [wind rose page](https://plot.ly/python/wind-rose-charts/) for more ## Polar Scatter Plot with go.Scatterpolar -When data is not in the form of a tidy dataframe, you can use the more generic `go.Scatterpolar`. All the options are documented in the [reference page](https://plot.ly/python/reference/#scatterpolar). +If Plotly Express does not provide a good starting point, you can use the more generic `go.Scatterpolar`. All the options are documented in the [reference page](https://plot.ly/python/reference/#scatterpolar). #### Basic Polar Chart diff --git a/python/px-arguments.md b/python/px-arguments.md index 790ccfd4f..5b3c7328b 100644 --- a/python/px-arguments.md +++ b/python/px-arguments.md @@ -20,9 +20,9 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.3 + version: 3.6.8 plotly: - description: Arguments accepted by plotly express functions + description: Arguments accepted by Plotly Express functions display_as: file_settings has_thumbnail: true ipynb: ~notebook_demo/253 @@ -37,9 +37,36 @@ jupyter: v4upgrade: true --- -## The different ways to call plotly express functions +### Tidy Data -See also the [introduction to plotly express](./plotly-express). +[Plotly Express](/python/plotly-express) operates on "tidy" or "long" data rather than "wide" data. You may pass data in either as a Pandas `DataFrame` objects or as individual array-like objects which `px` will assemble into a data frame internally, such as lists, `numpy` arrays or Pandas `Series` objects. + +What follows is a very short example of the difference between wide and tidy/long data, and the excellent [Tidy Data in Python blog post](https://www.jeannicholashould.com/tidy-data-in-python.html) contains much more information about the tidy approach to structuring data. + +```python +import pandas as pd +print("This is 'wide' data, unsuitable as-is for Plotly Express:") +wide_df = pd.DataFrame(dict(Month=["Jan", "Feb", "Mar"], London=[1,2,3], Paris=[3,1,2])) +wide_df +``` + +```python +import pandas as pd +print("This is the same data in 'long' format, ready for Plotly Express:") +wide_df = pd.DataFrame(dict(Month=["Jan", "Feb", "Mar"], London=[1,2,3], Paris=[3,1,2])) +tidy_df = wide_df.melt(id_vars="Month") +``` + +```python +import plotly.express as px +import pandas as pd + +wide_df = pd.DataFrame(dict(Month=["Jan", "Feb", "Mar"], London=[1,2,3], Paris=[3,1,2])) +tidy_df = wide_df.melt(id_vars="Month") + +fig = px.bar(tidy_df, x="Month", y="value", color="variable", barmode="group") +fig.show() +``` ### pandas DataFrame input data @@ -66,7 +93,7 @@ fig.show() #### Using the index of a DataFrame -In addition to columns, it is also possible to pass the index of a DataFrame as argument. In the example below the index is displayed in the hover data. +In addition to columns, it is also possible to pass the index of a DataFrame as argument. In the example below the index is displayed in the hover data. ```python import plotly.express as px @@ -93,7 +120,7 @@ fig.show() ### Using labels to pass names -The `labels` argument can be used to override the names used for axis titles, legend entries and hovers. +The `labels` argument can be used to override the names used for axis titles, legend entries and hovers. ```python import plotly.express as px @@ -101,7 +128,7 @@ import pandas as pd gapminder = px.data.gapminder() gdp = gapminder['pop'] * gapminder['gdpPercap'] -fig = px.bar(gapminder, x='year', y=gdp, color='continent', labels={'y':'gdp'}, +fig = px.bar(gapminder, x='year', y=gdp, color='continent', labels={'y':'gdp'}, hover_data=['country'], title='Evolution of world GDP') fig.show() @@ -109,7 +136,7 @@ fig.show() ### Using array-like arguments: NumPy arrays, lists... -`px` arguments can also be array-like objects such as lists, NumPy arrays. +`px` arguments can also be array-like objects such as lists, NumPy arrays. ```python import plotly.express as px @@ -138,7 +165,7 @@ import plotly.express as px import numpy as np N = 10000 np.random.seed(0) -fig = px.density_contour(dict(effect_size=5 + np.random.randn(N), +fig = px.density_contour(dict(effect_size=5 + np.random.randn(N), waiting_time=np.random.poisson(size=N)), x="effect_size", y="waiting_time") fig.show() @@ -159,7 +186,7 @@ fig.show() ### Mixing dataframes and other types -It is possible to mix DataFrame columns, NumPy arrays and lists as arguments. Remember that the only column names to be used correspond to columns in the `data_frame` argument, use `labels` to override names displayed in axis titles, legend entries or hovers. +It is possible to mix DataFrame columns, NumPy arrays and lists as arguments. Remember that the only column names to be used correspond to columns in the `data_frame` argument, use `labels` to override names displayed in axis titles, legend entries or hovers. ```python import plotly.express as px @@ -168,7 +195,7 @@ import pandas as pd gapminder = px.data.gapminder() gdp = np.log(gapminder['pop'] * gapminder['gdpPercap']) # NumPy array -fig = px.bar(gapminder, x='year', y=gdp, color='continent', labels={'y':'log gdp'}, +fig = px.bar(gapminder, x='year', y=gdp, color='continent', labels={'y':'log gdp'}, hover_data=['country'], title='Evolution of world GDP') fig.show() diff --git a/python/radar-chart.md b/python/radar-chart.md index 96fa7712f..e6cb20bc8 100644 --- a/python/radar-chart.md +++ b/python/radar-chart.md @@ -41,7 +41,9 @@ A [Radar Chart](https://en.wikipedia.org/wiki/Radar_chart) (also known as a spid For a Radar Chart, use a [polar chart](../polar-chart/) with categorical angular variables, with `px.line_polar` for data available as a tidy pandas DataFrame, or with `go.Scatterpolar` in the general case. See more examples of [polar charts here](../polar-chart/). -#### Radar Chart with plotly express +#### Radar Chart 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/). Use `line_close=True` for closed lines. @@ -50,7 +52,7 @@ import plotly.express as px import pandas as pd df = pd.DataFrame(dict( r=[1, 5, 2, 2, 3], - theta=['processing cost','mechanical properties','chemical stability', + theta=['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'])) fig = px.line_polar(df, r='r', theta='theta', line_close=True) fig.show() @@ -63,7 +65,7 @@ import plotly.express as px import pandas as pd df = pd.DataFrame(dict( r=[1, 5, 2, 2, 3], - theta=['processing cost','mechanical properties','chemical stability', + theta=['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'])) fig = px.line_polar(df, r='r', theta='theta', line_close=True) fig.update_traces(fill='toself') diff --git a/python/scatter-plots-on-maps.md b/python/scatter-plots-on-maps.md index ebafa55ef..b98e168ab 100644 --- a/python/scatter-plots-on-maps.md +++ b/python/scatter-plots-on-maps.md @@ -40,7 +40,9 @@ jupyter: ### Geographical Scatter Plot with px.scatter_geo -For data available as a tidy pandas DataFrame, use the [Plotly Express](/python/plotly-express/) function `px.scatter_geo` for a geographical scatter plot. The `size` argument is used to set the size of markers from a given column of the DataFrame. +Here we show the [Plotly Express](/python/plotly-express/) function `px.scatter_geo` for a geographical scatter plot. The `size` argument is used to set the size of markers from a given column of the DataFrame. + +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px diff --git a/python/scattermapbox.md b/python/scattermapbox.md index d49a30905..e22674fd6 100644 --- a/python/scattermapbox.md +++ b/python/scattermapbox.md @@ -43,7 +43,9 @@ To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public ### Basic example with Plotly Express -For data available as a tidy pandas DataFrame, use the [Plotly Express](/python/plotly-express/) function `px.scatter_mapbox` for a scatter plot on a tile map. +Here we show the [Plotly Express](/python/plotly-express/) function `px.scatter_mapbox` for a scatter plot on a tile map. + +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px @@ -196,9 +198,9 @@ fig.update_layout( fig.show() ``` -### Set Marker Symbols +### Set Marker Symbols -You can define a symbol on your map by setting [symbol](https://plot.ly/python/reference/#scattermapbox-marker-symbol) attribute. This attribute only works on Mapbox-provided `style`s: +You can define a symbol on your map by setting [symbol](https://plot.ly/python/reference/#scattermapbox-marker-symbol) attribute. This attribute only works on Mapbox-provided `style`s: - basic - streets - outdoors @@ -214,7 +216,7 @@ token = open(".mapbox_token").read() # you need your own token fig = go.Figure(go.Scattermapbox( mode = "markers+text+lines", - lon = [-75, -80, -50], lat = [45, 20, -20], + lon = [-75, -80, -50], lat = [45, 20, -20], marker = {'size': 20, 'symbol': ["bus", "harbor", "airport"]}, text = ["Bus", "Harbor", "airport"],textposition = "bottom right")) diff --git a/python/splom.md b/python/splom.md index 75f079525..3a132203b 100644 --- a/python/splom.md +++ b/python/splom.md @@ -38,11 +38,13 @@ jupyter: v4upgrade: true --- -### Scatter matrix with plotly express +### Scatter matrix with Plotly Express A scatterplot matrix is a matrix associated to n numerical arrays (data variables), $X_1,X_2,…,X_n$ , of the same length. The cell (i,j) of such a matrix displays the scatter plot of the variable Xi versus Xj. -For data available as a tidy pandas dataframe, the plotly express function `px.scatter_matrix` plots the scatter matrix for the columns of the dataframe. By default, all columns are considered. +Here we show the Plotly Express function `px.scatter_matrix` to plot the scatter matrix for the columns of the dataframe. By default, all columns are considered. + +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px @@ -56,20 +58,20 @@ Specify the columns to be represented with the `dimensions` argument, and set co ```python import plotly.express as px iris = px.data.iris() -fig = px.scatter_matrix(iris, +fig = px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species") fig.show() ``` -#### Styled Scatter Matrix with plotly express +#### Styled Scatter Matrix with Plotly Express The scatter matrix plot can be configured thanks to the parameters of `px.scatter_matrix`, but also thanks to `fig.update_traces` for fine tuning (see the next section to learn more about the options). ```python import plotly.express as px iris = px.data.iris() -fig = px.scatter_matrix(iris, +fig = px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species", symbol="species", title="Scatter matrix of iris data set", @@ -81,7 +83,7 @@ fig.show() ### Scatter matrix (splom) with go.Splom -When data are not available as a tidy dataframe, it is possible to use the more generic `go.Splom` function. All its parameters are documented in the reference page https://plot.ly/python/reference/#splom. +If Plotly Express does not provide a good starting point, it is possible to use the more generic `go.Splom` function. All its parameters are documented in the reference page https://plot.ly/python/reference/#splom. The Plotly splom trace implementation for the scatterplot matrix does not require to set $x=Xi$ , and $y=Xj$, for each scatter plot. All arrays, $X_1,X_2,…,X_n$ , are passed once, through a list of dicts called dimensions, i.e. each array/variable represents a dimension. @@ -113,10 +115,10 @@ import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/iris-data.csv') # The Iris dataset contains four data variables, sepal length, sepal width, petal length, -# petal width, for 150 iris flowers. The flowers are labeled as `Iris-setosa`, +# petal width, for 150 iris flowers. The flowers are labeled as `Iris-setosa`, # `Iris-versicolor`, `Iris-virginica`. -# Define indices corresponding to flower categories, using pandas label encoding +# Define indices corresponding to flower categories, using pandas label encoding index_vals = df['class'].astype('category').cat.codes fig = go.Figure(data=go.Splom( diff --git a/python/templates.md b/python/templates.md index f058940d7..4860660c1 100644 --- a/python/templates.md +++ b/python/templates.md @@ -52,8 +52,8 @@ pio.templates From this, we can see that the default theme is `"plotly"`, and we can see the names of several additional themes that we can choose from. -#### Specifying themes in plotly express -All plotly express functions accept a `template` argument that can be set to the name of a registered theme (or to a `Template` object as discussed later in this section). Here is an example of using plotly express to build and display the same scatter plot with five different themes. +#### Specifying themes in Plotly Express +All Plotly Express functions accept a `template` argument that can be set to the name of a registered theme (or to a `Template` object as discussed later in this section). Here is an example of using Plotly Express to build and display the same scatter plot with five different themes. ```python import plotly.express as px @@ -92,9 +92,9 @@ for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", ``` #### Specifying a default themes -If a theme is not provided to a plotly express function or to a graph object figure, then the default theme is used. The default theme starts out as `"plotly"`, but it can be changed by setting the `plotly.io.templates.default` property to the name of a registered theme. +If a theme is not provided to a Plotly Express function or to a graph object figure, then the default theme is used. The default theme starts out as `"plotly"`, but it can be changed by setting the `plotly.io.templates.default` property to the name of a registered theme. -Here is an example of changing to default theme to `"plotly_white"` and then constructing a scatter plot with plotly express without providing a template. +Here is an example of changing to default theme to `"plotly_white"` and then constructing a scatter plot with Plotly Express without providing a template. > Note: Default themes persist for the duration of a single session, but they do not persist across sessions. If you are working in an IPython kernel, this means that default themes will persist for the life of the kernel, but they will not persist across kernel restarts. @@ -282,7 +282,7 @@ fig.show() ``` #### Registering themes as named templates -The examples above construct and configure a `Template` object and then pass that object as the template specification to graph object figures (as the `layout.template` property) or plotly express functions (as the `template` keyword argument). It is also possible to register custom templates by name so that the name itself can be used to refer to the template. To register a template, use dictionary-style assignment to associate the template object with a name in the `plotly.io.templates` configuration object. +The examples above construct and configure a `Template` object and then pass that object as the template specification to graph object figures (as the `layout.template` property) or Plotly Express functions (as the `template` keyword argument). It is also possible to register custom templates by name so that the name itself can be used to refer to the template. To register a template, use dictionary-style assignment to associate the template object with a name in the `plotly.io.templates` configuration object. Here is an example of registering the draft watermark template from the previous sections as a template named `"draft"`. Then a graph object figure is created with the draft template specified by name. @@ -314,7 +314,7 @@ fig.show() > Note: this example uses magic underscore notation to write `go.layout.Template(layout=dict(annotations=[...]))` as ``go.layout.Template(layout_annotations=[...])` -It is also possible to set your own custom template as the default so that you do not need to pass it by name when constructing graph object figures or calling plotly express functions. +It is also possible to set your own custom template as the default so that you do not need to pass it by name when constructing graph object figures or calling Plotly Express functions. ```python import plotly.graph_objects as go @@ -375,7 +375,7 @@ fig = go.Figure() fig.show() ``` -Combining themes is also supported by plotly express +Combining themes is also supported by Plotly Express ```python import plotly.io as pio diff --git a/python/text-and-annotations.md b/python/text-and-annotations.md index 1df3fb276..39c97609e 100644 --- a/python/text-and-annotations.md +++ b/python/text-and-annotations.md @@ -38,7 +38,7 @@ jupyter: ### Text scatter plot with Plotly Express -Here is an example that creates a scatter plot with text labels using plotly express. +Here is an example that creates a scatter plot with text labels using Plotly Express. ```python import plotly.express as px diff --git a/python/v4-migration.md b/python/v4-migration.md index c954c707e..729440266 100644 --- a/python/v4-migration.md +++ b/python/v4-migration.md @@ -73,7 +73,7 @@ with from chart_studio.plotly import plot, iplot ``` -Similarly, +Similarly, - Replace **`plotly.api`** with **`chart_studio.api`** - Replace **`plotly.dashboard_objs`** with **`chart_studio.dashboard_objs`** - Replace **`plotly.grid_objs`** with **`chart_studio.grid_objs`** @@ -204,13 +204,13 @@ scatter.marker.size = 20 ### `make_subplots` updates -The `make_subplots` function has been overhauled to support all trace types and to support the integration of plotly express. Here are a few changes to be aware of when porting code that uses `make_subplots` to version 4. +The `make_subplots` function has been overhauled to support all trace types and to support the integration of Plotly Express. Here are a few changes to be aware of when porting code that uses `make_subplots` to version 4. #### New preferred import location The preferred import location of the `make_subplots` function is now `plotly.subplots.make_subplots`. For compatibility, this function is still available as `plotly.tools.make_subplots`. #### Grid no longer printed by default -When the `print_grid` argument to `make_subplots` is set to `True`, a text representation of the subplot grid is printed by the `make_subplots` function. In version 3, the default value of `print_grid` was `True`. In version 4, the default value of `print_grid` is `False`. +When the `print_grid` argument to `make_subplots` is set to `True`, a text representation of the subplot grid is printed by the `make_subplots` function. In version 3, the default value of `print_grid` was `True`. In version 4, the default value of `print_grid` is `False`. #### New `row_heights` argument to replace `row_width` The legacy argument for specifying the relative height of subplot rows was called `row_width`. A new `row_heights` argument has been introduced for this purpose. @@ -252,7 +252,7 @@ fig.show() ``` #### Implementation of shared axes with `make_subplots` -The implementation of shared axis support in the `make_subplots` function has been simplified. Prior to version 4, shared y-axes were implemented by associating a single `yaxis` object with multiple `xaxis` objects, and vica versa. +The implementation of shared axis support in the `make_subplots` function has been simplified. Prior to version 4, shared y-axes were implemented by associating a single `yaxis` object with multiple `xaxis` objects, and vica versa. In version 4, every 2D Cartesian subplot has a dedicated x-axis and and a dedicated y-axis. Axes are now "shared" by being linked together using the `matches` axis property. diff --git a/python/violin.md b/python/violin.md index 87597c388..93bcc8c1f 100644 --- a/python/violin.md +++ b/python/violin.md @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.6.8 plotly: description: How to make violin plots in Python with Plotly. display_as: statistical @@ -37,15 +37,15 @@ jupyter: v4upgrade: true --- -## Violin Plot with plotly express +## Violin Plot with Plotly Express A [violin plot](https://en.wikipedia.org/wiki/Violin_plot) is a statistical representation of numerical data. It is similar to a [box plot](https://plot.ly/python/box-plots/), with the addition of a rotated [kernel density](https://en.wikipedia.org/wiki/Kernel_density_estimation) plot on each side. See also the [list of other statistical charts](https://plot.ly/python/statistical-charts/). -### Basic Violin Plot with plotly express +### Basic Violin Plot with Plotly Express -[Plotly Express](../plotly-express/) functions take as a first argument a [tidy `pandas.DataFrame`](https://www.jeannicholashould.com/tidy-data-in-python.html). +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px @@ -91,7 +91,7 @@ fig.show() ## Violin Plot with go.Violin -When data are not available as a tidy dataframe, you can use the more generic function `go.Violin` from `plotly.graph_objects`. All the options of `go.Violin` are documented in the reference https://plot.ly/python/reference/#violin +If Plotly Express does not provide a good starting point, you can use the more generic function `go.Violin` from `plotly.graph_objects`. All the options of `go.Violin` are documented in the reference https://plot.ly/python/reference/#violin #### Basic Violin Plot diff --git a/python/webgl-vs-svg.md b/python/webgl-vs-svg.md index 42f2c8c81..ac8f3f2fd 100644 --- a/python/webgl-vs-svg.md +++ b/python/webgl-vs-svg.md @@ -40,11 +40,11 @@ jupyter: #### Compare WebGL and SVG Checkout [this notebook](https://plot.ly/python/compare-webgl-svg) to compare WebGL and SVG scatter plots with 75,000 random data points -#### WebGL with plotly express +#### WebGL with Plotly Express -The `rendermode` argument to supported plotly express functions can be used to enable WebGL rendering. +The `rendermode` argument to supported Plotly Express functions can be used to enable WebGL rendering. -Here is an example that creates a 100,000 point scatter plot using plotly express with WebGL rendering enabled. +Here is an example that creates a 100,000 point scatter plot using Plotly Express with WebGL rendering enabled. ```python import plotly.express as px diff --git a/python/wind-rose-charts.md b/python/wind-rose-charts.md index a1e5f46b9..6ea767096 100644 --- a/python/wind-rose-charts.md +++ b/python/wind-rose-charts.md @@ -38,9 +38,11 @@ jupyter: v4upgrade: true --- -### Wind Rose Chart with plotly express +### Wind Rose Chart with Plotly Express -A [wind rose chart](https://en.wikipedia.org/wiki/Wind_rose) (also known as a polar bar chart) is a graphical tool used to visualize how wind speed and direction are typically distributed at a given location. For data stored in a tidy pandas dataframe, use the `px.bar_polar` function from plotly express as below, otherwise use `go.Barpolar` as explained in the next section. +A [wind rose chart](https://en.wikipedia.org/wiki/Wind_rose) (also known as a polar bar chart) is a graphical tool used to visualize how wind speed and direction are typically distributed at a given location. You can use the `px.bar_polar` function from Plotly Express as below, otherwise use `go.Barpolar` as explained in the next section. + +[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/). ```python import plotly.express as px