[Feature] Multiple rugplots on same plot
See original GitHub issueHi there,
Is there a way to add multiple rugplots to the same figure? This would be useful when having unique values on one axis and multiple grouping variables to color by. I understand this is achievable with shapes/colors for groups of low cardinality but I believe can quickly get confusing. Currently, when calling rugplot
twice the second rugplot
draws over the first one.
Example:
import string
import random
import numpy as np
import pandas as pd
import seaborn as sns
N = 20
groups_a = random.choices(string.ascii_letters[0:5], k=N)
groups_b = random.choices(string.ascii_uppercase[0:5], k=N)
Y = np.random.random(N)
X = range(N)
df = pd.DataFrame.from_dict({"X":X, "Y":Y, "A":groups_a,"B":groups_b})
sns.scatterplot(data=df, x="X", y="Y")
sns.rugplot(data=df, x="X", hue="A", linewidth=12)
sns.rugplot(data=df, x="X", hue="B", linewidth=12)
This yields:
Expected output would be something like:
(of course with more modifications of cmaps etc. to make the plot more clear)
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
[R] multiple rugs on a single plot
I'd like to produce 3 rug plots under a kernel density plot > for a population. The population is subdivided into 3 >...
Read more >11. Rug Plots - Graphing Data with R [Book] - O'Reilly
Rug Plots The Rug Plot The rug is not really a separate plot. ... When two observations have the same value, they are...
Read more >Multiple rug plots on the same side of the plot margin - tidyverse
Hi, Does anyone know if it is possible to have multiple rug plots on the same outside margin of a plot? For example,...
Read more >How to spatially separate rug plots from different series
One way would be to use two geom_rug() calls - one for b , other for a . Then for one geom_rug() set...
Read more >seaborn.rugplot — seaborn 0.12.1 documentation - PyData |
Plot marginal distributions by drawing ticks along the x and y axes. This function is intended to complement other plots by showing the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I understand that this might be misusing rug plots a bit much. I will think about alternative angles to this problem then. Thanks for your help!
I think you’re asking for too much from a rug plot here, which is meant to show the marginal distribution of observations, and not additional categorical information. I’m still not exactly sure what you’re hoping for, but I think the answer is going to require a bespoke plot with a fair amount of customization. At this point, I’d suggest defining a clear problem statement and asking on StackOverflow, since the original feature request
is already satisfied with existing functionality.