Skip to content

Blog - complex scatter scatter plot#24

Open
kdorr wants to merge 4 commits into
matplotlib:gh-pagesfrom
kdorr:blog-scatter-complex
Open

Blog - complex scatter scatter plot#24
kdorr wants to merge 4 commits into
matplotlib:gh-pagesfrom
kdorr:blog-scatter-complex

Conversation

@kdorr
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread _posts/altair-to-mpl-scatter-part2.md Outdated
# 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
Copy Markdown
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

Comment thread _posts/altair-to-mpl-scatter-part2.md Outdated
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
Copy Markdown
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"

Comment thread _posts/altair-to-mpl-scatter-part2.md Outdated

## 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
Copy Markdown
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

Comment thread _posts/altair-to-mpl-scatter-part2.md Outdated
```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
Copy Markdown
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)

Comment thread _posts/altair-to-mpl-scatter-part2.md Outdated
ax.set_xlim([0, None])
ax.set_ylim([0, None])
ax.legend(title='Origin')
plt.grid()
Copy link
Copy Markdown
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