seaborn

How to zoom in a histogram in seaborn/matplotlib?

血红的双手。 提交于 2021-01-28 23:43:34
问题 I produced a histogram which looks something like this: Code that I used to produce this plot: sns.countplot(table.column_name) As you can notice, the entire histogram gets clustered at the left end due to uneven distribution of data. How do I zoom in at the left end? One way that I tried and it gave me a marginally better result was : plt.xlim(0,25) Is there a better way to do this? 回答1: Looks like the data would be better viewed on a logarithmic scale. On your matplotlib plot axis, ax , use

How to zoom in a histogram in seaborn/matplotlib?

我的梦境 提交于 2021-01-28 23:35:00
问题 I produced a histogram which looks something like this: Code that I used to produce this plot: sns.countplot(table.column_name) As you can notice, the entire histogram gets clustered at the left end due to uneven distribution of data. How do I zoom in at the left end? One way that I tried and it gave me a marginally better result was : plt.xlim(0,25) Is there a better way to do this? 回答1: Looks like the data would be better viewed on a logarithmic scale. On your matplotlib plot axis, ax , use

How to zoom in a histogram in seaborn/matplotlib?

一曲冷凌霜 提交于 2021-01-28 23:20:55
问题 I produced a histogram which looks something like this: Code that I used to produce this plot: sns.countplot(table.column_name) As you can notice, the entire histogram gets clustered at the left end due to uneven distribution of data. How do I zoom in at the left end? One way that I tried and it gave me a marginally better result was : plt.xlim(0,25) Is there a better way to do this? 回答1: Looks like the data would be better viewed on a logarithmic scale. On your matplotlib plot axis, ax , use

How to use scientific notation in Pairplot (seaborn)

徘徊边缘 提交于 2021-01-28 19:08:13
问题 Is there a way to force scientific notation using Seaborn's Pairplot? I'm hoping for some consistency between plots (examples below). I've found suggestions for other seaborn plots, but have not successfully implemented anything with Pairplot. https://seaborn.pydata.org/generated/seaborn.pairplot.html Versions: seaborn 0.8.1 numpy 1.13.1 matplotlib 2.0.2 pandas 0.23.0 Current plot: import numpy as np import pandas as pd import seaborn as sns from scipy import stats import matplotlib.pyplot as

Plotting binned correlation of two variables using common axis

Deadly 提交于 2021-01-28 11:40:21
问题 I have three lists that I have loaded into a pandas dataframe. import pandas as pd df = pd.DataFrame({'x': location}) df = df.assign(y1 = variable1) df = df.assign(y2 = variable2) I would like to plot the correlation of y1 with y2 with x being the common x-axis. That is, really, I would like to bin y1 and y2 values according to x location, find the correlation of y1 with y2 within each bin and then plot a line of the correlations across the whole x domain. So my final plot will have

Seaborn heatmap with numerical axes

夙愿已清 提交于 2021-01-28 10:41:00
问题 I want to overlay a heatmap with a second chart (a KDEplot, but for this example I'll use a scatterplot, since it shows the same issue). Seaborn heatmaps have categorical axes, so overlaying a chart with numerical axes doesn't line up the two charts properly. Example: df = pd.DataFrame({2:[1,2,3],4:[1,3,5],6:[2,4,6]}, index=[3,6,9]) df 2 4 6 3 1 1 2 6 2 3 4 9 3 5 6 fig, ax1 = plt.subplots(1,1) sb.heatmap(df, ax=ax1, alpha=0.1) Overlaying this with a scatterplot: fig, ax1 = plt.subplots(1,1)

Colour the x-values and show in legend instead of as ticks, in matplotlib (or seaborn)

…衆ロ難τιáo~ 提交于 2021-01-28 07:16:09
问题 I have a large df which I've grouped to plot in a bar chart. I made this mock df to show what I mean. (And I had way too much fun creating it...) my = pd.DataFrame( {'names': ['Andrea', 'Donna', 'Kelly', 'Brenda', 'Allison', 'Jo', 'Amanda', 'Jane', 'Kerry', 'Abby', 'Elizabeth', 'Haleh'], 'episodes': [ 147, 292, 292, 111, 160, 111, 199, 172, 250, 189, 160,184 ], 'tv-show' : ['Beverly Hills, 90210', 'Beverly Hills, 90210', 'Beverly Hills, 90210', 'Beverly Hills, 90210', 'Melrose place',

How to change the position of a single swarm group

一世执手 提交于 2021-01-28 06:58:39
问题 I am plotting a grouped bar plot on which I overlay a swarmplot and errorbars. One of the groups only have one bar, which I want to appear (with the swarm and the errorbar) in the middle of the location allocated to this group of bars. I managed to move the bar and the errorbar, but not sure how to move the swarm. Here is the code I have: import seaborn as sns import matplotlib.pyplot as plt mypallet = sns.color_palette([(190/256,7/256, 18/256),(127/256, 127/256, 127/256)]) import itertools

Plotting a barplot with a vertical line in pyplot-seaborn-pandas

烈酒焚心 提交于 2021-01-28 06:45:09
问题 I am having trouble doing something that seems to me straightforward. My data is: ROE_SP500_Q2_2018_quantile.to_json() '{"index":{"0":0.0,"1":0.05,"2":0.1,"3":0.15,"4":0.2,"5":0.25,"6":0.3,"7":0.35,"8":0.4,"9":0.45,"10":0.5,"11":0.55,"12":0.6,"13":0.65,"14":0.7,"15":0.75,"16":0.8,"17":0.85,"18":0.9,"19":0.95},"ROE_Quantiles":{"0":-0.8931,"1":-0.0393,"2":0.00569,"3":0.03956,"4":0.05826,"5":0.075825,"6":0.09077,"7":0.10551,"8":0.12044,"9":0.14033,"10":0.15355,"11":0.17335,"12":0.1878,"13":0

Can you copy only some subplots to a new figure?

耗尽温柔 提交于 2021-01-28 05:32:53
问题 Is there a way to copy an axis (subplot) to a new figure? This is straightforward in other languages, but I understand that not even a deep copy would work with python's matplotlib. E.g. if I have a figure with 6 subplots, how can I copy 2 of those subplots to a new figure, with all the settings? Labels, tickmarks, legend, grid, etc. I have found this answer , which is actually 2 in 1: the first no longer works (deprecated syntax), while I couldn't get the second to work in my case. I manage