Skip to content
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

Blog - complex scatter scatter plot #24

Open
wants to merge 4 commits into
base: gh-pages
Choose a base branch
from

Conversation

kdorr
Copy link
Collaborator

@kdorr kdorr commented Aug 15, 2018

This is the slightly more complex scatter plot section from the blog post Nabarun and I were working on.

Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

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

I'm not sure if this and the other Todo blog post should be merged or held off until those features are merged.

# Making a Complex Scatter Plot
At the time of writing, mpl-altair does not support scatter plots with nominal or ordinal color encodings, so this post will show how to create a complex scatter plot in Altair, Matplotlib, and how mpl-altair _should_ implement the chart conversion in the future.

In the first part, we made a simple scatter plot. This post will look at a more complex plot.
Copy link
Member

Choose a reason for hiding this comment

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

Link to the first post

In addition to looking at Horsepower vs Weight, let's color each point by its origin country.

## Altair
Since Altair is based on linking columns to encodings, we just have to specify
Copy link
Member

Choose a reason for hiding this comment

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

No 'just', use "we have to specify"


## Altair
Since Altair is based on linking columns to encodings, we just have to specify
that the color encoding comes from the Origin column.
Copy link
Member

Choose a reason for hiding this comment

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

Use italics to highlight the origin column

```python
ax.scatter('Weight_in_lbs', 'Horsepower', c='quantitative_column', data=cars)
```
However, the scatter function currently doesn't allow scalar mappables for categorical data.
Copy link
Member

Choose a reason for hiding this comment

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

Categorical color definitions (my guess is that scalar mappables is too weedy for the audience for this post)

ax.set_xlim([0, None])
ax.set_ylim([0, None])
ax.legend(title='Origin')
plt.grid()
Copy link
Member

Choose a reason for hiding this comment

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

ax.grid() and fig.show() if you want to stay more Oo

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