Skip to content

Commit 64a440d

Browse files
authored
Merge branch 'doc-prod' into patch-3
2 parents 7cafb62 + 0026a09 commit 64a440d

File tree

17,325 files changed

+827003
-620539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

17,325 files changed

+827003
-620539
lines changed

.circleci/config.yml

Lines changed: 230 additions & 247 deletions
Large diffs are not rendered by default.

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ below :-).
77
### Documentation PR
88
99
- [ ] I've [seen the `doc/README.md` file](https://github.com/plotly/plotly.py/blob/master/doc/README.md)
10-
- [ ] This change runs in the current version of Plotly on PyPI and targets the `doc-prod` branch OR it targets the `master` branch
10+
- [ ] This change runs in the current version of Plotly on PyPI and targets the `doc-prod` branch OR it targets the `main` branch
1111
- [ ] If this PR modifies the first example in a page or adds a new one, it is a `px` example if at all possible
1212
- [ ] Every new/modified example has a descriptive title and motivating sentence or paragraph
1313
- [ ] Every new/modified example is independently runnable
@@ -27,7 +27,7 @@ below :-).
2727
2828
## Code PR
2929
30-
- [ ] I have read through the [contributing notes](https://github.com/plotly/plotly.py/blob/master/contributing.md) and understand the structure of the package. In particular, if my PR modifies code of `plotly.graph_objects`, my modifications concern the `codegen` files and not generated files.
30+
- [ ] I have read through the [contributing notes](https://github.com/plotly/plotly.py/blob/master/CONTRIBUTING.md) and understand the structure of the package. In particular, if my PR modifies code of `plotly.graph_objects`, my modifications concern the `codegen` files and not generated files.
3131
- [ ] I have added tests (if submitting a new feature or correcting a bug) or
3232
modified existing tests.
3333
- [ ] For a new feature, I have added documentation examples in an existing or

.gitignore

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0
2+
0.html
3+
iframe_figures/
4+
tests/test_orca/images/linux/failed/
5+
16
*.egg-info
27

38
*.pyc
@@ -6,8 +11,11 @@
611

712
*~
813

14+
doc/python/raw.githubusercontent.com/
15+
916
# Don't ignore dataset files
1017
!*.csv.gz
18+
!*.geojson.gz
1119

1220
*.ipynb
1321

@@ -38,17 +46,20 @@ build
3846
dist
3947
plotly.egg-info/
4048

41-
plotly/tests/test_orca/images/*/failed
42-
plotly/tests/test_orca/images/*/tmp
43-
/plotly-package/plotly/tests/test_core/test_offline/plotly.min.js
49+
# macOS utility file
50+
**/.DS_Store
51+
52+
tests/test_orca/images/*/failed
53+
tests/test_orca/images/*/tmp
54+
tests/test_core/test_offline/plotly.min.js
4455
temp-plot.html
4556
.vscode
4657
doc/python/.ipynb_checkpoints
4758
doc/python/.mapbox_token
4859
doc/.ipynb_checkpoints
4960
tags
5061
doc/check-or-enforce-order.py
62+
plotly/package_data/widgetbundle.js
5163

52-
packages/javascript/jupyterlab-plotly/lib/
53-
packages/python/plotly/jupyterlab_plotly/labextension/
54-
packages/python/plotly/jupyterlab_plotly/nbextension/index.js*
64+
tests/percy/*.html
65+
tests/percy/pandas2/*.html

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 315 additions & 2 deletions
Large diffs are not rendered by default.

CITATION.cff

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cff-version: 1.2.0
2+
message: "If you use this software, please cite it as below."
3+
authors:
4+
- family-names: "Kruchten"
5+
given-names: "Nicolas"
6+
orcid: https://orcid.org/0000-0002-8416-789X
7+
- family-names: "Seier"
8+
given-names: "Andrew"
9+
- family-names: "Parmer"
10+
given-names: "Chris"
11+
title: "An interactive, open-source, and browser-based graphing library for Python"
12+
version: 5.24.1
13+
doi: 10.5281/zenodo.14503524
14+
date-released: 2024-09-12
15+
url: "https://github.com/plotly/plotly.py"

CONTRIBUTING.md

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing to plotly.py! We are actively looking for
4+
diverse contributors, with diverse background and skills.
5+
6+
This guide starts with a general description of the different ways to contribute
7+
to plotly.py, then we explain some technical aspects of preparing your
8+
contribution.
9+
10+
## Code of Conduct
11+
12+
Please check out the [Code of Conduct](CODE_OF_CONDUCT.md). Don't skip it,
13+
but the general idea is to be nice.
14+
15+
## What are the different ways to contribute?
16+
17+
There are many ways to contribute to plotly.py. To contribute effectively, it is important to first gain an understanding of the structure of the code and of the repository.
18+
19+
- [the `plotly.graph_objects` module](https://plotly.com/python/graph-objects/) (usually imported as `go`)
20+
is [generated from the Plotly.js schema](https://plotly.com/python/figure-structure/),
21+
so changes to be made in this package need to be
22+
[contributed to Plotly.js](https://github.com/plotly/plotly.js) or to the `codegen` system
23+
in `codegen/`. Most of the codegen code concerns the generation of docstrings from
24+
the schema JSON in Plotly.js. Traces and
25+
Layout classes have a direct correspondence with their Javascript
26+
counterpart. Higher-level methods that work on figures regardless of the current schema (e.g., `BaseFigure.for_each_trace`) are defined in `plotly/basedatatypes.py`. Additional helper methods are defined there for the `Figure` object, such as
27+
`update_layout`, `add_trace`, etc.
28+
29+
- [the `plotly.express` module](https://plotly.com/python/plotly-express/) (usually imported as `px`) is a high-level
30+
functional API that uses `graph_objects` under the hood. Its code is in `plotly/express/`.
31+
Plotly Express functions
32+
are designed to be highly consistent with each other, and to do *as little computation
33+
in Python as possible*, generally concerning themselves with formatting data and creating
34+
figures out of `plotly.graph_objects` instances. Most
35+
functions of `plotly.express` call the same internal `_make_figure` function
36+
in `_core.py`. More generally, the internals of `px` consist of general
37+
functions taking care of building the figure (defining subplots, traces
38+
or frames, for example), with special cases for different traces handled
39+
within these functions. There is also subsequent code reuse for `px`
40+
docstrings, in particular for documenting parameters.
41+
42+
- [the `plotly.figure_factory` module](https://plotly.com/python/figure-factories/) (usually imported as `ff`)
43+
provides Python "recipes" for building
44+
advanced visualizations with involved computation done in Python, such as
45+
Hexbin maps, ternary contour plots, etc.
46+
Figure factories are one of the easiest entry points into contributing to plotly.py, since
47+
they consist of Python-only code, with standalone, well-separated functions.
48+
However, please note that some of the figure factories become less relevant
49+
as we are introducing more features into `plotly.express`. Some issues in the
50+
tracker are labeled "figure_factory" and can be good issues to work on. More
51+
instructions on figure factories are found
52+
[here](plotly/figure_factory/README.md).
53+
54+
- other pure-Python submodules are: `plotly.io` (low-level interface for
55+
displaying, reading and writing figures), `plotly.subplots` (helper function
56+
for layout of multi-plot figures)
57+
58+
- tests are found in `plotly/tests`. Different
59+
directories correspond to different test jobs (with different dependency sets)
60+
run in continuous integration. More is explained about tests
61+
in the following "Technical aspects" section.
62+
63+
- the **documentation** is part of this repository. Its structure and some
64+
explanations are described [here](doc/README.md). The documentation, in
65+
particular example-based tutorials, is a great place to start contributing.
66+
The contribution process is also more lightweight, since you can modify
67+
tutorial notebooks without setting up an environment, etc.
68+
We maintain a wishlist of examples to add on
69+
https://github.com/plotly/plotly.py/issues/1965. If you have writing skills,
70+
the wording of existing examples can also be improved in places.
71+
72+
Contributing code or documentation is not the only way to contribute! You can
73+
also contribute to the project by
74+
75+
- reporting bugs (see below).
76+
77+
- submitting feature requests (maybe we'll convince you to contribute it as a
78+
pull request!).
79+
80+
- helping other users on the [community forum](https://community.plot.ly/).
81+
Join the list of [nice people](https://community.plot.ly/u) helping other
82+
plotly users :-).
83+
84+
We also recommend reading the great
85+
[how to contribute to open source](https://opensource.guide/how-to-contribute/)
86+
guide.
87+
88+
## Have a Bug Report?
89+
90+
Open an issue! Go to https://github.com/plotly/plotly.py/issues. It's possible that your issue was already addressed. If it wasn't, open it. We also accept pull requests; take a look at the steps below for instructions on how to do this.
91+
92+
## Have Questions about Plotly?
93+
94+
Check out our Community Forum: https://community.plot.ly/.
95+
96+
## Want to improve the plotly documentation?
97+
98+
Thank you! Instructions on how to contribute to the documentation are given [here](doc/README.md). Please also read the next section if you need to setup a development environment.
99+
100+
## How to contribute - Technical Aspects
101+
102+
Below we explain the technical aspects of contributing. It is not strictly necessary to follow all points (for example, you will not write tests when writing documentation, most of the time), but we want to make sure that you know how to deal with most cases.
103+
104+
Note that if you are modifying a single documentation page, you can do it
105+
directly on Github by clicking on the "Edit this page on GitHub" link, without
106+
cloning the repository.
107+
108+
## Setup a Development Environment
109+
110+
### Fork, Clone, Setup Your Version of the Plotly Python API
111+
112+
First, you'll need to *get* our project. This is the appropriate *clone* command (if you're unfamiliar with this process, https://help.github.com/articles/fork-a-repo):
113+
114+
**DO THIS (in the directory where you want the repo to live)**
115+
116+
```bash
117+
git clone https://github.com/your_github_username/plotly.py.git
118+
cd plotly.py
119+
```
120+
121+
Note: if you're just getting started with git, there exist great resources to
122+
learn and become confident about git, like http://try.github.io/.
123+
124+
### Create a virtual environment for plotly development
125+
126+
You can use either [conda][conda-env] or [virtualenv][virtualenv] to create a virtual environment for plotly development, e.g.:
127+
128+
```bash
129+
conda create -n plotly-dev python=3.11
130+
conda activate plotly-dev
131+
```
132+
133+
As of May 2024 our dependencies have been tested against Python versions 3.8 to 3.11.
134+
We will support Python 3.12 and higher versions soon.
135+
136+
[conda-env]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands
137+
[virtualenv]: http://docs.python-guide.org/en/latest/dev/virtualenvs/
138+
139+
### Install development requirements (Non-Windows)
140+
```bash
141+
(plotly_dev) $ pip install -r requires-optional.txt
142+
```
143+
### Install development requirements (Windows + Conda)
144+
Because Windows requires Visual Studio libraries to compile some of the optional dependencies, follow these steps to
145+
complete installation and avoid gdal-config errors.
146+
147+
```bash
148+
(plotly_dev) $ conda install fiona
149+
(plotly_dev) $ pip install -r requires-optional.txt
150+
```
151+
152+
### Editable install of plotly packages
153+
```bash
154+
(plotly_dev) $ pip install -e .
155+
```
156+
157+
**Note**: To test `go.FigureWidget` locally, you'll need to generate the javascript bundle as follows:
158+
```
159+
cd js
160+
npm install && npm run build
161+
```
162+
163+
Running `pip install -e` will ensure that the installed packages links to your local development
164+
directory, meaning that all changes you make reflect directly in your
165+
environment (don't forget to restart the Jupyter kernel though!). For more
166+
information see the
167+
[`setuptools`](https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode)
168+
and
169+
[`pip`](https://pip.pypa.io/en/stable/reference/pip_install/#install-editable)
170+
documentation on _development mode_.
171+
172+
### Configure black code formatting
173+
174+
This repo uses the [Black](https://black.readthedocs.io/en/stable/) code formatter,
175+
and the [pre-commit](https://pre-commit.com/) library to manage a git commit hook to
176+
run Black prior to each commit. Both pre-commit and black are included in the
177+
`requires-optional.txt` file, so you should have them
178+
installed already if you've been following along.
179+
180+
To enable the Black formatting git hook, run the following from within your virtual
181+
environment.
182+
183+
```bash
184+
(plotly_dev) $ pre-commit install
185+
```
186+
187+
Now, whenever you perform a commit, the Black formatter will run. If the formatter
188+
makes no changes, then the commit will proceed. But if the formatter does make changes,
189+
then the commit will abort. To proceed, stage the files that the formatter
190+
modified and commit again.
191+
192+
If you don't want to use `pre-commit`, then you can run black manually prior to making
193+
a PR as follows.
194+
195+
```bash
196+
(plotly_dev) $ black .
197+
```
198+
199+
### Making a Development Branch
200+
201+
Third, *don't* work in the `main` branch. As soon as you get your main branch ready, run:
202+
203+
**DO THIS (but change the branch name)**
204+
```bash
205+
git checkout -b my-dev-branch
206+
```
207+
208+
... where you should give your branch a more descriptive name than `my-dev-branch`
209+
210+
### Pull Request When Ready
211+
212+
Once you've made your changes (and hopefully written some tests, see below for more about testing...),
213+
make that pull request!
214+
215+
216+
## Update to a new version of Plotly.js
217+
First update the version of the `plotly.js` dependency in `js/package.json`.
218+
219+
Then run the `updateplotlyjs` command with:
220+
221+
```bash
222+
$ python commands.py updateplotlyjs
223+
```
224+
225+
This will download new versions of `plot-schema.json` and `plotly.min.js` from
226+
the `plotly/plotly.js` GitHub repository (and place them in
227+
`plotly/package_data`). It will then regenerate all of the `graph_objs`
228+
classes based on the new schema.
229+
230+
For dev branches, it is also possible to use `updateplotlyjsdev` in two configurations:
231+
232+
### CircleCI Release
233+
234+
If your devbranch is part of the official plotly.js repository, you can use
235+
```bash
236+
python commands.py updateplotlyjsdev --devrepo reponame --devbranch branchname
237+
```
238+
to update to development versions of `plotly.js`. This will fetch the `plotly.js` in the CircleCI artifact of the branch `branchname` of the repo `reponame`. If `--devrepo` or `--devbranch` are omitted, `updateplotlyjsdev` defaults using `plotly/plotly.js` and `master` respectively.
239+
240+
### Local Repository
241+
242+
If you have a local repository of `plotly.js` you'd like to try, you can run:
243+
244+
```bash
245+
# In your plotly.js/ directory, prepare the package:
246+
247+
$ npm run build
248+
$ npm pack
249+
$ mv plotly.js-*.tgz plotly.js.tgz
250+
251+
# In your plotly.py/ directory:
252+
$ python commands.py updateplotlyjsdev --local /path/to/your/plotly.js/
253+
```
254+
255+
## Testing
256+
257+
To run tests, we use [`pytest`](https://docs.pytest.org/en/latest/), a powerful framework for unit testing.
258+
259+
### Running Tests with `pytest`
260+
261+
Since our tests cover *all* the functionality, to prevent tons of errors from showing up and having to parse through a messy output, you'll need to install `requires-optional.txt` as explained above.
262+
263+
After you've done that, go ahead and run the test suite!
264+
265+
```bash
266+
pytest tests/
267+
```
268+
269+
Or for more *verbose* output:
270+
271+
```bash
272+
pytest -v tests/
273+
```
274+
275+
Either of those will run *every* test we've written for the Python API. You can get more granular by running something like:
276+
277+
```bash
278+
pytest tests/test_core/
279+
```
280+
281+
... or even more granular by running something like:
282+
283+
```bash
284+
pytest tests/test_plotly/test_plot.py
285+
```
286+
287+
or for a specific test function
288+
289+
```bash
290+
pytest tests/test_plotly/test_plot.py::test_function
291+
```
292+
293+
### Writing Tests
294+
295+
You're *strongly* encouraged to write tests that check your added functionality.
296+
297+
When you write a new test anywhere under the `tests` directory, if your PR gets accepted, that test will run in a virtual machine to ensure that future changes don't break your contributions!

LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2016-2018 Plotly, Inc
3+
Copyright (c) 2016-2024 Plotly Technologies Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)