You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 3, 2024. It is now read-only.
When using integer values as categorical variable in a strip / box / violin plot, the values of the categorical variable are mapped to a continuous numeric axis even if the values are of string or pd.Categorical type.
Example:
We create a dataframe with columns names having an integer value in string format. These could be any category that makes sense to the specific business case (e.g. product code, etc.)
The categorical variable (values '1', '2', '34' and '123') get mapped to a continuous numeric scale. Here, the variables '1' and '2' blend together and this can get worst if there are orders of magnitude between the different values.
Converting the string values to pd.Categorical type yields the same result as above.
Adding a character to the values makes them be recognized as categorical which is the expected result (except for the added character in the category names). Unfortunately, adding a blank space does not work either.
Considering that numeric categorical values are legitimate in many contexts, it should be possible to use numbers as categories if they are represented by a string or categorical data type, as is the case with the color parameter (#140):
px.strip(df.melt(), y='value', color='variable')
Thanks!
The text was updated successfully, but these errors were encountered:
Issue:
When using integer values as categorical variable in a strip / box / violin plot, the values of the categorical variable are mapped to a continuous numeric axis even if the values are of string or
pd.Categorical
type.Example:
We create a dataframe with columns names having an integer value in string format. These could be any category that makes sense to the specific business case (e.g. product code, etc.)
We unpivot the data using and make a strip plot.
The categorical variable (values '1', '2', '34' and '123') get mapped to a continuous numeric scale. Here, the variables '1' and '2' blend together and this can get worst if there are orders of magnitude between the different values.
Converting the string values to
pd.Categorical
type yields the same result as above.Workaround:
Adding a character to the values makes them be recognized as categorical which is the expected result (except for the added character in the category names). Unfortunately, adding a blank space does not work either.
Considering that numeric categorical values are legitimate in many contexts, it should be possible to use numbers as categories if they are represented by a string or categorical data type, as is the case with the
color
parameter (#140):Thanks!
The text was updated successfully, but these errors were encountered: