Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Theming chapter#28

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jonmmease merged 9 commits intomasterfromtemplates
Jun 27, 2019
Merged

Theming chapter#28

jonmmease merged 9 commits intomasterfromtemplates
Jun 27, 2019

Conversation

jonmmease
Copy link
Contributor

@jonmmeasejonmmease commentedJun 22, 2019
edited
Loading

Here is the initial draft of the theming chapter for the v4 docs.

cc@nicolaskruchten@emmanuelle@chriddyp

Closeshttps://github.com/plotly/plotly.py-docs/issues/7


Doc upgrade checklist:

  • Every example is independently runnable and is optimized for short line count
  • no moreplot() oriplot()
  • graph_objs has been renamed tograph_objects
  • fig = <something> call is high up in each example
  • minimal creation of intermediatetrace objects
  • liberal use ofadd_trace andupdate_layout
  • fig.show() at the end of each example
  • px example at the top if appropriate
  • v4upgrade: true metadata added
  • minimize usage of hex codes for colors in favour of those inhttps://github.com/plotly/plotly.py-docs/issues/14

From this, we can see that the default theme is `"plotly"`, and we can see the names of several additional themes that we can choose from.


### Specifying themes to plotly express
Copy link
Contributor

Choose a reason for hiding this comment

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

"in" rather than "to" ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

).show()
```

### Specifying themes to graph object figures
Copy link
Contributor

Choose a reason for hiding this comment

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

"in" rather than "to" ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

layout=go.Layout(dict(title=dict(font=dict(family="Rockwell", size=24))))
)

(go.Figure()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should usefig = andfig.show() for consistency

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

))

for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "none"]:
fig.update_layout(template=template, title="Mt Bruno Elevation: '%s' theme" % template).show()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should usefig.update_layout() andfig.show() for consistency

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

gapminder_2007 = gapminder.query("year==2007")

for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "none"]:
px.scatter(gapminder_2007,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should usefig = andfig.show() for consistency

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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



### Specifying themes to plotly express
All plotly express functions accept a `template` argument that can be set to the name of a registered theme. Here is an example of using plotly express to build and display the same scatter plot with five different themes.
Copy link
Contributor

Choose a reason for hiding this comment

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

you can actually pass in a fulltemplate as well, not just a name.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

👍

@nicolaskruchten
Copy link
Contributor

Looks great! For consistency I would stay away from method-chaining too much and actually assignfig= and then callfig.show() explicitly everywhere (I didn't comment each instance!)

v4upgrade: true
---

# Theming
Copy link
Member

Choose a reason for hiding this comment

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

maybe we call this chapter “theming and templates” just to reiterate that it’s not just about the “style” of the graph (themes) but really any chart defaults (templates).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

👍 I changed the title and added a terminology note in388b59a

import plotly.graph_objects as go

large_rockwell_template = go.layout.Template(
layout=go.Layout(dict(title=dict(font=dict(family="Rockwell", size=24))))
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to use the magic underscore here, liketitle_font=dict(..) ? (and to add a comment about it)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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



### Theming array properties
Some properties in the figure hierarchy are specified as arrays of objects. For example, the text annotations for a graph object figure are stored as a tuple of `go.layout.Annotation` objects in the `annotations` property of the figure's layout.
Copy link
Contributor

Choose a reason for hiding this comment

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

For mearray means numerical arrays like NumPy's. Why not iterable object instead?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fair enough 🙂 I changed "array" -> "tuple" in these sections in81c774b. "tuple" instead of "list" because the graph objects represent these as tuples to the user.

@emmanuelle
Copy link
Contributor

Awesome, thanks :-).

@jonmmease
Copy link
ContributorAuthor

stay away from method chaining
👍85e24bc

@jonmmease
Copy link
ContributorAuthor

Thanks for the quick comments all. I think I've made all of the associated updates.

@jonmmeasejonmmease changed the titleInitial draft of theming chapterTheming chapterJun 24, 2019
fig.show()
```

<!-- #region -->
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this "region" thing do?


> Note: this example uses magic underscore notation to write `go.layout.Template(layout=dict(annotations=[...]))` as ``go.layout.Template(layout_annotations=[...])`

It is also possible to set your own custom template as the default so that you do not need to pass it by name when constructing graph object figures or calling plotly express functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Github's syntax highlighting is confused about this block... does it render OK in Jupyter?

@nicolaskruchten
Copy link
Contributor

💃 let's merge it!

@jonmmeasejonmmease merged commit9d52eb2 intomasterJun 27, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolaskruchtennicolaskruchtennicolaskruchten left review comments

@emmanuelleemmanuelleemmanuelle left review comments

@chriddypchriddypchriddyp approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Templates
4 participants
@jonmmease@nicolaskruchten@emmanuelle@chriddyp

[8]ページ先頭

©2009-2025 Movatter.jp