python;gutter:true;</p>
<h1>!/usr/bin/python</h1>
<h1>-<em>- coding: -</em>-</h1>
<p>import matplotlib.pyplot as plt
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import pymssql # 引入pymssql模块
import seaborn as sns # Provides a high level interface for drawing attractive and informative statistical graphics
from matplotlib.font_manager import FontProperties
from pylab import *
import matplotlib.pyplot as plt
import seaborn as sns</p>
<p>plt.rcParams['font.sans-serif'] = ['SimHei']</p>
<h1>Matplotlib中设置字体-黑体,解决Matplotlib中文乱码问题</h1>
<p>plt.rcParams['axes.unicode_minus'] = False</p>
<h1>解决Matplotlib坐标轴负号'-'显示为方块的问题</h1>
<p>sns.set(font='SimHei')</p>
<h1>Seaborn中设置字体-黑体,解决Seaborn中文乱码问题</h1>
<p>import warnings # Ignore warning related to pandas_profiling
warnings.filterwarnings('ignore')
conn = pymssql.connect(host='localhost', user='wonderful', password='wonderful', database='ProcreateV93',charset='GBK')</p>
<p>font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=10)
sql = "select username,COUNT(DISTINCT o_id) AS Oidcount from Oplan GROUP BY username order by Oidcount desc "
df0 = pd.read_sql(sql, conn)
df = pd.DataFrame(df0)</p>
<h1>orient='h'表示是水平展示的,alpha表示颜色的深浅程度</h1>
<h1>设置y轴、X轴的坐标名字与字体大小</h1>
<p>sns.barplot(x=df.username.values,y=df.Oidcount.values,orient='v', color='green')</p>
<p>plt.xlabel('医生')
plt.ylabel('患者数')</p>
<h1>设置X轴的各列下标字体是水平的</h1>
<p>plt.xticks(rotation='horizontal')</p>
<h1>设置Y轴下标的字体大小</h1>
<p>plt.show()
Original: https://www.cnblogs.com/canyangfeixue/p/15386654.html
Author: 残阳飞雪
Title: 用SQL取代pandas 聚合运算结合plot画图的方法案例
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/9216/
转载文章受原作者版权保护。转载请注明原作者出处!