51 questions
1
vote
1
answer
86
views
Format y-axis as percentage in a seaborn.objects plot
I found a suggestion to use ticker.PercentFormatter. This changed the decimal numbers on the y-axis to percentages like I want, but the style formatting (grid, background, etc.) is lost, and the ...
1
vote
1
answer
103
views
Seaborn objects stacked bar plot not respecting dodge
I have survey data where I have an 'index' of the survey question, a 'variable' of the answer, and a 'value' of the fraction of respondents that gave the answer. The survey was repeated in two ...
0
votes
0
answers
49
views
Can't control what variable to dodge on using so.dodge
I'm trying to pass a list of variables to the so.Dodge function of seaborn objects, so that in my plot provided in the following example, the dodge is applied only on two of three possible variables. ...
0
votes
0
answers
13
views
Change the color of kde line in sns.histplot [duplicate]
How to change the color of kde line in a histplot of seaborn?
I'm using this code to plot the histogram:
p = sns.histplot(data=diamantes, x='carat', bins=40, color='#90d8fc', kde=True)
In the ...
0
votes
0
answers
11
views
X and Y axis limits Seaborn Objects interface
In the seaborn.objects interface, there is a limit method that allows you to set the x and y axis limits. But I need to be able to get those axis limits and/or get the highest count for the a ...
1
vote
1
answer
158
views
Set fontsize of axis and legends in seaborn.objects
I am using seaborn.objects to create a faceted plot. I have read the documentation but setting font size argument does not do anything (Seaborn.objects Documentation)
My Df:
{'storage': {0: '4 °C',
...
0
votes
0
answers
69
views
Seaborn graph in streamlit does not let you customize theme
I would like to modify the theme of a seaborn objects graph displayed through streamlit. However, it seems that the graph only uses the standard theme, disregarding the .theme() part.
The following ...
0
votes
1
answer
43
views
How to have both stacked and dodge bar in same plot in seaborn?
I am trying to have both stacked and dodge in same plot. In below example for each size I would like to have two set of stacked bar plot.
import seaborn.objects as so
tips= sns.load_dataset("...
1
vote
0
answers
54
views
Factor level order in stacked bar plot chart (seaborn.objects +matplotlib)
I have a pandas dataframe. My goal is to create a stacked bar plot chart that is facetted and annotated with the respective percentages.
I am using Python 3.12.3, pandas version '2.2.2', seaborn ...
0
votes
1
answer
331
views
Plotting paired data
I am trying to use seaborn's object-oriented interface to make a plot of paired data where each pair is connected by a line segment. I want a single subplot in the final plot to look like this:
The ...
2
votes
1
answer
815
views
How to add a general title with a seaborn.objects.Plot.facet plot
I am currently using the seaborn library in Python to create a facetted stacked barplot from a pandas dataframe named averages with columns ['Name', 'Period', 'Value', 'Solver'].
Here is the code I ...
1
vote
1
answer
203
views
How to add suptitle to a facet plot created using the seaborn.objects api?
I tried to find a way to add a separate suptitle to a set of subplots created using the seaborn.objects API. However, I couldn't find any such examples in the the docs. Is there a way to do this?
I ...
0
votes
1
answer
143
views
seaborn legend (functions vs. object)
when using seaborn functions I can get all handles and labels:
p=(
sns.scatterplot(data=peng, x='island', y='bill_length_mm', hue='species', style='sex')
)
print(type(p))
h, l = p....
-1
votes
1
answer
145
views
Seaborn objects facet without sharing y axis
I am attempting to create a faceted plot of overlays of three groups within my dataset, however the groups are on different scales so when faceted two of the plots are squashed. Is there a way of ...
2
votes
1
answer
1k
views
How to show all x-tick labels with seaborn.objects
How do I make it so that it shows all x ticks from 0 to 9?
bin diff
1 4 -0.032748
3 9 0.106409
13 7 0.057214
17 3 0.157840
19 0 -0.086567
... ... ...
1941 ...
2
votes
1
answer
241
views
How to order facets when using the Seaborn objects interface
I am trying to order facets in a plot produced by the seaborn objects interface.
import numpy as np
import seaborn as sns
import seaborn.objects as so
import matplotlib.pyplot as plt
df = sns....
2
votes
1
answer
179
views
Minor log ticks in seaborn.objects
The default log scale in seaborn.objects doesn't show the minor log grid lines. How can they be turned on?
#Synthetic data
import pandas as pd
from scipy.stats import expon
data = pd.DataFrame({'rate':...
1
vote
0
answers
653
views
Formatting text labels in seaborn.objects
Formatting of the so.Text() mapping doesn't seem to have an effect on text labels. In the example below, I am trying to format using the text= scale such that the text labels are rounded to 1dp and ...
5
votes
1
answer
796
views
Legend obscures plot using Seaborn Objects API
I have a recurring problem with legends on many of my plots with legends. The legend often obscures part of the data.
Reproducible example:
import seaborn.objects as so
import numpy as np
import ...
2
votes
1
answer
372
views
Is there an alternate for 'palette' while plotting barplot through seaborn object Plot(); How to remove legend when plotting with so.Plot()
I am trying to learn the seaborn object Plot() interface. With the traditional sns.barplot() we could easily define color palette for the bars.
import seaborn as sns
df = sns.load_dataset('penguins')
...
2
votes
1
answer
875
views
How do you plot a trendline on labelled scatterplot points with the seaborn objects interface?
I'm using the seaborn.objects interface to label plot points. However, I can't add a trendline if the labels are present.
Adding the argument text='label' and the method .add(so.Line(color='orange'), ...
0
votes
0
answers
146
views
seaborn.objects common labels is not working instead it gives separate label to each plots
Hi I am trying to give title to this plot. Instead of having a common label, the labels are shared among the plots. Is there any way to not switching from seaborn object.
(
so.Plot(df,x="...
3
votes
1
answer
187
views
adding a vertical line to plot using seaborn object interface
I am trying to use seaborn object interface. It looks intuitive like ggplot2 in R. However, since it is still in development stage, the underlying documentation is still WIP.
For example I am trying ...
2
votes
1
answer
366
views
Can I use the IPython magic function %matplotlib qt with seaborn.objects?
Typically if I want to make an interactive plot, I use %matplotlib qt, such that I can explore, zoom, add to the figure etc. I wanted to make an area plot, and with the release of seaborn objects, ...
0
votes
0
answers
323
views
Why is seaborn objects breaking on basic data?
I am a native R user but need to use Python in a new job. Seaborn objects seems to match up with ggplot much more closely (I know about plotnine; let's ignore it for now).
Unfortunately, it is not ...
1
vote
1
answer
1k
views
Use seaborn object interface to plot overlapping density plots, added inside a for loop, each having its own color/label shown in a legend
Using seaborn python library, I am trying to make several density plots overlapping each other in the same figure and I want to color/label each of the lines. Using seaborn objects interface I am able ...
0
votes
0
answers
284
views
Tornado plot using seaborn objects
I would like to create a tornado plot using seaborn objects and was wondering if there was an efficient way to do this.
import numpy as np
import pandas as pd
import seaborn.objects as so
# create a ...
2
votes
1
answer
3k
views
How can I add space between bars in a dodged (hue) group?
How can I add space between Male and Female bars in seaborn histplot ?
import seaborn as sns
tips = sns.load_dataset("tips")
sns.histplot(data=tips, x="day", hue="sex", ...
9
votes
2
answers
527
views
How to move marker and color sections of a figure legend
I am creating a figure (with the seaborn.objects interface) that requires a legend with both colors and markers. I am trying to move the legend that is generated, but I am having trouble moving the ...
2
votes
1
answer
654
views
Duplicate plots are output when using seaborn.objects with subplots in jupyter
I am running the code in jupyter, which displays a plot figure. However, without plt.show(), the same plot is duplicated, so two plot figures are display. Why is this happening?
import matplotlib....
4
votes
2
answers
219
views
How to reposition Figure legends into subfigures
I am new to this, trying to plot 2 subfigures horizontal with sample data using Matplotlib and Seaborn library in Jupyter Notebook, the 2 sub-charts come out alright, but the 2 legends overlap each ...
2
votes
1
answer
915
views
Plot regression confidence interval using seaborn.objects
How can I use the objects API to plot a regression line with confidence limits (like sns.regplot / sns.lmplot)?
Based on the so.Band fmri example, I thought it would be something like this:
import ...
2
votes
1
answer
945
views
How to define a colors with rgb values in the seaborn objects api?
I want to color my dots in a scatterplot with some rgb values.
Using the original api, this is easy:
import seaborn as sns
x = [0, 1, 2]
y = [0, 0, 0]
colors = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
sns....
3
votes
1
answer
577
views
Discrete date values for x-axis in seaborn.objects plot
I am trying to prepare a bar plot using seaborn.objects with time series data where the x-axis ticks and labels are only on the dates that really appear in the data.
import pandas as pd
import seaborn....
0
votes
2
answers
422
views
Plot horizontal bars using seaborn.objects
In the original API, barplot provided an orient parameter to swap bar orientation:
import pandas as pd, numpy as np, seaborn as sns
df = pd.DataFrame(data=np.random.randint(10, size=(3, 5)), columns=[...
1
vote
2
answers
921
views
How to add an arbitrary line to Seaborn.Objects plot
Is there a way using seaborn objects to add arbitrary line into a plot? Something like ggplots geom_abline specifying slope and intercept? I mean, using seaborn objects API only. ...
# this DOES NOT ...
0
votes
1
answer
190
views
Bin and aggregate with `seaborn.objects`
Is there a way to both bin and aggregate (with some other function than count) in seaborn.objects? I'd like to compute the mean per bin and right now I'm using the following:
import seaborn.objects as ...
2
votes
1
answer
914
views
Stacking to 100% with `seaborn.objects`
I'm trying to make a plot with bars or areas rescaled to 100% with the new seaborn.objects interface and I can't seem to get so.Norm() to work, with or without by...
Here's what I've got so far:
...
4
votes
1
answer
478
views
Adding bar labels shrinks dodged bars in seaborn.objects
I am trying to add text labels to the top of a grouped/dodged bar plot using seaborn.objects.
Here is a basic dodged bar plot:
import seaborn.objects as so
import pandas as pd
dat = pd.DataFrame({'...
1
vote
1
answer
201
views
how to use seaborn objects scale with two visualisations with same kwargs?
I'm trying to create bar plot with labels on bars. Position of labels and color of labels depends on column of dataframe. Also, I would like to color bars by column.
My data:
data = {
'Survived': [...
1
vote
1
answer
245
views
How can I use .on(fig) without distorting the legend position in seaborn.objects?
I am creating a plot in seaborn.objects. This plot has a legend, and I would also like to change its size.
This can be done using the .theme() method, which affects the matplotlib rcParams:
import ...
0
votes
1
answer
783
views
How can I rotate axis labels in a faceted seaborn.objects plot?
I am working with the excellent seaborn.objects module in the most recent version of seaborn.
I would like to produce a plot:
With rotated x-axis labels
With facets
Rotating x-axis labels is not ...
1
vote
1
answer
1k
views
How to create line + ribbon plot with seaborn.objects?
I would like to create a line + ribbon plot similar to these ones created with ggplot2 using geom_line + geom_ribbon:
For that, I would like to use the new seaborn.objects interface, but even though ...
5
votes
2
answers
3k
views
How to rotate the xticks with seaborn.objects
By chance, is there a way to rotate the xticks in the graphic below (just to make it a bit more readable)? The usual
sns.xticks() doesn't work in the new seaborn.objects development (which is amazing!)...
1
vote
1
answer
641
views
How to remove the ticklabels from a seaborn.objects plot
How to disable the axes' ticklabels for seaborn.objects generated image?
import seaborn as sns
from seaborn import objects as so
tips = sns.load_dataset("tips")
(
so.Plot(tips, "...
4
votes
1
answer
1k
views
How to change the image size for seaborn.objects
The solutions shown in How to change the figure size of a seaborn axes or figure level plot do not work for seaborn.objects. This question is about the new interface added in seaborn v0.12.
Tried ...
8
votes
0
answers
1k
views
How to move the legend position in the seaborn.objects API
I am using the new seaborn.objects API available in v0.12.0. None of the examples show how to move the legend position. For example, moving the legend to the bottom. Is there a way to do this?
Using ...
0
votes
1
answer
132
views
Is there a way to efficiently construct a pairplot in the new seaborn.objects as with seaborn.pairplot?
I just started digging into the new seaborn.objects interface, which I liked pretty much. Though seaborn.pairplot works fine for me, I have stumbled upon trying to make a nice lower-triangle pairplot ...
2
votes
1
answer
2k
views
How to change sort order of stacked bar chart using seaborn objects (v0.12)
I am using seaborn objects to plot a stacked bar chart and I am wondering what the right was is to change the sort order in which the bars are stacked.
Looking at this example:
import seaborn.objects ...
8
votes
2
answers
4k
views
How can I customize the legend with Seaborn 0.12 objects?
The new Seaborn objects (v 0.12) are great but I struggle to deal with legend customization. Especially when using matplotlib to define subplots. My code:
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, ...