Blog - complex scatter scatter plot#24
Open
kdorr wants to merge 4 commits into
Open
Conversation
story645
reviewed
Aug 20, 2018
Member
story645
left a comment
There was a problem hiding this comment.
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. |
| 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 |
Member
There was a problem hiding this comment.
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. |
Member
There was a problem hiding this comment.
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. |
Member
There was a problem hiding this comment.
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() |
Member
There was a problem hiding this comment.
ax.grid() and fig.show() if you want to stay more Oo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the slightly more complex scatter plot section from the blog post Nabarun and I were working on.