-
Notifications
You must be signed in to change notification settings - Fork 1
Treemap python #138
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
Treemap python #138
Conversation
python/treemap-charts.md
Outdated
|
||
### Basic Treemap | ||
|
||
Treemap chart visualize hierarchical data using nested rectangles. Same as [Sunburst](https://plot.ly/python/sunburst-charts/) the hierarchy is defined by [labels](https://plot.ly/python/reference/#treemap-labels) and [parents]((https://plot.ly/python/reference/#treemap-parents)) attributes. [count](https://plot.ly/python/reference/#treemap-count) attribute allows counting the numbers of leaves, branches or both when values array is not provided. |
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.
Please add a link to Wikipedia https://en.wikipedia.org/wiki/Treemapping
python/treemap-charts.md
Outdated
fig.show() | ||
``` | ||
|
||
### Advance Treemap |
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.
Treemap with several nested layers
(this code is actually not very complex, so I suggest to drop the "advanced")
python/treemap-charts.md
Outdated
|
||
### Advance Treemap | ||
|
||
The following example uses hierarchical data that includes layers and grouping. Treemap and [Sunburst](https://plot.ly/python/sunburst-charts/) charts reveal indights into the data, and the format of your hierarchical data. |
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.
indights --> insights
python/treemap-charts.md
Outdated
|
||
fig = go.Figure() | ||
|
||
fig.add_trace(go.Treemap( |
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.
Could you use make_subplots
here instead of domain
? I think we're trying to push make_subplots
as the preferred method to create subplots (and then you can add subtitles for example).
python/treemap-charts.md
Outdated
|
||
### Set Different Attributes in Treemap | ||
|
||
This example uses the following attributs: |
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.
attributes
python/treemap-charts.md
Outdated
|
||
This example uses the following attributs: | ||
|
||
1. [values](https://plot.ly/python/reference/#treemap-values): sets the values associated with each of the sunburst sectors |
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.
with each of the sectors (remove suburst)
python/treemap-charts.md
Outdated
```python | ||
import plotly.graph_objects as go | ||
|
||
fig = go.Figure(go.Treemap( |
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.
same as below, could use make_subplots
?
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.
+1
python/treemap-charts.md
Outdated
### Basic Treemap | ||
|
||
Treemap chart visualize hierarchical data using nested rectangles. Same as [Sunburst](https://plot.ly/python/sunburst-charts/) the hierarchy is defined by [labels](https://plot.ly/python/reference/#treemap-labels) and [parents]((https://plot.ly/python/reference/#treemap-parents)) attributes. [count](https://plot.ly/python/reference/#treemap-count) attribute allows counting the numbers of leaves, branches or both when values array is not provided. | ||
|
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.
Please explain here how to interact with the treemap chart: click on one sector to zoom (mention the pathbar), and double-click to zoom out one level.
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.
yeah, I add how to zoom in with click... to zoom out we basically use 'pathbar'.. double click is doing the same thing that click does.
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 me (Chrome) double clicking zooms out one level, is it the same for you?
python/treemap-charts.md
Outdated
import plotly.graph_objects as go | ||
|
||
fig = go.Figure(go.Treemap( | ||
labels = ["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"], |
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.
define labels
and parents
variables before defining the traces to show it's the same data used for the two traces?
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.
To kinda show the possibility of plotting Treemap with defining only these 2 attributes, make sense?
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.
no sorry, this is not what I meant: since it's the same values for the two traces for labels
and parents
I was suggesting to define variables to hold these values to reduce code duplication and to show what is similar in the two traces
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.
nice 👍
python/treemap-charts.md
Outdated
marker = {"line": {"width": 2}}, | ||
pathbar = {"visible": False})) | ||
|
||
fig.update_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.
with subplots you could use subtitles here which would be more readable
Is it possible to add an example showing how to control the color of |
python/treemap-charts.md
Outdated
```python | ||
import plotly.graph_objects as go | ||
|
||
fig = 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.
When we have one single trace we prefer the more compact syntax
fig = go.Figure(go.Treemap(...))
About using |
python/treemap-charts.md
Outdated
pygments_lexer: ipython3 | ||
version: 3.7.3 | ||
plotly: | ||
description: How to make Treemap Charts. |
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.
.. with plotly
python/treemap-charts.md
Outdated
order: 14 | ||
page_type: u-guide | ||
permalink: python/treemap-charts/ | ||
thumbnail: thumbnail/treemap.png |
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 this a new thumbnail or the old one?
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.
A new thumbnail
python/treemap-charts.md
Outdated
|
||
### Basic Treemap | ||
|
||
Treemap chart visualize hierarchical data using nested rectangles. Same as [Sunburst](https://plot.ly/python/sunburst-charts/) the hierarchy is defined by [labels](https://plot.ly/python/reference/#treemap-labels) and [parents]((https://plot.ly/python/reference/#treemap-parents)) attributes. [count](https://plot.ly/python/reference/#treemap-count) attribute allows counting the numbers of leaves, branches or both when values array is not provided. |
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.
chart --> charts
Same as -- As for
I would leave the explanation about count
for later in the tutorial since it's not used in the example just below
python/treemap-charts.md
Outdated
name: Treemap Charts | ||
order: 14 | ||
page_type: u-guide | ||
permalink: python/treemap-charts/ |
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.
This permalink should be the same as the file you're deleting in the other PR, so we inherit all the traffic from the previous page!
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.
(and the filename should match)
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 fact, it would be best if the deletion and upgrade were in the same PR :)
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.
This permalink should be the same as the file you're deleting in the other PR, so we inherit all the traffic from the previous page!
good point, I changed it to be similar to other charts name!
Nicolas showed me that the color is controlled by |
One thing which you might do another time is to do a |
python/treemaps.md
Outdated
parents = parents, | ||
values = [10, 14, 12, 10, 2, 6, 6, 1, 4], | ||
textinfo = "label+value+percent parent+percent entry+percent root", | ||
pathbar = {"visible": False}), |
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.
It was a smart trick to disable the pathbar
because of the overflow but the pathbar
is super useful for navigation. What I tried is adding a blank line in the titles like branchvalues: <b>remainder</b><br> <br>'
, a bit ugly but it does the trick (you can add a comment in the code cell to explain that it's a workaround for now)
python/treemaps.md
Outdated
fig.show() | ||
``` | ||
|
||
### Set Color of Sectors |
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.
Set Color of Treemap Sectors
(I think we want to repeat the chart name as much as possible for search engines)
|
||
### Set Color of Sectors | ||
|
||
There are three different ways to change the color of the sectors in Treemap: |
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.
Nice examples about colors, thanks for adding them! I would never have found the 3 ways myself 😆
python/treemaps.md
Outdated
fig = go.Figure(go.Treemap( | ||
labels = labels, | ||
parents = parents, | ||
marker = {'colors': ["pink", "royalblue", "lightgray", "purple", "cyan", "lightgray", "lightblue"]})) |
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.
very minor style remark, but can you use the shorter syntax marker_colors
here? We're trying to push the magic underscore as much as possible :-)
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.
Yeah, good point
python/treemaps.md
Outdated
labels = labels, | ||
values = values, | ||
parents = parents, | ||
marker = {"colorscale": "Blues"})) |
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.
marker_colorscale
for more magic underscore :-)
### Nested Layers in Treemap | ||
|
||
The following example uses hierarchical data that includes layers and grouping. Treemap and [Sunburst](https://plot.ly/python/sunburst-charts/) charts reveal insights into the data, and the format of your hierarchical data. | ||
|
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.
Could you please add a sentence about maxdepth
here?
Thanks for the update! I left a couple of comments and after this we should be good to go :-) |
Could you also update the plotly.py version in the |
💃 once the CI is happy (bumping up |
8b928d1
to
2fd565e
Compare
💃 ! |
Doc upgrade checklist:
unconverted/x/y.md
tox/y.md
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 appropriate