Skip to content

[MRG] Bar chart notebook #1

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 9 commits into from
Jun 21, 2019
Merged

[MRG] Bar chart notebook #1

merged 9 commits into from
Jun 21, 2019

Conversation

emmanuelle
Copy link
Contributor

Refreshed the bar chart notebook, using px and a more modern plotly syntax.

@emmanuelle
Copy link
Contributor Author

This PR is not completely ready for review yet, I need to add some text at the beginning of sections, but I wanted some advice whether the examples and the syntax used in examples look ok.

@emmanuelle
Copy link
Contributor Author

Also, what are the available color names with plotly? (like red, blue, ...) Is it possible to have darkred, lightblue etc. ? I think most users can't be bothered with RGB or hex...

@emmanuelle
Copy link
Contributor Author

As you see, I tried to avoid having dictionaries as much as possible, hence I made heavy use of the magic underscore. In particular, marker_color rather than a dictionary for marker. I think I'd prefer to code this way.

@emmanuelle
Copy link
Contributor Author

Question: when we call fig.update(...), do we want to add fig.show() or not? It's not necessary, so I'm fine with having just the update call but maybe we want show everywhere...

@emmanuelle
Copy link
Contributor Author

I think this one is ready for another pass. One question is where the px reference page will be. I left some TODOs for potential links, I think it's ok to merge keeping the TODOs and make another pass for removing the TODOs before the release.

@emmanuelle emmanuelle changed the title [WIP] first pass at bar chart notebook Bar chart notebook Jun 6, 2019
@emmanuelle
Copy link
Contributor Author

@nicolaskruchten and now with plenty of inlining and go.Figure to start examples... Hope it corresponds to what you have in mind.

@emmanuelle emmanuelle changed the title Bar chart notebook [MRG] Bar chart notebook Jun 13, 2019
When data are not available as tidy dataframes, it is also possible to use the more generic `go.Bar` function from `plotly.graph_objs`.

```python
import plotly.graph_objs as go
Copy link
Contributor

Choose a reason for hiding this comment

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

We can start using graph_objects now!

go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
])
# Change the bar mode
fig.update(layout_barmode='group')
Copy link
Contributor

Choose a reason for hiding this comment

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

this one will need fig.show()

Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably also consistently use .update_layout() now that we have it

go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
])
# Change the bar mode
fig.update(layout_barmode='stack')
Copy link
Contributor

Choose a reason for hiding this comment

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

fig.show()

fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='angled-text-bar')
# Here we modify the tickangle of the xaxis, resulting in rotated labels.
fig.update(layout_barmode='group', layout_xaxis_tickangle=-45)
Copy link
Contributor

Choose a reason for hiding this comment

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

.update_layout() will make this a little bit shorter :)


fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='style-bar')
fig.update(layout=layout)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be updated to .update_layout( ...contents of go.Layout ... ) so no need to actually create layout or refer to go.Layout at all I think.

fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='style-bar')
fig.update(layout=layout)
fig.show()
```

### Waterfall Bar Chart
Copy link
Contributor

Choose a reason for hiding this comment

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

Yikes, let's remove this waterfall example altogether! we have a specific waterfall trace now and should not be confusing users with this old thing :)

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Jun 18, 2019

OK this one is super close! Just needs a couple of updates to track the latest integration build, but we can do that in a follow-up pass if you're sick of iterating on it...

  • graph_objs -> graph_objects
  • update(layout_attr='val') -> update_layout(attr='val')`
  • fig.show() at the end of each one

Basically we don't need to use the generic .update() anywhere at all any more, right?

@emmanuelle
Copy link
Contributor Author

Should be good to go! Yes, I don't think we need update any more.

@nicolaskruchten
Copy link
Contributor

💃 to merge once the "waterfall" example has been removed, and all references to graph_objs are replaced with graph_objetcs :)

@emmanuelle emmanuelle merged commit 3c030ce into master Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants