How can i plot multiple distribution plots with Seaborn? [duplicate] - python

This question already has answers here:
seaborn distplot / displot with multiple distributions
(6 answers)
Plotting multiple seaborn displot
(1 answer)
seaborn is not plotting within defined subplots
(1 answer)
Closed 9 months ago.
I am not experienced with plotting in Python. But I have managed to plot a signle distribution plot with Seaborn.
example code:
sns.displot(SD_frame_A,kind="kde")
example plot:
So I tryed to plot three of them in one graph:
example code:
sns.displot(SD_frame_A,kind="kde")
sns.displot(SD_frame_S,kind="kde")
sns.displot(SD_frame_D,kind="kde")
plt.show()
But this will only plot the three distribution separately. Does anyone how I can plot both 3 distribution in one plot?
Thanks for reading!

You can't do that with displot because that is a figure-level function. But you can use kdeplot and provide an axes object:
ax = plt.axes()
sns.kdeplot(SD_frame_A, ax=ax)
sns.kdeplot(SD_frame_S, ax=ax)
sns.kdeplot(SD_frame_D, ax=ax)
plt.show()

Related

How do I change the color of the markers and width of the figure in this boxplot using seaborn? [duplicate]

This question already has answers here:
Setting flier (outlier) style in Seaborn boxplot is ignored
(2 answers)
How to change the figure size of a seaborn axes or figure level plot
(13 answers)
Closed 2 months ago.
Using seaborn I want to change the color of the outlier markers to red. I also want to reduce the width of the figure to get rid of the whitespcace.
This is my current code and the graph it produces:
import seaborn as sns
import matplotlib.pyplot as plt
rbp_box = sns.boxplot(data=df_raw, y="Resting blood pressure", color="red", flierprops={"marker": "x"}, width=0.2)
rbp_box.set(xlabel='', ylabel='mm Hg', title='Resting blood pressure box plot')
box plot

stripplot and box plot from dataframe in python [duplicate]

This question already has answers here:
seaborn boxplot and stripplot points aren't aligned over the x-axis by hue
(1 answer)
Seaborn boxplot + stripplot: duplicate legend
(2 answers)
How to do a boxplot with individual data points using seaborn
(1 answer)
How to overlay data points on seaborn figure-level boxplots
(2 answers)
Closed 7 months ago.
I'm trying to make a box plot and a strip plot from the following dataframe, but I think I'm not putting the arguments or maybe the df should be re-arranged but I don't know how.
the dataframe is here
I'm hopping to have a strip plot and a box for each color (column) in the same plot.
I'd be grateful if you could help

Problem on combining bar and line plot in seaborn [duplicate]

This question already has answers here:
How to plot seaborn lineplot and barplot on the same plot with same number of y-axes tickers and both y-axes aligned at 0 in Python
(2 answers)
How to line plot timeseries data on a bar plot
(1 answer)
Problem in combining bar plot and line plot (python)
(2 answers)
Closed 7 months ago.
I am trying to combine a line plot and bar plot in seaborn. Code is as below:)
fig, ax1 = plt.subplots(figsize=(10,6))
sns.barplot(x=df_mergedpa['Day'], y=df_mergedpa['pro_mean'],hue=df_mergedpa['Strain'], ax=ax1)
ax2 = ax1.twinx()
sns.lineplot(x=df_mergedpa['Day'],y=df_mergedpa['ami_mean'],hue=df_mergedpa['Strain'],
marker='o', ax=ax1)
The plot I am getting is as above:
Why the line plot is not rendering properly. It is extending in X-Axis. I am not able to figure out why?
Dataframe looks as below:

seaborn.lmplot with single axes labels [duplicate]

This question already has answers here:
Python Seaborn Facetgrid change xlabels
(2 answers)
Common xlabel/ylabel for matplotlib subplots
(8 answers)
How to add a shared x-label and y-label to a plot created with pandas plot
(4 answers)
One shared x-axis label for Seaborn FacetGrid subplots (layouts/spacing?)
(1 answer)
How to set common axes labels for subplots
(9 answers)
Closed last year.
What I need should be straighforward but I couldn't find a solution. Say we draw the following seaborn.lmplot:
import seaborn as sns; sns.set_theme(color_codes=True)
tips = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", col="day", hue="day",
data=tips, col_wrap=2, height=3)
I simply want to have a single label for the x-axis and a single label for the y-axis instead of two as currently.
In other words, that the word 'tip' be printed only one time on the centre left of the graph, and that the word 'total_bill' be printed only one time on the bottom centre of the graph.
How do we do this?
EDIT: there is a similar question here One shared x-axis label for Seaborn FacetGrid subplots (layouts/spacing?) yet it is not elaborated and does not solve my issue.

Numpy histogram no boundaries between bins [duplicate]

This question already has answers here:
No outlines on bins of Matplotlib histograms or Seaborn distplots
(3 answers)
Closed 5 years ago.
I wonder why the bins are not showing a boundary between each other. It's confusing to look at it. I attached an example below:
for key,value in dict.items():
plt.figure()
plt.hist( value, bins='auto')
plt.title("Histogram for THR")
plt.show()
That's the new default style for matplotlib 2.0 (for example, see the plots from the documentation for plt.hist in v2.0).
To force the edges of the bins to be displayed you can pass the edgecolor= (or ec=) argument to plt.hist, e.g. plt.hist(values, bins='auto', ec='k') for black bin edges.

Categories

Resources