-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Coloring scatter plots by factor/string #11422
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
Comments
After checking the documentation again, this is definitely a feature request. After seeing how many posts on stackoverflow are about exactly this problem, I think this is something that is really not working as expected - Intuition (and implementations in R and, for example, seaborn), suggest that matplotlib should automatically deduce what the user wants in this case instead of throwing an error. |
OK, if you do |
Yes, as long as it's numerical, it works. Only the implementation for
string / categorical data is missing.
Jody Klymak <notifications@github.com> schrieb am Di., 12. Juni 2018, 18:21:
… OK, if you do data={"x":[1,2,3,2,4], "y":[2,1,2,3,1], "z":[5, 4, 3, 2, 1]}
this works, right? We don't have categorical data for the z axis.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11422 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APirBH4xsIj8KjL_XqhWmDJtz6JUX5Tpks5t7-qXgaJpZM4Uki7y>
.
|
However, this also plots on a scale of continuous numbers instead of using
categories. Implementation of this in a useful way (like ggplot & seaborn
do it) might be harder than initially thought.
Thomas <teefkay@gmail.com> schrieb am Di., 12. Juni 2018, 18:26:
… Yes, as long as it's numerical, it works. Only the implementation for
string / categorical data is missing.
Jody Klymak ***@***.***> schrieb am Di., 12. Juni 2018,
18:21:
> OK, if you do data={"x":[1,2,3,2,4], "y":[2,1,2,3,1], "z":[5, 4, 3, 2,
> 1]} this works, right? We don't have categorical data for the z axis.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#11422 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/APirBH4xsIj8KjL_XqhWmDJtz6JUX5Tpks5t7-qXgaJpZM4Uki7y>
> .
>
|
Yes, right now categorical axes work by converting the string "units" to numbers. But we don't have the equivalent unit conversion machinery in place for z-data. I think one of the reasons seaborn is around is to scratch that itch. We are thinking about how to do it, lead by @story645, but its not trivial. |
This is how I would currently do it:
Concerning the legend, there is a proposal #11127 which is still under review to simplify the legend creation. If this passes as in its current proposed version, a legend could be simply created like
However, as of now you would need to create the legend manually, e.g. like
|
Xref: This request is also very similar to the request in #6214. |
@ImportanceOfBeingErnest : That indeed seems to be the same issue, with broader scope. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
I think this is still wanted and I think one way to tackle this is to try and make NoNorm unit aware #7383 |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Bug report
This may be either a bug report or a feature request, depending how you view things. The issue is that you cannot use a factor/string column in a pandas dataframe as color option without awkward workarounds.
Code for reproduction
Actual outcome
Expected outcome
An image where each point is colored according to it's value in "z", cycling through a predefined color map. A shining example of how easy such a commonly used visualization should be is ggplot, see the code in this post: The color option automatically notices that this is a factor variable and assigns each level a color. Also, a legend is automatically shown.
Matplotlib version
'2.1.0'
The text was updated successfully, but these errors were encountered: