Skip to content

Updates to examples in fundamentals section #2201

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

Merged
merged 6 commits into from
Apr 6, 2020
Merged

Conversation

jdamiba
Copy link

@jdamiba jdamiba commented Feb 14, 2020

The purpose of this PR is to update 3 of our examples.

@jdamiba jdamiba changed the title fixups to grammar and wording Updates to examples in fundamentals section Feb 14, 2020

Instead, pass your figure as the `figure` parameter to the `dcc.Graph` component.

```python
Copy link
Contributor

Choose a reason for hiding this comment

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

does this actually work here? I would think you'd need to escape this block somehow so it doesn't actually execute :)


Here is an example of creating a figure with two scatter traces in side-by-side subplots.
This function accepts two integer parameters (`rows` and `cols`), which specifiy how the subplots should be laid out.
Copy link
Contributor

Choose a reason for hiding this comment

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

this is probably misleading, as this function accepts many other parameters as well...

@@ -203,9 +205,9 @@ fig.show()
```

#### Customizing Subplot Axes
After a figure with subplots is created using the `make_subplots` function, its axis properties (title, font, range, grid style, etc.) can be customized using the `update_xaxes` and `update_yaxes` graph object figure methods. By default, these methods apply to all of the x axes or y axes in the figure. The `row` and `col` arguments can be used to control which axes are targeted by the update.
After a figure with subplots is created using the `make_subplots()` function, its axis properties (title, font, range, grid style, etc.) can be customized using the `update_xaxes` and `update_yaxes` graph object figure methods. By default, these methods apply to all of the `x` axes or `y` axes in the figure. The `row` and `col` arguments can be used to control which axes are targeted by the update.
Copy link
Contributor

Choose a reason for hiding this comment

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

why put x and y in backticks here?

@@ -354,7 +355,7 @@ fig.show()
```

#### Subplots Types
By default, the `make_subplots` function assumes that the traces that will be added to all subplots are 2-dimensional cartesian traces (e.g. `scatter`, `bar`, `histogram`, `violin`, etc.). Traces with other subplot types (e.g. `scatterpolar`, `scattergeo`, `parcoords`, etc.) are supporteed by specifying the `type` subplot option in the `specs` argument to `make_subplots`.
By default, the `make_subplots()` function assumes that the traces that will be added to all subplots are 2-dimensional cartesian traces (e.g. `scatter`, `bar`, `histogram`, `violin`, etc.). Traces with other subplot types (e.g. `scatterpolar`, `scattergeo`, `parcoords`, etc.) are supporteed by specifying the `type` subplot option in the `specs` argument to `make_subplots`.
Copy link
Contributor

Choose a reason for hiding this comment

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

in general, I don't really agree with putting the () after the function name everywhere (this comment applies to this whole PR btw). The function is properly named make_subplots and calling it with no parameters like make_subplots() will probably result in an error. It's probably OK to use this for something like "the .show() method" as that actually will work with no arguments.

Also note: maybe we haven't used it super consistently, but the leading . in "the .show() method" is actually informative IMO in that it reminds the reader that show isn't a free function but a method of a figure. As a matter of style we could say "the fig.show method" or "the .show method of every go.Figure object" or something.

In any case, unless you're going to fully standardize the usage of this kind of thing throughout the docs, I find it pretty distracting and hard to review changes like this :)

@@ -171,18 +175,17 @@ fig.show(renderer="png")
```

###### `pdf`
This renderer displays figures as static PDF files. This is especially useful for notebooks that will be exported to PDF files using the LaTeX export capabilities of nbconvert.
This renderer displays figures as static `.pdf` files. This is especially useful for notebooks that will be exported to `.pdf` files using the `LaTeX` export capabilities of `nbconvert`.
Copy link
Contributor

Choose a reason for hiding this comment

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

here the usage of backticks is questionable also... "static PDF files" is acceptable, no? It's not clear why "static .pdf files" is clearer or better :)


> Note: Adding the Plotly.js bundle to the notebook does add a few megabytes to the notebook size, so if you can count on having an internet connection you may want to consider the `notebook_connected` renderer.
> Note: Adding the `plotly.js` bundle to the notebook adds a few megabytes to the notebook size. If you can count on always having an Internet connection, you may want to consider using the `notebook_connected` renderer if notebook size is a constraint.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should backtick "plotly.js" ...

3. Using a `FigureWidget` in an ipywidgets context
In general, there are three different approaches you can take in order to display figures:

1. Using the `renderers` framework in the context of a script or notebook
Copy link
Contributor

Choose a reason for hiding this comment

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

Here also I think the usage of backticks for renderers is going a bit too far IMO...


`go` figures also support `update_layout_images` in order to [update background layout images](/python/images/), `update_annotations` in order to [update annotations](/python/text-and-annotations/#multiple-annotations), and `update-shapes` in order to [update shapes](/python/shapes/).
Figures created with the `plotly.graph_objects` module also support:
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't totally correct: all figures support this, including those created with make_subplots and PX...

@nicolaskruchten
Copy link
Contributor

As a general comment, I think the style rule around backticks could be something like "text that might reasonably end up being executed gets backticks"... this excludes LaTeX and "x axis" but includes nbconvert and .show and go.Figure and px.scatter ... thoughts?

@jdamiba
Copy link
Author

jdamiba commented Feb 17, 2020

@nicolaskruchten I agree with your style comments and think this is a good opportunity to standardize.

To summarize, if a piece of text is likely to be copied into a development environment, it should be styled with backticks. So variable names like fig and descriptions of method calls like fig.show(), .show(), and make_subplots should be in backticks.

File formats such as PDF and JPEG should not be in backticks.

What about package and library names like plotly.py, plotly.js or htmlwidgets? I think they should get backticks.

@jdamiba
Copy link
Author

jdamiba commented Feb 19, 2020

@nicolaskruchten Can you please take another look at this.

@@ -23,5 +23,4 @@ recommonmark
pathlib
python-frontmatter
datashader
pyarrow
cufflinks==0.17.3
pyarrow
Copy link
Contributor

Choose a reason for hiding this comment

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

this diff should not be in this PR: we need cufflinks installed

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll make the change and merge this

@nicolaskruchten nicolaskruchten merged commit 3f78485 into doc-prod Apr 6, 2020
@nicolaskruchten nicolaskruchten deleted the wording-fixups branch June 19, 2020 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants