seaborn

Markers are not visible in seaborn plot

£可爱£侵袭症+ 提交于 2020-01-24 09:23:31
问题 Here is an example: import seaborn as sns ax = sns.lineplot(range(10), range(10), markers=True) Why aren't there any markers although I set markers=True ? 回答1: Basically, because that's not what markers= is for. As per the documentation: markers : boolean, list, or dictionary, optional Object determining how to draw the markers for different levels of the style variable. Setting to True will use default markers, or you can pass a list of markers or a dictionary mapping levels of the style

Python seaborn facetGrid: Is it possible to set row category label location to the left

喜你入骨 提交于 2020-01-24 03:06:45
问题 When using Seaborn facetGrid plots. Is it possible to set the row variable label to the left (eg. as the first line of the two-line sub-plots y axes label)? The default location is on the top as part of the sub-plot title. unfortunately the combined text sometimes gets too long to legitably fit into that crowded space. Then I tried to use margin_titles = True option when instantiate the facetGrid object. But in this case, the row variable label is outside to the right of the legend, which can

heatmap-like plot, but for categorical variables in seaborn

醉酒当歌 提交于 2020-01-24 02:21:12
问题 Same question as heatmap-like plot, but for categorical variables but using python and seaborn instead of R: Imagine I have the following dataframe: df = pd.DataFrame({"John":"No Yes Maybe".split(), "Elly":"Yes Yes Yes".split(), "George":"No Maybe No".split()}, index="Mon Tue Wed".split()) Now I would like to plot a heatmap and color each cell by its corresponding value. That is "Yes", "No", "Maybe", for instance becomes "Green", "Gray", "Yellow". The legend should have those three colors and

Custom Colormap

安稳与你 提交于 2020-01-23 13:04:13
问题 I want to plot a heatmap with a custom colormap similar to this one, although not exactly. I'd like to have a colormap that goes like this. In the interval [-0.6, 0.6] the color is light grey. Above 0.6, the color red intensifies. Below -0.6 another color, say blue, intensifies. How can I create such a colormap using python and matplotlib? What I have so far: In seaborn there is the command seaborn.diverging_palette(220, 10, as_cmap=True) which produces a colormap going from blue-light grey

How to add the second line of labels for axes

泪湿孤枕 提交于 2020-01-23 07:27:44
问题 I am trying to plot a set of survey question in different categories. As shown in the picture, the Xlabel is the name of each question. But I want to add another label underneath with the name of the category: [general info, technical, psychological]. Anyway of doing that instead of manually putting it in using the plt.text(). Another way I can do is to put a legend in for the category based color coding of the bar. But I think putting a second xlabel makes it easier to read. 回答1: Use the '\n

How to add the second line of labels for axes

瘦欲@ 提交于 2020-01-23 07:27:16
问题 I am trying to plot a set of survey question in different categories. As shown in the picture, the Xlabel is the name of each question. But I want to add another label underneath with the name of the category: [general info, technical, psychological]. Anyway of doing that instead of manually putting it in using the plt.text(). Another way I can do is to put a legend in for the category based color coding of the bar. But I think putting a second xlabel makes it easier to read. 回答1: Use the '\n

Seaborn ImportError: DLL load failed: The specified module could not be found

与世无争的帅哥 提交于 2020-01-22 21:48:31
问题 I am getting the "ImportError: DLL load failed: The specified module could not be found." when importing the module seaborn . I tried uninstalling both seaborn and matplotlib, then reinstalling by using pip install seaborn but no luck. I still get the same error. ImportError Traceback (most recent call last) <ipython-input-5-085c0287ecb5> in <module>() ----> 1 import seaborn C:\Users\johnsam\venv\lib\site-packages\seaborn\__init__.py in <module>() 4 5 # Import seaborn objects ----> 6 from

Hue parameter in seaborn FacetGrid

江枫思渺然 提交于 2020-01-22 12:15:48
问题 I am having a problem with Facetgrid: when I use the hue parameter, the x-labels show up in the wrong order and do not match the data. Loading the Titanic dataset in ipython: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import seaborn as sns titanic = sns.load_dataset("titanic") g = sns.FacetGrid(titanic, col='pclass', hue='survived') g = g.map(sns.swarmplot, 'sex', 'age') Facetgrid with Hue: From this it seems that there are more females than males, but this is not

Hue parameter in seaborn FacetGrid

让人想犯罪 __ 提交于 2020-01-22 12:15:21
问题 I am having a problem with Facetgrid: when I use the hue parameter, the x-labels show up in the wrong order and do not match the data. Loading the Titanic dataset in ipython: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import seaborn as sns titanic = sns.load_dataset("titanic") g = sns.FacetGrid(titanic, col='pclass', hue='survived') g = g.map(sns.swarmplot, 'sex', 'age') Facetgrid with Hue: From this it seems that there are more females than males, but this is not

A convenient way to plot bar-plot in Python pandas

雨燕双飞 提交于 2020-01-21 10:36:28
问题 I have a DataFrame contains as following, where first row is the "columns": id,year,type,sale 1,1998,a,5 2,2000,b,10 3,1999,c,20 4,2001,b,15 5,2001,a,25 6,1998,b,5 ... I want to draw two figures, the first one is like The second one is like Figures in my draft might not be in right scale. I am a newbie to Python and I understand plotting functionality is powerful in Python. I believe there must be very easy to plot such figures. 回答1: The Pandas library provides simple and efficient tools to