- Notifications
You must be signed in to change notification settings - Fork1
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
notebooks/templates.md Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"in" rather than "to" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
).show() | ||
``` | ||
### Specifying themes to graph object figures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"in" rather than "to" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
layout=go.Layout(dict(title=dict(font=dict(family="Rockwell", size=24)))) | ||
) | ||
(go.Figure() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
)) | ||
for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "none"]: | ||
fig.update_layout(template=template, title="Mt Bruno Elevation: '%s' theme" % template).show() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
gapminder_2007 = gapminder.query("year==2007") | ||
for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "none"]: | ||
px.scatter(gapminder_2007, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
### 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
Uh oh!
There was an error while loading.Please reload this page.
Looks great! For consistency I would stay away from method-chaining too much and actually assign |
notebooks/templates.md Outdated
v4upgrade: true | ||
--- | ||
# Theming |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
notebooks/templates.md Outdated
import plotly.graph_objects as go | ||
large_rockwell_template = go.layout.Template( | ||
layout=go.Layout(dict(title=dict(font=dict(family="Rockwell", size=24)))) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
notebooks/templates.md Outdated
### 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Awesome, thanks :-). |
|
Thanks for the quick comments all. I think I've made all of the associated updates. |
fig.show() | ||
``` | ||
<!-- #region --> |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
💃 let's merge it! |
Uh oh!
There was an error while loading.Please reload this page.
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:
plot()
oriplot()
graph_objs
has been renamed tograph_objects
fig = <something>
call is high up in each exampletrace
objectsadd_trace
andupdate_layout
fig.show()
at the end of each examplepx
example at the top if appropriatev4upgrade: true
metadata added