From 62102fd354b545c1de7d921013c84800d6a34802 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 15:01:28 -0400 Subject: [PATCH 01/20] percy tests --- .circleci/config.yml | 31 +++++ test/percy/plotly-express.py | 225 +++++++++++++++++++++++++++++++++++ 2 files changed, 256 insertions(+) create mode 100644 test/percy/plotly-express.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 101357a36da..e0bae139f4d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -160,6 +160,37 @@ jobs: command: 'cd packages/python/plotly; tox -e py37-optional' no_output_timeout: 20m + python-3.7-percy: + docker: + - image: circleci/python:3.7-stretch-node-browsers + + environment: + PERCY_ENABLED: True + PERCY_PROJECT: plotly/plotly.py + + steps: + - checkout + - run: + name: Inject Percy Environment variables + command: | + echo 'export PERCY_TOKEN="$PERCY_PYTHON_TOKEN_V0"' >> $BASH_ENV + + - run: + name: Install requirements + command: | + pip install -e ./packages/python/plotly + + - run: + name: Build html figures + command: | + python tests/percy/plotly.express.py + + - run: + name: Run percy snapshots + command: | + npx percy snapshot tests/percy/ + rm tests/percy/*.html + # Plot.ly python-2.7-plot_ly: docker: diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py new file mode 100644 index 00000000000..70107b2d1ca --- /dev/null +++ b/test/percy/plotly-express.py @@ -0,0 +1,225 @@ +## This script uses px functions to generate html figures, which will be +## tested with percy. + +import plotly.express as px +print(px.data.iris.__doc__) +px.data.iris().head() + +# #### Scatter and Line plots + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter(iris, x="sepal_width", y="sepal_length") +fig.write_html('scatter.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species") +fig.write_html('scatter_color.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="rug", marginal_x="histogram") +fig.write_html('scatter_marginal.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="violin", + marginal_x="box", trendline="ols") +fig.write_html('scatter_trendline.html') + +import plotly.express as px +iris = px.data.iris() +iris["e"] = iris["sepal_width"]/100 +fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", error_x="e", error_y="e") +fig.write_html('scatter_errorbar.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.scatter(tips, x="total_bill", y="tip", facet_row="time", facet_col="day", color="smoker", trendline="ols", + category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) +fig.write_html('scatter_categories.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter_matrix(iris) +fig.write_html('scatter_matrix.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species") +fig.write_html('scatter_matrix_dimensions.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.parallel_coordinates(iris, color="species_id", labels={"species_id": "Species", + "sepal_width": "Sepal Width", "sepal_length": "Sepal Length", + "petal_width": "Petal Width", "petal_length": "Petal Length", }, + color_continuous_scale=px.colors.diverging.Tealrose, color_continuous_midpoint=2) +fig.write_html('parallel_coordinates.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.parallel_categories(tips, color="size", color_continuous_scale=px.colors.sequential.Inferno) +fig.write_html('parallel_categories.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.scatter(tips, x="total_bill", y="tip", color="size", facet_col="sex", + color_continuous_scale=px.colors.sequential.Viridis, render_mode="webgl") +fig.write_html('scatter_webgl.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.scatter(gapminder.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", color="continent", + hover_name="country", log_x=True, size_max=60) +fig.write_html('scatter_hover.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.scatter(gapminder, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country", + size="pop", color="continent", hover_name="country", facet_col="continent", + log_x=True, size_max=45, range_x=[100,100000], range_y=[25,90]) +fig.write_html('scatter_log.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.line(gapminder, x="year", y="lifeExp", color="continent", line_group="country", hover_name="country", + line_shape="spline", render_mode="svg") +fig.write_html('line.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.area(gapminder, x="year", y="pop", color="continent", line_group="country") +fig.write_html('area.html') + +# #### Visualize Distributions + +import plotly.express as px +iris = px.data.iris() +fig = px.density_contour(iris, x="sepal_width", y="sepal_length") +fig.write_html('density_contour.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.density_contour(iris, x="sepal_width", y="sepal_length", color="species", marginal_x="rug", marginal_y="histogram") +fig.write_html('density_contour_marginal.html') + +import plotly.express as px +iris = px.data.iris() +fig = px.density_heatmap(iris, x="sepal_width", y="sepal_length", marginal_x="rug", marginal_y="histogram") +fig.write_html('density_heatmap.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group") +fig.write_html('bar.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group", facet_row="time", facet_col="day", + category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) +fig.write_html('bar_facet.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.histogram(tips, x="total_bill", y="tip", color="sex", marginal="rug", hover_data=tips.columns) +fig.write_html('histogram.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.histogram(tips, x="sex", y="tip", histfunc="avg", color="smoker", barmode="group", + facet_row="time", facet_col="day", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], + "time": ["Lunch", "Dinner"]}) +fig.write_html('histogram_histfunc.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.strip(tips, x="total_bill", y="time", orientation="h", color="smoker") +fig.write_html('strip.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.box(tips, x="day", y="total_bill", color="smoker", notched=True) +fig.write_html('box.html') + +import plotly.express as px +tips = px.data.tips() +fig = px.violin(tips, y="tip", x="smoker", color="sex", box=True, points="all", hover_data=tips.columns) +fig.write_html('violin.html') + +# #### Ternary Coordinates + +import plotly.express as px +election = px.data.election() +fig = px.scatter_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", size="total", hover_name="district", + size_max=15, color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"} ) +fig.write_html('scatter_ternary.html') + +import plotly.express as px +election = px.data.election() +fig = px.line_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", line_dash="winner") +fig.write_html('line_ternary.html') + +# #### 3D Coordinates + +import plotly.express as px +election = px.data.election() +fig = px.scatter_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", size="total", hover_name="district", + symbol="result", color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"}) +fig.write_html('scatter_3d.html') + +import plotly.express as px +election = px.data.election() +fig = px.line_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner") +fig.write_html('line_3d.html') + +# #### Polar Coordinates + +import plotly.express as px +wind = px.data.wind() +fig = px.scatter_polar(wind, r="frequency", theta="direction", color="strength", symbol="strength", + color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) +fig.write_html('scatter_polar.html') + +import plotly.express as px +wind = px.data.wind() +fig = px.line_polar(wind, r="frequency", theta="direction", color="strength", line_close=True, + color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) +fig.write_html('line_polar.html') + +import plotly.express as px +wind = px.data.wind() +fig = px.bar_polar(wind, r="frequency", theta="direction", color="strength", template="plotly_dark", + color_discrete_sequence= px.colors.sequential.Plasma[-2::-1]) +fig.write_html('bar_polar.html') + +# #### Maps + +import plotly.express as px +carshare = px.data.carshare() +fig = px.scatter_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour", size="car_hours", + color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, zoom=10) +fig.write_html('scatter_mapbox.html') + +import plotly.express as px +carshare = px.data.carshare() +fig = px.line_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour") +fig.write_html('line_mapbox.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.scatter_geo(gapminder, locations="iso_alpha", color="continent", hover_name="country", size="pop", + animation_frame="year", projection="natural earth") +fig.write_html('scatter_geo.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.line_geo(gapminder.query("year==2007"), locations="iso_alpha", color="continent", projection="orthographic") +fig.write_html('line_geo.html') + +import plotly.express as px +gapminder = px.data.gapminder() +fig = px.choropleth(gapminder, locations="iso_alpha", color="lifeExp", hover_name="country", animation_frame="year", range_color=[20,80]) +fig.write_html('choropleth.html') + From 6f7224b57ba35b66e3677bfd98546cd6702969e3 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 15:11:56 -0400 Subject: [PATCH 02/20] change order of ci jobs --- .circleci/config.yml | 63 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e0bae139f4d..68d97e237ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,6 +79,38 @@ jobs: command: 'cd packages/python/plotly; tox -e py37-core' no_output_timeout: 20m + python-3.7-percy: + docker: + - image: circleci/python:3.7-stretch-node-browsers + + environment: + PERCY_ENABLED: True + PERCY_PROJECT: plotly/plotly.py + + steps: + - checkout + - run: + name: Inject Percy Environment variables + command: | + echo 'export PERCY_TOKEN="$PERCY_PYTHON_TOKEN_V0"' >> $BASH_ENV + + - run: + name: Install requirements + command: | + pip install -e ./packages/python/plotly + + - run: + name: Build html figures + command: | + python tests/percy/plotly.express.py + + - run: + name: Run percy snapshots + command: | + npx percy snapshot tests/percy/ + rm tests/percy/*.html + + # Optional python-2.7-optional: docker: @@ -160,37 +192,6 @@ jobs: command: 'cd packages/python/plotly; tox -e py37-optional' no_output_timeout: 20m - python-3.7-percy: - docker: - - image: circleci/python:3.7-stretch-node-browsers - - environment: - PERCY_ENABLED: True - PERCY_PROJECT: plotly/plotly.py - - steps: - - checkout - - run: - name: Inject Percy Environment variables - command: | - echo 'export PERCY_TOKEN="$PERCY_PYTHON_TOKEN_V0"' >> $BASH_ENV - - - run: - name: Install requirements - command: | - pip install -e ./packages/python/plotly - - - run: - name: Build html figures - command: | - python tests/percy/plotly.express.py - - - run: - name: Run percy snapshots - command: | - npx percy snapshot tests/percy/ - rm tests/percy/*.html - # Plot.ly python-2.7-plot_ly: docker: From e06daf38b7f519bb3bbb0cbdc1257dd89bf11aab Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 15:18:38 -0400 Subject: [PATCH 03/20] typo --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68d97e237ed..3baa4a337a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,8 +82,7 @@ jobs: python-3.7-percy: docker: - image: circleci/python:3.7-stretch-node-browsers - - environment: + environment: PERCY_ENABLED: True PERCY_PROJECT: plotly/plotly.py From 1d16c572a5e53ffe156e672c6d4699f56fdb861e Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 15:29:12 -0400 Subject: [PATCH 04/20] typo --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3baa4a337a7..1e33d0b7824 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,17 +92,14 @@ jobs: name: Inject Percy Environment variables command: | echo 'export PERCY_TOKEN="$PERCY_PYTHON_TOKEN_V0"' >> $BASH_ENV - - run: name: Install requirements command: | pip install -e ./packages/python/plotly - - run: name: Build html figures command: | python tests/percy/plotly.express.py - - run: name: Run percy snapshots command: | From 3fa37691994c31d93396d40aa4af14e6ca599211 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 15:44:14 -0400 Subject: [PATCH 05/20] typo --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e33d0b7824..8b7262f7c74 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -106,7 +106,6 @@ jobs: npx percy snapshot tests/percy/ rm tests/percy/*.html - # Optional python-2.7-optional: docker: From a1acb0dbc6711f5b370c9e8519955057c0542940 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:01:21 -0400 Subject: [PATCH 06/20] add percy job to workflows --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b7262f7c74..f5748a3b774 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -394,6 +394,7 @@ workflows: - python-3.5-core - python-3.6-core - python-3.7-core + - python-3.7-percy - python-2.7-optional - python-3.5-optional - python-3.6-optional From ccc0e515faf402c28c924007587a60b08ca5693c Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:06:17 -0400 Subject: [PATCH 07/20] use virtualenv for percy testing --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5748a3b774..f8edbf64ebd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,6 +95,9 @@ jobs: - run: name: Install requirements command: | + sudo pip install --upgrade virtualenv + python -m venv venv || virtualenv venv + . venv/bin/activate pip install -e ./packages/python/plotly - run: name: Build html figures From 34f9861d517545232bdb4e65250aca788b197b1c Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:09:46 -0400 Subject: [PATCH 08/20] typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8edbf64ebd..2b9aa88f1a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -102,7 +102,7 @@ jobs: - run: name: Build html figures command: | - python tests/percy/plotly.express.py + python test/percy/plotly-express.py - run: name: Run percy snapshots command: | From 82e296406f73ace62e32ea866dae69ab8e6cb61a Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:13:57 -0400 Subject: [PATCH 09/20] virtual env --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2b9aa88f1a8..14b85dddaa0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -102,6 +102,7 @@ jobs: - run: name: Build html figures command: | + . venv/bin/activate python test/percy/plotly-express.py - run: name: Run percy snapshots From af5020de5dc1caf3ad82a81f9629fc3ee1db84d6 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:17:54 -0400 Subject: [PATCH 10/20] pandas --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 14b85dddaa0..5ce1a63dff6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,6 +103,7 @@ jobs: name: Build html figures command: | . venv/bin/activate + pip install pandas python test/percy/plotly-express.py - run: name: Run percy snapshots From ef36e03bb33c7442fa50a396c6b293c3e4202545 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:23:25 -0400 Subject: [PATCH 11/20] statsmodels --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5ce1a63dff6..024eb175427 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,7 @@ jobs: name: Build html figures command: | . venv/bin/activate - pip install pandas + pip install pandas statsmodels python test/percy/plotly-express.py - run: name: Run percy snapshots From dddca45ea2b0487bd4ea0622b2bfd3523887a977 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:29:17 -0400 Subject: [PATCH 12/20] typo n path --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 024eb175427..f005d2d3e1f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,7 +109,7 @@ jobs: name: Run percy snapshots command: | npx percy snapshot tests/percy/ - rm tests/percy/*.html + rm test/percy/*.html # Optional python-2.7-optional: From f12fe5a5fbfe654cc78cf1539df2fdc005300832 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 16:56:06 -0400 Subject: [PATCH 13/20] improvement --- .circleci/config.yml | 2 +- test/percy/plotly-express.py | 77 +++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f005d2d3e1f..242189ef77a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,7 @@ jobs: name: Build html figures command: | . venv/bin/activate - pip install pandas statsmodels + pip install pandas statsmodels --quiet python test/percy/plotly-express.py - run: name: Run percy snapshots diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 70107b2d1ca..f8ef93944d1 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -1,6 +1,9 @@ ## This script uses px functions to generate html figures, which will be ## tested with percy. +import os +dir_name = os.path.join("test", "percy") + import plotly.express as px print(px.data.iris.__doc__) px.data.iris().head() @@ -10,45 +13,45 @@ import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length") -fig.write_html('scatter.html') +fig.write_html(os.path.join(dir_name, 'scatter.html')) import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species") -fig.write_html('scatter_color.html') +fig.write_html(os.path.join(dir_name, 'scatter_color.html')) import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="rug", marginal_x="histogram") -fig.write_html('scatter_marginal.html') +fig.write_html(os.path.join(dir_name, 'scatter_marginal.html')) import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="violin", marginal_x="box", trendline="ols") -fig.write_html('scatter_trendline.html') +fig.write_html(os.path.join(dir_name, 'scatter_trendline.html')) import plotly.express as px iris = px.data.iris() iris["e"] = iris["sepal_width"]/100 fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", error_x="e", error_y="e") -fig.write_html('scatter_errorbar.html') +fig.write_html(os.path.join(dir_name, 'scatter_errorbar.html')) import plotly.express as px tips = px.data.tips() fig = px.scatter(tips, x="total_bill", y="tip", facet_row="time", facet_col="day", color="smoker", trendline="ols", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) -fig.write_html('scatter_categories.html') +fig.write_html(os.path.join(dir_name, 'scatter_categories.html')) import plotly.express as px iris = px.data.iris() fig = px.scatter_matrix(iris) -fig.write_html('scatter_matrix.html') +fig.write_html(os.path.join(dir_name, 'scatter_matrix.html')) import plotly.express as px iris = px.data.iris() fig = px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species") -fig.write_html('scatter_matrix_dimensions.html') +fig.write_html(os.path.join(dir_name, 'scatter_matrix_dimensions.html')) import plotly.express as px iris = px.data.iris() @@ -56,97 +59,97 @@ "sepal_width": "Sepal Width", "sepal_length": "Sepal Length", "petal_width": "Petal Width", "petal_length": "Petal Length", }, color_continuous_scale=px.colors.diverging.Tealrose, color_continuous_midpoint=2) -fig.write_html('parallel_coordinates.html') +fig.write_html(os.path.join(dir_name, 'parallel_coordinates.html')) import plotly.express as px tips = px.data.tips() fig = px.parallel_categories(tips, color="size", color_continuous_scale=px.colors.sequential.Inferno) -fig.write_html('parallel_categories.html') +fig.write_html(os.path.join(dir_name, 'parallel_categories.html')) import plotly.express as px tips = px.data.tips() fig = px.scatter(tips, x="total_bill", y="tip", color="size", facet_col="sex", color_continuous_scale=px.colors.sequential.Viridis, render_mode="webgl") -fig.write_html('scatter_webgl.html') +fig.write_html(os.path.join(dir_name, 'scatter_webgl.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.scatter(gapminder.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", color="continent", hover_name="country", log_x=True, size_max=60) -fig.write_html('scatter_hover.html') +fig.write_html(os.path.join(dir_name, 'scatter_hover.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.scatter(gapminder, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country", size="pop", color="continent", hover_name="country", facet_col="continent", log_x=True, size_max=45, range_x=[100,100000], range_y=[25,90]) -fig.write_html('scatter_log.html') +fig.write_html(os.path.join(dir_name, 'scatter_log.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.line(gapminder, x="year", y="lifeExp", color="continent", line_group="country", hover_name="country", line_shape="spline", render_mode="svg") -fig.write_html('line.html') +fig.write_html(os.path.join(dir_name, 'line.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.area(gapminder, x="year", y="pop", color="continent", line_group="country") -fig.write_html('area.html') +fig.write_html(os.path.join(dir_name, 'area.html')) # #### Visualize Distributions import plotly.express as px iris = px.data.iris() fig = px.density_contour(iris, x="sepal_width", y="sepal_length") -fig.write_html('density_contour.html') +fig.write_html(os.path.join(dir_name, 'density_contour.html')) import plotly.express as px iris = px.data.iris() fig = px.density_contour(iris, x="sepal_width", y="sepal_length", color="species", marginal_x="rug", marginal_y="histogram") -fig.write_html('density_contour_marginal.html') +fig.write_html(os.path.join(dir_name, 'density_contour_marginal.html')) import plotly.express as px iris = px.data.iris() fig = px.density_heatmap(iris, x="sepal_width", y="sepal_length", marginal_x="rug", marginal_y="histogram") -fig.write_html('density_heatmap.html') +fig.write_html(os.path.join(dir_name, 'density_heatmap.html')) import plotly.express as px tips = px.data.tips() fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group") -fig.write_html('bar.html') +fig.write_html(os.path.join(dir_name, 'bar.html')) import plotly.express as px tips = px.data.tips() fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group", facet_row="time", facet_col="day", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) -fig.write_html('bar_facet.html') +fig.write_html(os.path.join(dir_name, 'bar_facet.html')) import plotly.express as px tips = px.data.tips() fig = px.histogram(tips, x="total_bill", y="tip", color="sex", marginal="rug", hover_data=tips.columns) -fig.write_html('histogram.html') +fig.write_html(os.path.join(dir_name, 'histogram.html')) import plotly.express as px tips = px.data.tips() fig = px.histogram(tips, x="sex", y="tip", histfunc="avg", color="smoker", barmode="group", facet_row="time", facet_col="day", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) -fig.write_html('histogram_histfunc.html') +fig.write_html(os.path.join(dir_name, 'histogram_histfunc.html')) import plotly.express as px tips = px.data.tips() fig = px.strip(tips, x="total_bill", y="time", orientation="h", color="smoker") -fig.write_html('strip.html') +fig.write_html(os.path.join(dir_name, 'strip.html')) import plotly.express as px tips = px.data.tips() fig = px.box(tips, x="day", y="total_bill", color="smoker", notched=True) -fig.write_html('box.html') +fig.write_html(os.path.join(dir_name, 'box.html')) import plotly.express as px tips = px.data.tips() fig = px.violin(tips, y="tip", x="smoker", color="sex", box=True, points="all", hover_data=tips.columns) -fig.write_html('violin.html') +fig.write_html(os.path.join(dir_name, 'violin.html')) # #### Ternary Coordinates @@ -154,12 +157,12 @@ election = px.data.election() fig = px.scatter_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", size="total", hover_name="district", size_max=15, color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"} ) -fig.write_html('scatter_ternary.html') +fig.write_html(os.path.join(dir_name, 'scatter_ternary.html')) import plotly.express as px election = px.data.election() fig = px.line_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", line_dash="winner") -fig.write_html('line_ternary.html') +fig.write_html(os.path.join(dir_name, 'line_ternary.html')) # #### 3D Coordinates @@ -167,12 +170,12 @@ election = px.data.election() fig = px.scatter_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", size="total", hover_name="district", symbol="result", color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"}) -fig.write_html('scatter_3d.html') +fig.write_html(os.path.join(dir_name, 'scatter_3d.html')) import plotly.express as px election = px.data.election() fig = px.line_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner") -fig.write_html('line_3d.html') +fig.write_html(os.path.join(dir_name, 'line_3d.html')) # #### Polar Coordinates @@ -180,19 +183,19 @@ wind = px.data.wind() fig = px.scatter_polar(wind, r="frequency", theta="direction", color="strength", symbol="strength", color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) -fig.write_html('scatter_polar.html') +fig.write_html(os.path.join(dir_name, 'scatter_polar.html')) import plotly.express as px wind = px.data.wind() fig = px.line_polar(wind, r="frequency", theta="direction", color="strength", line_close=True, color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) -fig.write_html('line_polar.html') +fig.write_html(os.path.join(dir_name, 'line_polar.html')) import plotly.express as px wind = px.data.wind() fig = px.bar_polar(wind, r="frequency", theta="direction", color="strength", template="plotly_dark", color_discrete_sequence= px.colors.sequential.Plasma[-2::-1]) -fig.write_html('bar_polar.html') +fig.write_html(os.path.join(dir_name, 'bar_polar.html')) # #### Maps @@ -200,26 +203,26 @@ carshare = px.data.carshare() fig = px.scatter_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour", size="car_hours", color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, zoom=10) -fig.write_html('scatter_mapbox.html') +fig.write_html(os.path.join(dir_name, 'scatter_mapbox.html')) import plotly.express as px carshare = px.data.carshare() fig = px.line_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour") -fig.write_html('line_mapbox.html') +fig.write_html(os.path.join(dir_name, 'line_mapbox.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.scatter_geo(gapminder, locations="iso_alpha", color="continent", hover_name="country", size="pop", animation_frame="year", projection="natural earth") -fig.write_html('scatter_geo.html') +fig.write_html(os.path.join(dir_name, 'scatter_geo.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.line_geo(gapminder.query("year==2007"), locations="iso_alpha", color="continent", projection="orthographic") -fig.write_html('line_geo.html') +fig.write_html(os.path.join(dir_name, 'line_geo.html')) import plotly.express as px gapminder = px.data.gapminder() fig = px.choropleth(gapminder, locations="iso_alpha", color="lifeExp", hover_name="country", animation_frame="year", range_color=[20,80]) -fig.write_html('choropleth.html') +fig.write_html(os.path.join(dir_name, 'choropleth.html')) From c6acb91b757b7fc6430b66a01ea968857c0f0146 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 17:02:08 -0400 Subject: [PATCH 14/20] test --- test/percy/plotly-express.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index f8ef93944d1..43429bbb539 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -1,6 +1,7 @@ ## This script uses px functions to generate html figures, which will be ## tested with percy. +# this directory import os dir_name = os.path.join("test", "percy") From fa2c7e4048b3d2d503ef387a6f093cf09d827d60 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 17:06:00 -0400 Subject: [PATCH 15/20] typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 242189ef77a..1ed3c4dc0e6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,7 +108,7 @@ jobs: - run: name: Run percy snapshots command: | - npx percy snapshot tests/percy/ + npx percy snapshot test/percy/ rm test/percy/*.html # Optional From 4f859a7abc5fae4574990244405dc1df5936b3e6 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 17:10:04 -0400 Subject: [PATCH 16/20] make black happy --- test/percy/plotly-express.py | 394 +++++++++++++++++++++++++++-------- 1 file changed, 305 insertions(+), 89 deletions(-) diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 43429bbb539..99eae79f92e 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -3,227 +3,443 @@ # this directory import os + dir_name = os.path.join("test", "percy") import plotly.express as px -print(px.data.iris.__doc__) + +print (px.data.iris.__doc__) px.data.iris().head() # #### Scatter and Line plots import plotly.express as px + iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length") -fig.write_html(os.path.join(dir_name, 'scatter.html')) +fig.write_html(os.path.join(dir_name, "scatter.html")) import plotly.express as px + iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species") -fig.write_html(os.path.join(dir_name, 'scatter_color.html')) +fig.write_html(os.path.join(dir_name, "scatter_color.html")) import plotly.express as px + iris = px.data.iris() -fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="rug", marginal_x="histogram") -fig.write_html(os.path.join(dir_name, 'scatter_marginal.html')) +fig = px.scatter( + iris, + x="sepal_width", + y="sepal_length", + color="species", + marginal_y="rug", + marginal_x="histogram", +) +fig.write_html(os.path.join(dir_name, "scatter_marginal.html")) import plotly.express as px + iris = px.data.iris() -fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", marginal_y="violin", - marginal_x="box", trendline="ols") -fig.write_html(os.path.join(dir_name, 'scatter_trendline.html')) +fig = px.scatter( + iris, + x="sepal_width", + y="sepal_length", + color="species", + marginal_y="violin", + marginal_x="box", + trendline="ols", +) +fig.write_html(os.path.join(dir_name, "scatter_trendline.html")) import plotly.express as px + iris = px.data.iris() -iris["e"] = iris["sepal_width"]/100 -fig = px.scatter(iris, x="sepal_width", y="sepal_length", color="species", error_x="e", error_y="e") -fig.write_html(os.path.join(dir_name, 'scatter_errorbar.html')) +iris["e"] = iris["sepal_width"] / 100 +fig = px.scatter( + iris, x="sepal_width", y="sepal_length", color="species", error_x="e", error_y="e" +) +fig.write_html(os.path.join(dir_name, "scatter_errorbar.html")) import plotly.express as px + tips = px.data.tips() -fig = px.scatter(tips, x="total_bill", y="tip", facet_row="time", facet_col="day", color="smoker", trendline="ols", - category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) -fig.write_html(os.path.join(dir_name, 'scatter_categories.html')) +fig = px.scatter( + tips, + x="total_bill", + y="tip", + facet_row="time", + facet_col="day", + color="smoker", + trendline="ols", + category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}, +) +fig.write_html(os.path.join(dir_name, "scatter_categories.html")) import plotly.express as px + iris = px.data.iris() fig = px.scatter_matrix(iris) -fig.write_html(os.path.join(dir_name, 'scatter_matrix.html')) +fig.write_html(os.path.join(dir_name, "scatter_matrix.html")) import plotly.express as px + iris = px.data.iris() -fig = px.scatter_matrix(iris, dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], color="species") -fig.write_html(os.path.join(dir_name, 'scatter_matrix_dimensions.html')) +fig = px.scatter_matrix( + iris, + dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"], + color="species", +) +fig.write_html(os.path.join(dir_name, "scatter_matrix_dimensions.html")) import plotly.express as px + iris = px.data.iris() -fig = px.parallel_coordinates(iris, color="species_id", labels={"species_id": "Species", - "sepal_width": "Sepal Width", "sepal_length": "Sepal Length", - "petal_width": "Petal Width", "petal_length": "Petal Length", }, - color_continuous_scale=px.colors.diverging.Tealrose, color_continuous_midpoint=2) -fig.write_html(os.path.join(dir_name, 'parallel_coordinates.html')) +fig = px.parallel_coordinates( + iris, + color="species_id", + labels={ + "species_id": "Species", + "sepal_width": "Sepal Width", + "sepal_length": "Sepal Length", + "petal_width": "Petal Width", + "petal_length": "Petal Length", + }, + color_continuous_scale=px.colors.diverging.Tealrose, + color_continuous_midpoint=2, +) +fig.write_html(os.path.join(dir_name, "parallel_coordinates.html")) import plotly.express as px + tips = px.data.tips() -fig = px.parallel_categories(tips, color="size", color_continuous_scale=px.colors.sequential.Inferno) -fig.write_html(os.path.join(dir_name, 'parallel_categories.html')) +fig = px.parallel_categories( + tips, color="size", color_continuous_scale=px.colors.sequential.Inferno +) +fig.write_html(os.path.join(dir_name, "parallel_categories.html")) import plotly.express as px + tips = px.data.tips() -fig = px.scatter(tips, x="total_bill", y="tip", color="size", facet_col="sex", - color_continuous_scale=px.colors.sequential.Viridis, render_mode="webgl") -fig.write_html(os.path.join(dir_name, 'scatter_webgl.html')) +fig = px.scatter( + tips, + x="total_bill", + y="tip", + color="size", + facet_col="sex", + color_continuous_scale=px.colors.sequential.Viridis, + render_mode="webgl", +) +fig.write_html(os.path.join(dir_name, "scatter_webgl.html")) import plotly.express as px + gapminder = px.data.gapminder() -fig = px.scatter(gapminder.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", color="continent", - hover_name="country", log_x=True, size_max=60) -fig.write_html(os.path.join(dir_name, 'scatter_hover.html')) +fig = px.scatter( + gapminder.query("year==2007"), + x="gdpPercap", + y="lifeExp", + size="pop", + color="continent", + hover_name="country", + log_x=True, + size_max=60, +) +fig.write_html(os.path.join(dir_name, "scatter_hover.html")) import plotly.express as px + gapminder = px.data.gapminder() -fig = px.scatter(gapminder, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country", - size="pop", color="continent", hover_name="country", facet_col="continent", - log_x=True, size_max=45, range_x=[100,100000], range_y=[25,90]) -fig.write_html(os.path.join(dir_name, 'scatter_log.html')) +fig = px.scatter( + gapminder, + x="gdpPercap", + y="lifeExp", + animation_frame="year", + animation_group="country", + size="pop", + color="continent", + hover_name="country", + facet_col="continent", + log_x=True, + size_max=45, + range_x=[100, 100000], + range_y=[25, 90], +) +fig.write_html(os.path.join(dir_name, "scatter_log.html")) import plotly.express as px + gapminder = px.data.gapminder() -fig = px.line(gapminder, x="year", y="lifeExp", color="continent", line_group="country", hover_name="country", - line_shape="spline", render_mode="svg") -fig.write_html(os.path.join(dir_name, 'line.html')) +fig = px.line( + gapminder, + x="year", + y="lifeExp", + color="continent", + line_group="country", + hover_name="country", + line_shape="spline", + render_mode="svg", +) +fig.write_html(os.path.join(dir_name, "line.html")) import plotly.express as px + gapminder = px.data.gapminder() fig = px.area(gapminder, x="year", y="pop", color="continent", line_group="country") -fig.write_html(os.path.join(dir_name, 'area.html')) +fig.write_html(os.path.join(dir_name, "area.html")) # #### Visualize Distributions import plotly.express as px + iris = px.data.iris() fig = px.density_contour(iris, x="sepal_width", y="sepal_length") -fig.write_html(os.path.join(dir_name, 'density_contour.html')) +fig.write_html(os.path.join(dir_name, "density_contour.html")) import plotly.express as px + iris = px.data.iris() -fig = px.density_contour(iris, x="sepal_width", y="sepal_length", color="species", marginal_x="rug", marginal_y="histogram") -fig.write_html(os.path.join(dir_name, 'density_contour_marginal.html')) +fig = px.density_contour( + iris, + x="sepal_width", + y="sepal_length", + color="species", + marginal_x="rug", + marginal_y="histogram", +) +fig.write_html(os.path.join(dir_name, "density_contour_marginal.html")) import plotly.express as px + iris = px.data.iris() -fig = px.density_heatmap(iris, x="sepal_width", y="sepal_length", marginal_x="rug", marginal_y="histogram") -fig.write_html(os.path.join(dir_name, 'density_heatmap.html')) +fig = px.density_heatmap( + iris, x="sepal_width", y="sepal_length", marginal_x="rug", marginal_y="histogram" +) +fig.write_html(os.path.join(dir_name, "density_heatmap.html")) import plotly.express as px + tips = px.data.tips() fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group") -fig.write_html(os.path.join(dir_name, 'bar.html')) +fig.write_html(os.path.join(dir_name, "bar.html")) import plotly.express as px + tips = px.data.tips() -fig = px.bar(tips, x="sex", y="total_bill", color="smoker", barmode="group", facet_row="time", facet_col="day", - category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) -fig.write_html(os.path.join(dir_name, 'bar_facet.html')) +fig = px.bar( + tips, + x="sex", + y="total_bill", + color="smoker", + barmode="group", + facet_row="time", + facet_col="day", + category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}, +) +fig.write_html(os.path.join(dir_name, "bar_facet.html")) import plotly.express as px + tips = px.data.tips() -fig = px.histogram(tips, x="total_bill", y="tip", color="sex", marginal="rug", hover_data=tips.columns) -fig.write_html(os.path.join(dir_name, 'histogram.html')) +fig = px.histogram( + tips, x="total_bill", y="tip", color="sex", marginal="rug", hover_data=tips.columns +) +fig.write_html(os.path.join(dir_name, "histogram.html")) import plotly.express as px + tips = px.data.tips() -fig = px.histogram(tips, x="sex", y="tip", histfunc="avg", color="smoker", barmode="group", - facet_row="time", facet_col="day", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], - "time": ["Lunch", "Dinner"]}) -fig.write_html(os.path.join(dir_name, 'histogram_histfunc.html')) +fig = px.histogram( + tips, + x="sex", + y="tip", + histfunc="avg", + color="smoker", + barmode="group", + facet_row="time", + facet_col="day", + category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}, +) +fig.write_html(os.path.join(dir_name, "histogram_histfunc.html")) import plotly.express as px + tips = px.data.tips() fig = px.strip(tips, x="total_bill", y="time", orientation="h", color="smoker") -fig.write_html(os.path.join(dir_name, 'strip.html')) +fig.write_html(os.path.join(dir_name, "strip.html")) import plotly.express as px + tips = px.data.tips() fig = px.box(tips, x="day", y="total_bill", color="smoker", notched=True) -fig.write_html(os.path.join(dir_name, 'box.html')) +fig.write_html(os.path.join(dir_name, "box.html")) import plotly.express as px + tips = px.data.tips() -fig = px.violin(tips, y="tip", x="smoker", color="sex", box=True, points="all", hover_data=tips.columns) -fig.write_html(os.path.join(dir_name, 'violin.html')) +fig = px.violin( + tips, + y="tip", + x="smoker", + color="sex", + box=True, + points="all", + hover_data=tips.columns, +) +fig.write_html(os.path.join(dir_name, "violin.html")) # #### Ternary Coordinates import plotly.express as px + election = px.data.election() -fig = px.scatter_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", size="total", hover_name="district", - size_max=15, color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"} ) -fig.write_html(os.path.join(dir_name, 'scatter_ternary.html')) +fig = px.scatter_ternary( + election, + a="Joly", + b="Coderre", + c="Bergeron", + color="winner", + size="total", + hover_name="district", + size_max=15, + color_discrete_map={"Joly": "blue", "Bergeron": "green", "Coderre": "red"}, +) +fig.write_html(os.path.join(dir_name, "scatter_ternary.html")) import plotly.express as px + election = px.data.election() -fig = px.line_ternary(election, a="Joly", b="Coderre", c="Bergeron", color="winner", line_dash="winner") -fig.write_html(os.path.join(dir_name, 'line_ternary.html')) +fig = px.line_ternary( + election, a="Joly", b="Coderre", c="Bergeron", color="winner", line_dash="winner" +) +fig.write_html(os.path.join(dir_name, "line_ternary.html")) # #### 3D Coordinates import plotly.express as px + election = px.data.election() -fig = px.scatter_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", size="total", hover_name="district", - symbol="result", color_discrete_map = {"Joly": "blue", "Bergeron": "green", "Coderre":"red"}) -fig.write_html(os.path.join(dir_name, 'scatter_3d.html')) +fig = px.scatter_3d( + election, + x="Joly", + y="Coderre", + z="Bergeron", + color="winner", + size="total", + hover_name="district", + symbol="result", + color_discrete_map={"Joly": "blue", "Bergeron": "green", "Coderre": "red"}, +) +fig.write_html(os.path.join(dir_name, "scatter_3d.html")) import plotly.express as px + election = px.data.election() -fig = px.line_3d(election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner") -fig.write_html(os.path.join(dir_name, 'line_3d.html')) +fig = px.line_3d( + election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner" +) +fig.write_html(os.path.join(dir_name, "line_3d.html")) # #### Polar Coordinates import plotly.express as px + wind = px.data.wind() -fig = px.scatter_polar(wind, r="frequency", theta="direction", color="strength", symbol="strength", - color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) -fig.write_html(os.path.join(dir_name, 'scatter_polar.html')) +fig = px.scatter_polar( + wind, + r="frequency", + theta="direction", + color="strength", + symbol="strength", + color_discrete_sequence=px.colors.sequential.Plasma[-2::-1], +) +fig.write_html(os.path.join(dir_name, "scatter_polar.html")) import plotly.express as px + wind = px.data.wind() -fig = px.line_polar(wind, r="frequency", theta="direction", color="strength", line_close=True, - color_discrete_sequence=px.colors.sequential.Plasma[-2::-1]) -fig.write_html(os.path.join(dir_name, 'line_polar.html')) +fig = px.line_polar( + wind, + r="frequency", + theta="direction", + color="strength", + line_close=True, + color_discrete_sequence=px.colors.sequential.Plasma[-2::-1], +) +fig.write_html(os.path.join(dir_name, "line_polar.html")) import plotly.express as px + wind = px.data.wind() -fig = px.bar_polar(wind, r="frequency", theta="direction", color="strength", template="plotly_dark", - color_discrete_sequence= px.colors.sequential.Plasma[-2::-1]) -fig.write_html(os.path.join(dir_name, 'bar_polar.html')) +fig = px.bar_polar( + wind, + r="frequency", + theta="direction", + color="strength", + template="plotly_dark", + color_discrete_sequence=px.colors.sequential.Plasma[-2::-1], +) +fig.write_html(os.path.join(dir_name, "bar_polar.html")) # #### Maps import plotly.express as px + carshare = px.data.carshare() -fig = px.scatter_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour", size="car_hours", - color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, zoom=10) -fig.write_html(os.path.join(dir_name, 'scatter_mapbox.html')) +fig = px.scatter_mapbox( + carshare, + lat="centroid_lat", + lon="centroid_lon", + color="peak_hour", + size="car_hours", + color_continuous_scale=px.colors.cyclical.IceFire, + size_max=15, + zoom=10, +) +fig.write_html(os.path.join(dir_name, "scatter_mapbox.html")) import plotly.express as px + carshare = px.data.carshare() -fig = px.line_mapbox(carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour") -fig.write_html(os.path.join(dir_name, 'line_mapbox.html')) +fig = px.line_mapbox( + carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour" +) +fig.write_html(os.path.join(dir_name, "line_mapbox.html")) import plotly.express as px + gapminder = px.data.gapminder() -fig = px.scatter_geo(gapminder, locations="iso_alpha", color="continent", hover_name="country", size="pop", - animation_frame="year", projection="natural earth") -fig.write_html(os.path.join(dir_name, 'scatter_geo.html')) +fig = px.scatter_geo( + gapminder, + locations="iso_alpha", + color="continent", + hover_name="country", + size="pop", + animation_frame="year", + projection="natural earth", +) +fig.write_html(os.path.join(dir_name, "scatter_geo.html")) import plotly.express as px + gapminder = px.data.gapminder() -fig = px.line_geo(gapminder.query("year==2007"), locations="iso_alpha", color="continent", projection="orthographic") -fig.write_html(os.path.join(dir_name, 'line_geo.html')) +fig = px.line_geo( + gapminder.query("year==2007"), + locations="iso_alpha", + color="continent", + projection="orthographic", +) +fig.write_html(os.path.join(dir_name, "line_geo.html")) import plotly.express as px -gapminder = px.data.gapminder() -fig = px.choropleth(gapminder, locations="iso_alpha", color="lifeExp", hover_name="country", animation_frame="year", range_color=[20,80]) -fig.write_html(os.path.join(dir_name, 'choropleth.html')) +gapminder = px.data.gapminder() +fig = px.choropleth( + gapminder, + locations="iso_alpha", + color="lifeExp", + hover_name="country", + animation_frame="year", + range_color=[20, 80], +) +fig.write_html(os.path.join(dir_name, "choropleth.html")) From 3717b868d5b0f8c7bfaa98a2e9f2e634e9b0f9d9 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Sep 2019 22:04:37 -0400 Subject: [PATCH 17/20] typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ed3c4dc0e6..25583c16e04 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,7 +108,7 @@ jobs: - run: name: Run percy snapshots command: | - npx percy snapshot test/percy/ + npx percy snapshot test/percy/ rm test/percy/*.html # Optional From d61e9cd303773dc836f1801532ef7343324c752b Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Mon, 9 Sep 2019 09:33:55 -0400 Subject: [PATCH 18/20] removed 3d and mapbox percy tests --- test/percy/plotly-express.py | 48 ------------------------------------ 1 file changed, 48 deletions(-) diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 99eae79f92e..13da2c92370 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -314,31 +314,6 @@ ) fig.write_html(os.path.join(dir_name, "line_ternary.html")) -# #### 3D Coordinates - -import plotly.express as px - -election = px.data.election() -fig = px.scatter_3d( - election, - x="Joly", - y="Coderre", - z="Bergeron", - color="winner", - size="total", - hover_name="district", - symbol="result", - color_discrete_map={"Joly": "blue", "Bergeron": "green", "Coderre": "red"}, -) -fig.write_html(os.path.join(dir_name, "scatter_3d.html")) - -import plotly.express as px - -election = px.data.election() -fig = px.line_3d( - election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner" -) -fig.write_html(os.path.join(dir_name, "line_3d.html")) # #### Polar Coordinates @@ -385,29 +360,6 @@ import plotly.express as px -carshare = px.data.carshare() -fig = px.scatter_mapbox( - carshare, - lat="centroid_lat", - lon="centroid_lon", - color="peak_hour", - size="car_hours", - color_continuous_scale=px.colors.cyclical.IceFire, - size_max=15, - zoom=10, -) -fig.write_html(os.path.join(dir_name, "scatter_mapbox.html")) - -import plotly.express as px - -carshare = px.data.carshare() -fig = px.line_mapbox( - carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour" -) -fig.write_html(os.path.join(dir_name, "line_mapbox.html")) - -import plotly.express as px - gapminder = px.data.gapminder() fig = px.scatter_geo( gapminder, From 2652b7034cd02f963b939d046f7c673f60463b05 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Mon, 9 Sep 2019 10:46:53 -0400 Subject: [PATCH 19/20] Revert "removed 3d and mapbox percy tests" This reverts commit fb83b644bc168aed1f29795ea214939e0d0eb11d. --- test/percy/plotly-express.py | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 13da2c92370..99eae79f92e 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -314,6 +314,31 @@ ) fig.write_html(os.path.join(dir_name, "line_ternary.html")) +# #### 3D Coordinates + +import plotly.express as px + +election = px.data.election() +fig = px.scatter_3d( + election, + x="Joly", + y="Coderre", + z="Bergeron", + color="winner", + size="total", + hover_name="district", + symbol="result", + color_discrete_map={"Joly": "blue", "Bergeron": "green", "Coderre": "red"}, +) +fig.write_html(os.path.join(dir_name, "scatter_3d.html")) + +import plotly.express as px + +election = px.data.election() +fig = px.line_3d( + election, x="Joly", y="Coderre", z="Bergeron", color="winner", line_dash="winner" +) +fig.write_html(os.path.join(dir_name, "line_3d.html")) # #### Polar Coordinates @@ -360,6 +385,29 @@ import plotly.express as px +carshare = px.data.carshare() +fig = px.scatter_mapbox( + carshare, + lat="centroid_lat", + lon="centroid_lon", + color="peak_hour", + size="car_hours", + color_continuous_scale=px.colors.cyclical.IceFire, + size_max=15, + zoom=10, +) +fig.write_html(os.path.join(dir_name, "scatter_mapbox.html")) + +import plotly.express as px + +carshare = px.data.carshare() +fig = px.line_mapbox( + carshare, lat="centroid_lat", lon="centroid_lon", color="peak_hour" +) +fig.write_html(os.path.join(dir_name, "line_mapbox.html")) + +import plotly.express as px + gapminder = px.data.gapminder() fig = px.scatter_geo( gapminder, From b3d1011f49b9996207f188bd2b938850b97428f6 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Tue, 10 Sep 2019 16:37:02 -0400 Subject: [PATCH 20/20] toggled animation auto_play to False --- test/percy/plotly-express.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/percy/plotly-express.py b/test/percy/plotly-express.py index 99eae79f92e..7ca527efbb8 100644 --- a/test/percy/plotly-express.py +++ b/test/percy/plotly-express.py @@ -165,7 +165,7 @@ range_x=[100, 100000], range_y=[25, 90], ) -fig.write_html(os.path.join(dir_name, "scatter_log.html")) +fig.write_html(os.path.join(dir_name, "scatter_log.html"), auto_play=False) import plotly.express as px @@ -418,7 +418,7 @@ animation_frame="year", projection="natural earth", ) -fig.write_html(os.path.join(dir_name, "scatter_geo.html")) +fig.write_html(os.path.join(dir_name, "scatter_geo.html"), auto_play=False) import plotly.express as px @@ -442,4 +442,4 @@ animation_frame="year", range_color=[20, 80], ) -fig.write_html(os.path.join(dir_name, "choropleth.html")) +fig.write_html(os.path.join(dir_name, "choropleth.html"), auto_play=False)