question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Multiple rugplots on same plot

See original GitHub issue

Hi 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: image

Expected output would be something like: image

(of course with more modifications of cmaps etc. to make the plot more clear)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jeskowagnercommented, May 2, 2022

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!

0reactions
mwaskomcommented, May 2, 2022

ideally one would have some sort of spacing in between the two rugs

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 there a way to add multiple rugplots to the same figure?

is already satisfied with existing functionality.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found