seaborn

Assign specific color to seaborn heatmap

爷,独闯天下 提交于 2021-01-28 04:40:39
问题 I'm trying to make heatmap using seaborn, but got stuck to change color on specific values. Suppose, the value 0 should be white, and value 1 should be grey, then over that uses the palette as provided by cmap. Was trying to use mask, but got confused. import matplotlib.pyplot as plt import numpy as np import seaborn as sns import pandas as pd df = pd.read_csv('/home/test.csv', index_col=0) fig, ax = plt.subplots() sns.heatmap(df, cmap="Reds", vmin=0, vmax=15) plt.show() this for the sample

How to combine two relplots in seaborn python?

社会主义新天地 提交于 2021-01-28 02:05:43
问题 I would like to plot two data columns of a dataframe in a single plot using sns.relplot. The dataframe looks like this: index x-axis col1 col2 group group2 0 0 27 26 A C 1 1 45 27 B D 2 2 48 22 A C 3 3 35 24 B D 4 4 49 38 A C 5 5 46 29 B D 6 6 29 37 A C 7 7 38 41 B D 8 8 24 46 A C 9 9 46 38 B D 10 10 37 23 A C Here, I want to plot col1 and col2 together against x-axis data. 'group' is the value of 'hue', and 'group2' for 'col' in the relplot. I am able to plot the two columns separately using

Legend not showing when plotting multiple seaborn plots

天大地大妈咪最大 提交于 2021-01-28 01:05:54
问题 I typically don't have problems with matplotlib legend, but this is the first time I am using it with multiple seaborn plots, and the following does not work. fig = plt.figure(figsize=(10,6)) a =sns.regplot(x='VarX', y='VarY1', data=data) b = sns.regplot(x='VarX', y='VarY2', data=data) c = sns.regplot(x='VarX', y='VarY3', data=data) fig.legend(handles=[a, b, c],labels=['First','Second','Third']) fig.show() What am I doing wrong? 回答1: seaborn.regplot returns an axes. You cannot create a legend

How can I specify the color for a partial histogram patch?

半城伤御伤魂 提交于 2021-01-27 23:37:18
问题 I would like to produce the following graph Note that one bar is partially blue and partially teal. This is what I'm trying to reproduce import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np from matplotlib.patches import Rectangle # plt parameters plt.rcParams['figure.figsize'] = (10.0, 10.0) plt.style.use('seaborn-dark-palette') plt.rcParams['axes.grid'] = True plt.rcParams["patch.force_edgecolor"] = True # data np.random.seed(365) replicates = np

Plotting three dimensions of categorical data in Python

空扰寡人 提交于 2021-01-27 20:41:41
问题 My data has three categorical variables I'm trying to visualize: City (one of five) Occupation (one of four) Blood type (one of four) So far, I've succeeded in grouping the data in a way that I think will be easy to work with: import numpy as np, pandas as pd # Make data cities = ['Tijuana','Las Vegas','Los Angeles','Anaheim','Atlantis'] occupations = ['Doctor','Lawyer','Engineer','Drone security officer'] bloodtypes = ['A','B','AB','O'] df = pd.DataFrame({'City': np.random.choice(cities,500)

How to set the hue range for a numeric variable using a colored bubble plot in seaborn, python?

女生的网名这么多〃 提交于 2021-01-27 19:52:50
问题 I'm trying to use seaborn to create a colored bubbleplot of 3-D points (x,y,z), each coordinate being an integer in range [0,255]. I want the axes to represent x and y, and the hue color and size of the scatter bubbles to represent the z-coordinate. The code: import seaborn seaborn.set() import pandas import matplotlib.pyplot x = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200] y = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200] z = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200] df =

How to create a heat-map with multiple colormaps?

笑着哭i 提交于 2021-01-27 19:05:23
问题 As illustrated below, I am looking for an easy way to combine two or more heat-maps into one, i.e., a heat-map with multiple colormaps. The idea is to break each cell into multiple sub-cells. I couldn't find any python library with such a visualization function already implemented. Anybody knows something (at least) close to this? 回答1: The heatmaps can be drawn column by column. White gridlines can mark the cell borders. import numpy as np from matplotlib import pyplot as plt a = np.random

Seaborn AttributeError: module 'seaborn' has no attribute 'displot' AND conda Solving environment fail

ε祈祈猫儿з 提交于 2021-01-27 07:33:16
问题 As per seaborn documentation here seaborn.distplot() has been deprecated with the forward going supported plots being: seaborn.displot() and seaborn.histplot() . However, when I try to use either of displot() or histplot() I get the following Attribute error: AttributeError: module 'seaborn' has no attribute 'displot' Note I can succesfully run seaborn.jointplot() and various others. I found this SO post Module Seaborn has no attribute '' but that doesn't seem to be the solution to my issue.

Seaborn AttributeError: module 'seaborn' has no attribute 'displot' AND conda Solving environment fail

我怕爱的太早我们不能终老 提交于 2021-01-27 07:32:43
问题 As per seaborn documentation here seaborn.distplot() has been deprecated with the forward going supported plots being: seaborn.displot() and seaborn.histplot() . However, when I try to use either of displot() or histplot() I get the following Attribute error: AttributeError: module 'seaborn' has no attribute 'displot' Note I can succesfully run seaborn.jointplot() and various others. I found this SO post Module Seaborn has no attribute '' but that doesn't seem to be the solution to my issue.

How to use custom error bar in seaborn lineplot?

喜你入骨 提交于 2021-01-27 07:04:03
问题 I am using seaborn.lineplot to generate some time series plots. I have pre-compute a specific kind of error bars in two lists, e.g., upper=[1,2,3,4,5] lower=[0,1,2,3,4] . Is there a way I could customize the error bar here, instead of using the CI or Std error bars in lineplot ? 回答1: If you want error bands/bars other than the ones that seaborn.lineplot offers, you have to plot them yourself. Here are a couple examples of how to draw an error band and error bars in matplotlib and get plots