seaborn

3D scatterplots in Python with hue colormap and legend

江枫思渺然 提交于 2020-07-05 02:43:33
问题 I have been searching for 3D plots in python with seaborn and haven't seen any. I would like to 3D plot a dataset that I originally plotted using seaborn pairplot. Can anyone help me with these 2 issues: I am not able to get same color palette as sns pairplot, e.g. how to get the color palette from figure 2 and apply to the points on figure 1? The legend does not stick to the plot or does not show up as nice on pairplot, e.g. When I do plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad

How to save multiple Seaborn plots into single pdf file

时光怂恿深爱的人放手 提交于 2020-06-28 04:22:20
问题 So I'm trying to save multiple plots that i create in a for loop into a single pdf file. I've searched around on SO and pieced together some code that seems to work except it doesn't save the figures it creates a pdf but without anything in it. Here's the code to reproduce it: import numpy as np import matplotlib.pyplot as plt import seaborn as sns import pandas as pd dftest = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)), columns=['a', 'b', 'c', 'd', 'e']) from matplotlib

Align line graph to xticks on dual axis plot with heatmap

陌路散爱 提交于 2020-06-27 16:43:34
问题 I'm trying to plot a line graph and a heatmap on a dual axis plot. This is what I'm getting: As you can see, the line graph isn't aligned to the xticks due to the presence of the heatmap, which centers the xticks. How can I shift the line graph to the right by 0.5 so that the data points on the line graph correctly correspond to the xticks? Below is my code: import matplotlib.pyplot as plt import seaborn as sns import numpy as np data1 = np.random.random((10, 10)) data2 = np.random.random((10

How to obtain xticks with alternating distances?

不问归期 提交于 2020-06-27 16:17:55
问题 I have a bar plot where the x-axis has the 2-letter labels of countries. I have to choose a very small font, so the x-ticks do not overlap with each other. Is there any way to assign a distance between x-ticks and the x-axis, so I can choose a larger font without labels being overlapped? Currently: Desired example: axis: ---------------------- ticks: c1 c3 ... c2 c4 ... 回答1: An approach is to create minor ticks at the alternating positions and give them a larger tick length. A MultipleLocator

How can I adjust the size of the whiskers in a Seaborn boxplot?

廉价感情. 提交于 2020-06-27 15:19:18
问题 I'd like to make the whisker lines wider in the following boxplot. import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt data = pd.DataFrame({'Data': np.random.random(100), 'Type':['Category']*100}) fig, ax = plt.subplots() # Plot boxplot setting the whiskers to the 5th and 95th percentiles sns.boxplot(x='Type', y='Data', data=data, color = 'gray', whis = [5,95]) # Adjust boxplot and whisker line properties for p, artist in enumerate(ax.artists): artist

How to annotate text from one column onto a seaborn plot

感情迁移 提交于 2020-06-27 04:16:42
问题 I have a seaborn line plot denoting one column, but would like to annotate text from another column just above the value shown in the line. I can't seem to figure out the syntax. The code below is a replica of my dataframe. I would like to have the numbers from the 'flag' column annotated above the line of the group their observation corresponds to. import pandas as pd import seaborn as sns import matplotlib.pyplot as plt d = {'group':[1,2,3,4,5,6,7,8,9,10] ,'y':[100,200,300,400,500,650,780

How to annotate text from one column onto a seaborn plot

一曲冷凌霜 提交于 2020-06-27 04:16:08
问题 I have a seaborn line plot denoting one column, but would like to annotate text from another column just above the value shown in the line. I can't seem to figure out the syntax. The code below is a replica of my dataframe. I would like to have the numbers from the 'flag' column annotated above the line of the group their observation corresponds to. import pandas as pd import seaborn as sns import matplotlib.pyplot as plt d = {'group':[1,2,3,4,5,6,7,8,9,10] ,'y':[100,200,300,400,500,650,780

Prevent Sharing of Y Axes in Seaborn Relplot?

你。 提交于 2020-06-26 04:43:09
问题 I'm having trouble getting seaborn's relplot function to plot with different y axes on each row (while sharing x axes per column). I can see that both the FacetGrid and catplot methods in seaborn have a sharex/sharey keyword argument that would solve my problem, but I can't find a similar one in relplot . Is there some way I can work around this if it's intended by accessing the subplots returned by relplot individually? I would like to continue using relplot as it handles figure sizing

Ascending order of bars in seaborn barplot

家住魔仙堡 提交于 2020-06-25 07:21:34
问题 I have the following dataframe Class Age Percentage 0 2004 3 43.491170 1 2004 2 29.616607 2 2004 4 13.838925 3 2004 6 10.049712 4 2004 5 2.637445 5 2004 1 0.366142 6 2005 2 51.267369 7 2005 3 19.589268 8 2005 6 13.730432 9 2005 4 11.155305 10 2005 5 3.343524 11 2005 1 0.913590 12 2005 9 0.000511 I would like to make a bar plot using seaborn where in the y-axis is the 'Percentage', in the x-axis is the 'Class' and label them using the 'Age' column. I would also like to arrange the bars in

Fill area of overlap between two normal distributions in seaborn / matplotlib

*爱你&永不变心* 提交于 2020-06-25 04:32:58
问题 I want to fill the area overlapping between two normal distributions. I've got the x min and max, but I can't figure out how to set the y boundaries. I've looked at the plt documentation and some examples. I think this related question and this one come close, but no luck. Here's what I have so far. import numpy as np import seaborn as sns import scipy.stats as stats import matplotlib.pyplot as plt pepe_calories = np.array([361, 291, 263, 284, 311, 284, 282, 228, 328, 263, 354, 302, 293, 254,