Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add range_theta kwarg #1969

Merged
merged 3 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 34 additions & 39 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
- checkout
- run:
name: Install black
command: 'sudo pip install black'
command: "sudo pip install black"
- run:
name: Check formatting with black
command: 'black --check .'
command: "black --check ."

# Core
python-2.7-core:
Expand All @@ -25,10 +25,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py27-core'
command: "cd packages/python/plotly; tox -e py27-core"
no_output_timeout: 20m

python-3.5-core:
Expand All @@ -41,10 +41,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py35-core'
command: "cd packages/python/plotly; tox -e py35-core"
no_output_timeout: 20m

python-3.6-core:
Expand All @@ -57,10 +57,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py36-core'
command: "cd packages/python/plotly; tox -e py36-core"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious to know why you made these changes? In cases variables had to be interpreted within the strings? Asking only for my own enlightenment :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh umm I didn't intentionally change anything there! I must have an autoformatter

no_output_timeout: 20m

python-3.7-core:
Expand All @@ -73,10 +73,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py37-core'
command: "cd packages/python/plotly; tox -e py37-core"
no_output_timeout: 20m

python-3.7-percy:
Expand Down Expand Up @@ -122,14 +122,14 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Install npm dependencies
command: cd packages/python/plotly/plotly/tests/test_optional/test_jupyter && npm install
no_output_timeout: 20m
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py27-optional'
command: "cd packages/python/plotly; tox -e py27-optional"
no_output_timeout: 20m

python-3.5-optional:
Expand All @@ -142,14 +142,14 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Install npm dependencies
command: cd packages/python/plotly/plotly/tests/test_optional/test_jupyter && npm install
no_output_timeout: 20m
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py35-optional'
command: "cd packages/python/plotly; tox -e py35-optional"
no_output_timeout: 20m

python-3.6-optional:
Expand All @@ -162,14 +162,14 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Install npm dependencies
command: cd packages/python/plotly/plotly/tests/test_optional/test_jupyter && npm install
no_output_timeout: 20m
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py36-optional'
command: "cd packages/python/plotly; tox -e py36-optional"
no_output_timeout: 20m

python-3.7-optional:
Expand All @@ -182,14 +182,14 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Install npm dependencies
command: cd packages/python/plotly/plotly/tests/test_optional/test_jupyter && npm install
no_output_timeout: 20m
- run:
name: Test with tox
command: 'cd packages/python/plotly; tox -e py37-optional'
command: "cd packages/python/plotly; tox -e py37-optional"
no_output_timeout: 20m

# Plot.ly
Expand All @@ -203,10 +203,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/chart-studio; tox -e py27-plot_ly'
command: "cd packages/python/chart-studio; tox -e py27-plot_ly"
no_output_timeout: 20m

python-3.5-plot_ly:
Expand All @@ -219,10 +219,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/chart-studio; tox -e py35-plot_ly'
command: "cd packages/python/chart-studio; tox -e py35-plot_ly"
no_output_timeout: 20m

python-3.7-plot_ly:
Expand All @@ -235,10 +235,10 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install tox'
command: "sudo pip install tox"
- run:
name: Test with tox
command: 'cd packages/python/chart-studio; tox -e py37-plot_ly'
command: "cd packages/python/chart-studio; tox -e py37-plot_ly"
no_output_timeout: 20m

python-2-7-orca:
Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
pytest packages/python/plotly/plotly/tests/test_orca

- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed
path: plotly/tests/test_orca/images/linux/failed

python-3-5-orca:
docker:
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
pytest packages/python/plotly/plotly/tests/test_orca

- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed
path: plotly/tests/test_orca/images/linux/failed

python-3-7-orca:
docker:
Expand All @@ -325,12 +325,12 @@ jobs:
command: |
. /home/circleci/miniconda/etc/profile.d/conda.sh
conda activate circle_optional
pytest --doctest-modules --ignore packages/python/plotly/plotly/tests --ignore packages/python/plotly/plotly/matplotlylib/mplexporter/tests packages/python/plotly/plotly
pytest --doctest-modules --ignore packages/python/plotly/plotly/tests --ignore packages/python/plotly/plotly/matplotlylib/mplexporter/tests packages/python/plotly/plotly
pytest --disable-warnings packages/python/plotly/plotly/tests/test_core
pytest packages/python/plotly/plotly/tests/test_orca

- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed
path: plotly/tests/test_orca/images/linux/failed

plotlyjs_dev_build:
docker:
Expand All @@ -343,13 +343,13 @@ jobs:
- checkout
- run:
name: Install tox
command: 'sudo pip install retrying tox black inflect'
command: "sudo pip install retrying tox black inflect"
- run:
name: Update jupyterlab-plotly version
command: 'cd packages/python/plotly; python setup.py updateplotlywidgetversion'
command: "cd packages/python/plotly; python setup.py updateplotlywidgetversion"
- run:
name: Update plotly.js to dev
command: 'cd packages/python/plotly; python setup.py updateplotlyjsdev'
command: "cd packages/python/plotly; python setup.py updateplotlyjsdev"
- run:
name: Test with tox
command: |
Expand Down Expand Up @@ -385,15 +385,13 @@ jobs:
- store_artifacts:
path: packages/python/plotly/dist


build-doc:
resource_class: xlarge
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.8-node


working_directory: ~/project

steps:
Expand All @@ -419,12 +417,12 @@ jobs:
npm install [email protected]
npm install orca
pip install -r requirements.txt
if [ "${CIRCLE_BRANCH}" == "master" ]; then
if [ "${CIRCLE_BRANCH}" != "doc-prod" ]; then
pip uninstall -y plotly
cd ../packages/python/plotly
python3 setup.py install
cd ../../../doc
fi
cd ../../../doc
fi
echo 'export PATH="/home/circleci/project/doc/node_modules/.bin:$PATH"' >> $BASH_ENV
sudo apt-get install -y poppler-utils libxtst6 xvfb libgtk2.0-0 libgconf-2-4 libnss3 libasound2
cd ..
Expand Down Expand Up @@ -484,12 +482,9 @@ jobs:

cd ../..


- store_artifacts:
path: doc/build
destination: doc/build



workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ plotly/tests/test_orca/images/*/tmp
/plotly-package/plotly/tests/test_core/test_offline/plotly.min.js
temp-plot.html
.vscode
doc/python/.ipynb_checkpoints
11 changes: 10 additions & 1 deletion doc/python/polar-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 polar charts in Python with Plotly.
display_as: scientific
Expand Down Expand Up @@ -75,6 +75,15 @@ fig.show()
See also the [wind rose page](https://plot.ly/python/wind-rose-charts/) for more wind rose visualizations in polar coordinates.


You can plot less than a whole circle with the `range_theta` argument, and also control the `start_angle` and `direction`:

```python
import plotly.express as px
fig = px.scatter_polar(r=range(0,90,10), theta=range(0,90,10),
range_theta=[0,90], start_angle=0, direction="counterclockwise")
fig.show()
```

## Polar Scatter Plot with go.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).
Expand Down
3 changes: 3 additions & 0 deletions packages/python/plotly/plotly/express/_chart_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ def scatter_polar(
start_angle=90,
size_max=None,
range_r=None,
range_theta=None,
log_r=False,
render_mode="auto",
title=None,
Expand Down Expand Up @@ -776,6 +777,7 @@ def line_polar(
line_shape=None,
render_mode="auto",
range_r=None,
range_theta=None,
log_r=False,
title=None,
template=None,
Expand Down Expand Up @@ -811,6 +813,7 @@ def bar_polar(
direction="clockwise",
start_angle=90,
range_r=None,
range_theta=None,
log_r=False,
title=None,
template=None,
Expand Down
3 changes: 3 additions & 0 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ def configure_polar_axes(args, fig, orders):
else:
if args["range_r"]:
radialaxis["range"] = args["range_r"]

if args["range_theta"]:
layout["polar"]["sector"] = args["range_theta"]
fig.update(layout=layout)


Expand Down
4 changes: 4 additions & 0 deletions packages/python/plotly/plotly/express/_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@
"list of two numbers",
"If provided, overrides auto-scaling on the radial axis in polar coordinates.",
],
range_theta=[
"list of two numbers",
"If provided, overrides auto-scaling on the angular axis in polar coordinates.",
],
title=["str", "The figure title."],
template=[
"or dict or plotly.graph_objects.layout.Template instance",
Expand Down