seaborn

How to create groupby subplots in Pandas?

扶醉桌前 提交于 2019-12-18 04:20:47
问题 I've got a dataframe with timeseries data of crime with a facet on offence (which looks like the format below). What I'd like to perform a groupby plot on the dataframe so that it's possible to explore trends in crime over time. Offence Rolling year total number of offences Month 0 Criminal damage and arson 1001 2003-03-31 1 Drug offences 66 2003-03-31 2 All other theft offences 617 2003-03-31 3 Bicycle theft 92 2003-03-31 4 Domestic burglary 282 2003-03-31 I've got some code which does the

Add Legend to Seaborn point plot

烂漫一生 提交于 2019-12-18 03:55:34
问题 I am plotting multiple dataframes as point plot using seaborn . Also I am plotting all the dataframes on the same axis . How would I add legend to the plot ? My code takes each of the dataframe and plots it one after another on the same figure. Each dataframe has same columns date count 2017-01-01 35 2017-01-02 43 2017-01-03 12 2017-01-04 27 My code : f, ax = plt.subplots(1, 1, figsize=figsize) x_col='date' y_col = 'count' sns.pointplot(ax=ax,x=x_col,y=y_col,data=df_1,color='blue') sns

Plotting two distributions in seaborn.jointplot

≡放荡痞女 提交于 2019-12-18 03:35:17
问题 I have two pandas dataframes I would like to plot in the same seaborn jointplot. It looks something like this (commands are don in an IPython shell; ipython --pylab ): import pandas as pd import seaborn as sns iris = sns.load_dataset('iris') df = pd.read_csv('my_dataset.csv') g = sns.jointplot('sepal_length', 'sepal_width', iris) The keys in the two dataframes are identical. How do I plot my values in the same plot (different color of course)? And even more detailed: How do I plot both

How do I create a multiline plot using seaborn?

混江龙づ霸主 提交于 2019-12-18 02:18:24
问题 I am trying out Seaborn to make my plot visually better than matplotlib. I have a dataset which has a column 'Year' which I want to plot on the X-axis and 4 Columns say A,B,C,D on the Y-axis using different coloured lines. I was trying to do this using the sns.lineplot method but it allows for only one variable on the X-axis and one on the Y-axis. I tried doing this sns.lineplot(data_preproc['Year'],data_preproc['A'], err_style=None) sns.lineplot(data_preproc['Year'],data_preproc['B'], err

Show confidence limits and prediction limits in scatter plot

▼魔方 西西 提交于 2019-12-17 22:42:10
问题 I have two arrays of data as hight and weight: import numpy as np, matplotlib.pyplot as plt heights = np.array([50,52,53,54,58,60,62,64,66,67,68,70,72,74,76,55,50,45,65]) weights = np.array([25,50,55,75,80,85,50,65,85,55,45,45,50,75,95,65,50,40,45]) plt.plot(heights,weights,'bo') plt.show() I want to produce the plot similiar to this: http://www.sas.com/en_us/software/analytics/stat.html#m=screenshot6 Any ideas is appreciated. 回答1: Here's what I put together. I tried to closely emulate your

How to express classes on the axis of a heatmap in Seaborn

。_饼干妹妹 提交于 2019-12-17 22:35:07
问题 I created a very simple heatmap chart with Seaborn displaying a similarity square matrix. Here is the one line of code I used: sns.heatmap(sim_mat, linewidths=0, square=True, robust=True) sns.plt.show() and this is the output I get: What I'd like to do is to represent on the x and y axis not the labels of my instances but a colored indicator (imagine something like a small palplot on each axis) where each color represents another variable associated to each instance (let's say I have this

Multi-line chart with seaborn tsplot

浪子不回头ぞ 提交于 2019-12-17 20:54:06
问题 I want to create a smoothed line chart using matplotlib and seaborn. This is my dataframe df : hour direction hourly_avg_count 0 1 20 1 1 22 2 1 21 3 1 21 .. ... ... 24 1 15 0 2 24 1 2 28 ... ... ... The line chart should contain two lines, one for direction equal to 1, another for direction equal to 2. The X axis is hour and Y axis is hourly_avg_count . I tried this, but I cannot see the lines. import pandas as pd import seaborn as sns import matplotlib import matplotlib.pyplot as plt plt

Sorted bar charts with pandas/matplotlib or seaborn

喜夏-厌秋 提交于 2019-12-17 19:23:51
问题 I have a dataset of 5000 products with 50 features. One of the column is 'colors' and there are more than 100 colors in the column. I'm trying to plot a bar chart to show only the top 10 colors and how many products there are in each color. top_colors = df.colors.value_counts() top_colors[:10].plot(kind='barh') plt.xlabel('No. of Products'); Using Seaborn: sns.factorplot("colors", data=df , palette="PuBu_d"); 1) Is there a better way to do this? 2) How can i replicate this with Seaborn? 3)

Can I mimic a log scale of an axis in matplotlib without transforming the associated data?

一世执手 提交于 2019-12-17 16:53:16
问题 I am trying to display a Zipf plot, which is typically displayed on a log-log scale. I'm using a library which gives rank in linear scale and frequencies in log scale. I have the following code which plots my data fairly correctly: ranks = [3541, 60219, 172644, 108926, 733215, 1297533, 1297534, 1297535] # These frequencies are already log-scale freqs = [-10.932271003723145, -15.213129043579102, -17.091760635375977, -16.27560806274414, -19.482173919677734, -19.502029418945312, -19

Can I mimic a log scale of an axis in matplotlib without transforming the associated data?

旧城冷巷雨未停 提交于 2019-12-17 16:53:14
问题 I am trying to display a Zipf plot, which is typically displayed on a log-log scale. I'm using a library which gives rank in linear scale and frequencies in log scale. I have the following code which plots my data fairly correctly: ranks = [3541, 60219, 172644, 108926, 733215, 1297533, 1297534, 1297535] # These frequencies are already log-scale freqs = [-10.932271003723145, -15.213129043579102, -17.091760635375977, -16.27560806274414, -19.482173919677734, -19.502029418945312, -19