-
Notifications
You must be signed in to change notification settings - Fork 7
Blog - complex scatter scatter plot #24
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
base: gh-pages
Are you sure you want to change the base?
Conversation
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 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. |
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.
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 |
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.
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. |
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.
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. |
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.
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() |
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.
ax.grid() and fig.show() if you want to stay more Oo
This is the slightly more complex scatter plot section from the blog post Nabarun and I were working on.