seaborn

[Pyhon疫情大数据分析] 一.腾讯实时数据爬取、Matplotlib和Seaborn可视化分析全国各地区、某省各城市、新增趋势

孤街醉人 提交于 2020-02-18 00:36:53
思来想去,虽然很忙,但还是挤时间针对这次肺炎疫情写个Python大数据分析系列博客,包括网络爬虫、可视化分析、GIS地图显示、情感分析、舆情分析、主题挖掘、威胁情报溯源、知识图谱、预测预警及AI和NLP应用等。希望该系列线上远程教学对您有所帮助,也希望早点战胜病毒,武汉加油、湖北加油、全国加油。待到疫情结束樱花盛开,这座英雄的城市等你们来。 第一篇文章将分享腾讯疫情实时数据抓取,获取全国各地和贵州省各地区的实时数据,并将数据存储至本地,最后调用Maplotlib和Seaborn绘制中国各地区、贵州省各城市、新增人数的图形。希望这篇可视化分析文章对您有所帮助,也非常感谢参考文献中老师的分享,一起加油,战胜疫情!如果您有想学习的知识或建议,可以给作者留言~ 文章目录 一.Python实时数据爬取 二.Matplotlib绘制全国各地区柱状图 三.数据存储及Seaborn绘制全国各地区柱状图 四.Seaborn绘制全国各地区对比柱状图 五.Seaborn绘制疫情趋势图及湖北省内外对比图 六.Seaborn绘制其他图形及分析 七.贵州省可视化分析 八.总结 同时推荐前面作者另外五个Python系列文章。从2014年开始,作者主要写了三个Python系列文章,分别是基础知识、网络爬虫和数据分析。2018年陆续增加了Python图像识别和Python人工智能专栏。 Python基础知识系列:

How to invert color of seaborn heatmap colorbar

雨燕双飞 提交于 2020-02-17 05:53:08
问题 I use an heatmap to visualize a confusion matrix. I like the standard colors, but I would like to have 0s in light orange and highest values in dark purple. I managed to do so only with another set of colors (light to dark violet), setting: colormap = sns.cubehelix_palette(as_cmap=True) ax = sns.heatmap(cm_prob, annot=False, fmt=".3f", xticklabels=print_categories, yticklabels=print_categories, vmin=-0.05, cmap=colormap) But I want to keep these standard ones. This is my code and the image I

python可视化(十种常用图)

你离开我真会死。 提交于 2020-02-08 15:09:20
python的可视化库(seaborn和matplotlib) 今天我将和大家一起入门这十种简单图的绘制 1.散点图 import numpy as np import pandas as pd import matplotlib . pyplot as plt import seaborn as sns # 数据准备 N = 1000 x = np . random . randn ( N ) y = np . random . randn ( N ) # 用Matplotlib画散点图 plt . scatter ( x , y , marker = 'x' ) plt . show ( ) # 用Seaborn画散点图 df = pd . DataFrame ( { 'x' : x , 'y' : y } ) sns . jointplot ( x = "x" , y = "y" , data = df , kind = 'scatter' ) ; plt . show ( ) 2.折线图 import pandas as pd import matplotlib . pyplot as plt import seaborn as sns # 数据准备 x = [ 2010 , 2011 , 2012 , 2013 , 2014 , 2015 , 2016 , 2017 ,

Colorbar not shown in multiple Seaborn Jointplot

别说谁变了你拦得住时间么 提交于 2020-02-07 01:59:12
问题 As suggested in the answer of question, it's possible to plot multiple Seanborn Jointplot by SeabornFig2Grid . However, the colorbars aren't shown: import matplotlib.pyplot as plt import seaborn as sns; sns.set(style="white", color_codes=True) import seabornfig2grid as sfg import matplotlib.gridspec as gridspec iris = sns.load_dataset("iris") g1 = sns.jointplot("sepal_width", "petal_length", data=iris, kind="kde", space=0, color="g", cbar=True, cbar_kws={"label": 'Normalized Densities'}, ) g2

python画图吐血大集合

﹥>﹥吖頭↗ 提交于 2020-02-02 23:51:31
目录 折线图 直方图 垂直条形图 水平条形图 饼图 箱线图 热力图 散点图 蜘蛛图 二元变量分布 面积图 六边形图 以下默认所有的操作都先导入了Numpy、pandas、matplotlib、seaborn import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns 折线图 折线图可以用来表示数据随着时间变化的趋势 x = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019] y = [5, 3, 6, 20, 17, 16, 19, 30, 32, 35] Matplotlib plt.plot(x, y) plt.show() Seaborn df = pd.DataFrame({'x': x, 'y': y}) sns.lineplot(x="x", y="y", data=df) plt.show() 直方图 直方图是比较常见的视图,它是把横坐标等分成了一定数量的小区间,然后在每个小区间内用矩形条(bars)展示该区间的数值 a = np.random.randn(100) s = pd.Series(a) Matplotlib plt.hist(s) plt.show()

Changing color scale/gradient vertically in bar like plot using seaborn

笑着哭i 提交于 2020-02-02 13:23:09
问题 I wanted to have vertical gradient for each bar of the seaborn barplot/countplot , (source: pydata.org) #to reproduce above plot import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(style="whitegrid", color_codes=True) np.random.seed(sum(map(ord, "categorical"))) titanic = sns.load_dataset("titanic") sns.countplot(x="deck", data=titanic, palette="Greens_d") plt.show() This image has horizontal gradient but I want the gradient to be vertical, like the linear down or

Changing color scale/gradient vertically in bar like plot using seaborn

天涯浪子 提交于 2020-02-02 13:22:51
问题 I wanted to have vertical gradient for each bar of the seaborn barplot/countplot , (source: pydata.org) #to reproduce above plot import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(style="whitegrid", color_codes=True) np.random.seed(sum(map(ord, "categorical"))) titanic = sns.load_dataset("titanic") sns.countplot(x="deck", data=titanic, palette="Greens_d") plt.show() This image has horizontal gradient but I want the gradient to be vertical, like the linear down or

Seaborn : How to get the count in y axis for distplot using PairGrid

让人想犯罪 __ 提交于 2020-02-02 10:54:59
问题 I'm using PairGrid but I don't understand what does y axis means for distplot. I thought it represents a count. But it's starting from negative values in the pairgrid. If I make only the distplot, I'm getting the count. I don't know if it's clear so, there's some plots : My PairGrid: My distplot : The distplot is the same as the plot in the top left corner of the PairGrid. The code corresponding to this is : sns.distplot(pd.DataFrame(mySerie), kde=False) and for the PairGrid : g = sns

Seaborn - 05 分类值可视化

泪湿孤枕 提交于 2020-01-31 15:19:09
import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns sns.set(style="whitegrid", color_codes=True) np.random.seed(sum(map(ord, "categorical"))) titanic = sns.load_dataset("titanic") tips = sns.load_dataset("tips") iris = sns.load_dataset("iris") 用stripplot展示类别值,类似于散点图 sns.stripplot(x="day", y="total_bill", data=tips,jitter=False) 该方法不适合于数据量特别大的场合,如果那样,则纵轴数据会连成一条线,很难区分数据的差异/重叠是很常见的现象,但是重叠影响我观察数据的量了,最好加入jitter sns.stripplot(x="day", y="total_bill", data=tips, jitter=True) sns.swarmplot(x="day", y="total_bill", data=tips) sns

[工具]数据可视化的几种武器

て烟熏妆下的殇ゞ 提交于 2020-01-25 23:34:36
作为Python用户,在进行数据可视化时可能用到的工具包括:matplotlib,seaborn,plotly,Vega-Lite以及Altair。其中Vega-Lite是基于JSON进行图形表达的独立语言标准,其余均为Python内的软件包。 matplotlib 这是Python中最基础也是最重要的作图软件包,为许多其他作图软件树立了标杆,实际上也提供了一种描述图形的语言。 下面是matplotlib官方示例中绘制PSD(Power Spectral Density)的示例代码: import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlab import matplotlib.gridspec as gridspec # Fixing random state for reproducibility np.random.seed(19680801) dt = 0.01 t = np.arange(0, 10, dt) nse = np.random.randn(len(t)) r = np.exp(-t / 0.05) cnse = np.convolve(nse, r) * dt cnse = cnse[:len(t)] s = 0.1 * np.sin(2 * np.pi