-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
adding pie, treemap, sunburst, funnel and funnelarea to px #1909
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
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1947333
first draft of adding pie, sunburst, funnel and funnelarea
emmanuelle 668eb90
black
emmanuelle 78ed0f2
labels and names
emmanuelle 1916166
hovertemplate
emmanuelle 1b06d3a
added tests
emmanuelle 6c5313b
doc
emmanuelle 2e2444f
continuous color scale for sunburst and treemap
emmanuelle ae6221d
color scales for treemap and sunburst
emmanuelle 861b066
colorway
emmanuelle e2902b4
added tests
emmanuelle b9f9084
added funnelarea
emmanuelle 947e7c2
minor improvements
emmanuelle ea87847
removed test
emmanuelle 9d6360a
tweaks to pie/funnel
nicolaskruchten 0dd2f39
fix tests
nicolaskruchten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/python/plotly/plotly/tests/test_core/test_px/test_px_functions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import plotly.express as px | ||
import plotly.graph_objects as go | ||
from numpy.testing import assert_array_equal | ||
|
||
|
||
def _compare_figures(go_trace, px_fig): | ||
"""Compare a figure created with a go trace and a figure created with | ||
a px function call. Check that all values inside the go Figure are the | ||
same in the px figure (which sets more parameters). | ||
""" | ||
go_fig = go.Figure(go_trace) | ||
go_fig = go_fig.to_plotly_json() | ||
px_fig = px_fig.to_plotly_json() | ||
del go_fig["layout"]["template"] | ||
del px_fig["layout"]["template"] | ||
for key in go_fig["data"][0]: | ||
assert_array_equal(go_fig["data"][0][key], px_fig["data"][0][key]) | ||
for key in go_fig["layout"]: | ||
assert go_fig["layout"][key] == px_fig["layout"][key] | ||
|
||
|
||
def test_pie_like_px(): | ||
# Pie | ||
labels = ["Oxygen", "Hydrogen", "Carbon_Dioxide", "Nitrogen"] | ||
values = [4500, 2500, 1053, 500] | ||
|
||
fig = px.pie(names=labels, values=values) | ||
trace = go.Pie(labels=labels, values=values) | ||
_compare_figures(trace, fig) | ||
|
||
labels = ["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"] | ||
parents = ["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"] | ||
values = [10, 14, 12, 10, 2, 6, 6, 4, 4] | ||
# Sunburst | ||
fig = px.sunburst(names=labels, parents=parents, values=values) | ||
trace = go.Sunburst(labels=labels, parents=parents, values=values) | ||
_compare_figures(trace, fig) | ||
# Treemap | ||
fig = px.treemap(names=labels, parents=parents, values=values) | ||
trace = go.Treemap(labels=labels, parents=parents, values=values) | ||
_compare_figures(trace, fig) | ||
|
||
# Funnel | ||
x = ["A", "B", "C"] | ||
y = [3, 2, 1] | ||
fig = px.funnel(y=y, x=x) | ||
trace = go.Funnel(y=y, x=x) | ||
_compare_figures(trace, fig) | ||
# Funnelarea | ||
fig = px.funnel_area(values=y, names=x) | ||
trace = go.Funnelarea(values=y, labels=x) | ||
_compare_figures(trace, fig) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.