seaborn

Regression line using Relplot in seaborn

老子叫甜甜 提交于 2021-02-10 20:00:35
问题 Below is a working example where I need to draw regression line. I have searched online but I see another function like regplot, implot to draw regression lines but here I am using replot. How I can draw regression line using relplot? from matplotlib import pyplot as plt import pandas as pd import seaborn as sns d = {'x-axis':[100,915,298,299], 'y-axis': [1515,1450,1313,1315], 'text':['point1','point2','point3','point4']} df = pd.DataFrame(d) p1 = sns.relplot(x='x-axis', y='y-axis',data=df )

Seaborn correlation heatmap with equal cell size

夙愿已清 提交于 2021-02-10 16:18:08
问题 I am plotting various correlation matrices with a different number of columns using seaborn. For the sake of eye-candy, I'd like to have all correlation matrices to have the same cell size. Unfortunately, I am not able to parameterize seaborn to do so. Here is a minimal example: from string import ascii_letters import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Generate two random dataset rs = np.random.RandomState(42) d1 = pd.DataFrame(data=rs

create seaborn plot with pandas of matplotlib

本小妞迷上赌 提交于 2021-02-10 14:35:53
问题 I'm struggling to (re)create a seaborn plot with pandas or matplotlib. DataFrame: wage = pd.melt(pd.read_html('https://en.wikipedia.org/wiki/List_of_countries_by_average_wage')[8].iloc[:5], id_vars=['Country'],var_name='Year', value_name='Wage') print(wage.sample(n=7)) Result: Country Year Wage 29 Netherlands 2013 52808 38 United States 2015 60692 4 Netherlands 2000 47596 9 Netherlands 2005 49939 23 United States 2012 58669 46 Switzerland 2017 62283 12 Iceland 2010 44558 The plot using

How can a circle be drawn over a Seaborn plot?

橙三吉。 提交于 2021-02-10 14:27:50
问题 I have a Seaborn Joinplot on which I want to draw an empty circle which will mark a certain diameter around the (0,0) point. Something like this: How can it be done? 回答1: ax_joint.plot will do the job. import matplotlib.pyplot as plt import seaborn as sns sns.set(style="white", color_codes=True) tips = sns.load_dataset("tips") a = sns.jointplot(x="total_bill", y="tip", data=tips) a.ax_joint.plot([15],[3],'o',ms=60,mec='r',mfc='none') 回答2: I found the answer: a = sns.jointplot(x=var_x, y=var_y

How to make histograms in Python (scipy.stats) look as good as R?

北城余情 提交于 2021-02-10 14:17:18
问题 The following plot and its code were generated in R (source). How can I replicate this quality of a histogram in Python code using scipy.stats ? x = rgamma(1000, 3, .1) hist(x, prob=T, br=30, col="skyblue2", main="n = 1000: GAMMA(3, .1)") curve(dgamma(x, 3, .1), add=T, lwd=2, col="orange") abline(v = 55.81, lwd=2, col="blue") abline(v = 53.2232, lwd=2, col="brown", lty="dotted") The R plot above is alot better than Python's scipy.stats histograms, one example shown below, but I know there are

How to make histograms in Python (scipy.stats) look as good as R?

时间秒杀一切 提交于 2021-02-10 14:14:59
问题 The following plot and its code were generated in R (source). How can I replicate this quality of a histogram in Python code using scipy.stats ? x = rgamma(1000, 3, .1) hist(x, prob=T, br=30, col="skyblue2", main="n = 1000: GAMMA(3, .1)") curve(dgamma(x, 3, .1), add=T, lwd=2, col="orange") abline(v = 55.81, lwd=2, col="blue") abline(v = 53.2232, lwd=2, col="brown", lty="dotted") The R plot above is alot better than Python's scipy.stats histograms, one example shown below, but I know there are

How to plot only the lower triangle of a seaborn heatmap?

眉间皱痕 提交于 2021-02-10 06:16:06
问题 I've a list of lists all_genres where each sub-lists contain genres for a particular tv-show and each different sub-list refers to different tv-shows. I want to plot a seaborn heatmap but with only the lower traiangle part. Here is what I've tried so far : import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(rc={'figure.figsize':(16,9)}) all_genres = [['Drama', 'History'], ['Documentary'], ['Action', 'Drama', 'History'], ['Documentary'], ['Crime', 'Drama',

Setting the interval of x-axis for seaborn plot

一曲冷凌霜 提交于 2021-02-10 04:21:16
问题 I have a set of subplots to plot. Here, how do we set the interval for x-axis in the subplot in second row, i.e ax4 to ax6 . Currently all the values from 1 to 100 are printed as shown in the figure. I tried ax4.set_xticks(range(1,100,5)) . But there, the range shown was 1 to 20. I was expecting a range from 1 to 100, with an interval of 5, i.e. 1,5,10...95,100 Currently the plot has x-axis as shown below. I have not added the code for first row. yInit = initRes yInit = yInit[(yInit['nodeSKT'

Seaborn: Specify an exact color

∥☆過路亽.° 提交于 2021-02-08 13:28:07
问题 You can specify a color for plots, but Seaborn will mute the color a bit during plotting. Is there a way to turn off this behavior? Example: import matplotlib import seaborn as sns import numpy as np # Create some data np.random.seed(0) x = np.random.randn(100) # Set the Seaborn style sns.set_style('white') # Specify a color for plotting current_palette = matplotlib.colors.hex2color('#86b92e') # Make a plot g = sns.distplot(x, color=current_palette) # Show what the color should look like sns

Seaborn Lineplot Module Object Has No Attribute 'Lineplot'

北城余情 提交于 2021-02-08 12:17:58
问题 Using seaborn's documentation code to generate a lineplot returns an AttributeError: 'module' object has no attribute 'lineplot'. I have updated seaborn and reimported the module and tried again, no luck. Did lineplot get retired, or is there something else going on? import seaborn as sns; sns.set() import matplotlib.pyplot as plt fmri = sns.load_dataset("fmri") ax = sns.lineplot(x="timepoint", y="signal", data=fmri) 回答1: If you are using conda, you need to install seaborn with the version