-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
added histogram to facet_grid #776
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
Conversation
CHANGELOG.md
Outdated
@@ -2,6 +2,10 @@ | |||
All notable changes to this project will be documented in this file. | |||
This project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
## [Unreleased] | |||
### Added | |||
- `.create_facet_grid` now supports histogram 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.
maybe figure_factory.create_facet_grid
just to be super clear
just tried putting hist in one of the docstring examples and it's rendered a bit weird and needs to be autoscaled:
|
plotly/figure_factory/_facet_grid.py
Outdated
) | ||
|
||
temp_trace = 'scatter' if (trace_type == 'histogram') else trace_type |
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.
since this renders the trace as scatter first, the histogram attributes can't be passed. For example:
tips = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/tips.csv')
fig = ff.create_facet_grid(
tips,
x='total_bill',
y='tip',
trace_type='histogram',
histfunc='sum',
facet_row='sex',
facet_col='smoker'
)
py.iplot(fig, filename='facet_grid_tips_sequential_colors')
Note: going to add lines to histogram for aesthetics |
@cldougl tests finally passed. good to merge? |
I'll take another look this afternoon @Kully |
plotly/figure_factory/_facet_grid.py
Outdated
@@ -25,6 +25,7 @@ | |||
THRES_FOR_FLIPPED_FACET_TITLES = 10 | |||
GRID_WIDTH = 1 | |||
|
|||
VALID_TRACE_TYPES = ['scatter', 'scattergl', 'histogram'] |
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.
technically other types too though, right? I think that box
, histogram2d
, and bar
might work now
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 remember not liking the look of box or bar - it was very squashed up, but perhaps it was the dataset
plotly/figure_factory/_facet_grid.py
Outdated
@@ -189,18 +190,22 @@ def _facet_grid_color_categorical(df, x, y, facet_row, facet_col, color_name, | |||
if not facet_row and not facet_col: | |||
color_groups = list(df.groupby(color_name)) | |||
for group in color_groups: | |||
trace = graph_objs.Scatter( | |||
trace = dict( | |||
x=group[1][x], | |||
y=group[1][y], |
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'm having a hard time understanding what happens when the histogram
mode sets both x
and y
here. Shouldn't only one of them be set?
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.
Or is just the other variable ignored?
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.
Oh, or the user just doesn't supply the y
variable when setting it? Like
FF.facet_grid(df, x='categorial-column', facet_col='another-column', trace_type='histogram')
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 found an oversight in my design.
Originally this was meant for just scatter, so I was forcing x
and y
. I'm going to try not forcing x
and y
and putting df[x]
and df[y]
in the trace dictionary depending on what the user provides
@chriddyp We got some nice variety going: |
@cldougl Can you give this one quick review today? I'm trying to get it merged today and the pip package updated so I can finish documentation by the end of the week. Thank you 😄 |
@Kully is it possible to change the color of the markers?
|
|
||
fig = ff.create_facet_grid( | ||
mtcars, | ||
x='wt', |
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.
shouldn't this example only have an x or a y?
plotly/figure_factory/_facet_grid.py
Outdated
type=trace_type, | ||
marker=dict( | ||
color=marker_color, | ||
**kwargs_marker | ||
line=kwargs_marker['line'], | ||
#opacity=kwargs_marker['opacity'], |
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.
should this be commented out?
@@ -25,6 +25,7 @@ | |||
THRES_FOR_FLIPPED_FACET_TITLES = 10 | |||
GRID_WIDTH = 1 | |||
|
|||
VALID_TRACE_TYPES = ['scatter', 'scattergl', 'histogram', 'bar', 'box'] |
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.
are we planning on adding histogram2d
as well (#776 (review)) ?
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 histogram2dcontour
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.
Since marker
is not a valid key in facet grid, I vote that these trace types get moved into another PR/Issue. It would require a large reworking of the code, so I think we should move it to another issue so we can get this merged so the documentation can go up this week.
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'm ok w/ doing those in a different pr
looks good to me! 💃 from me once @cldougl 's comments are addressed |
Yeah, I think that would be a good idea |
💃 good for me too |
just did |
No description provided.