我是靠谱客的博主 传统云朵,这篇文章主要介绍python画折线图参数配置python画折线图参数配置,现在分享给大家,希望可以做个参考。

python画折线图参数配置

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
1.设定x,y坐标轴间隔 2.中文显示,搞定 3.网格线显示,搞定 4.数值显示,简化阅读繁琐程度 5.设置折线的颜色 #解决中文显示问题 plt.rcParams['font.sans-serif']=['SimHei'] plt.rcParams['axes.unicode_minus'] = False 添加图例(label) plt.plot(x, y2, label='y = cos(x)') 显示图例 plt.legend() 显示图像 plt.show() 图例位置 legend方法可接受一个loc关键字参数来设定图例的位置,可取值为数字或字符串: 0: ‘best' 1: ‘upper right' 2: ‘upper left' 3: ‘lower left' 4: ‘lower right' 5: ‘right' 6: ‘center left' 7: ‘center right' 8: ‘lower center' 9: ‘upper center' 10: ‘center'

 画折线图代码

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#****************************************************导入包********************************** import pandas as pd from pyecharts.charts import Sankey from pyecharts import options as opts from matplotlib import pyplot import matplotlib.pyplot as plt from matplotlib.pyplot import MultipleLocator #****************************************************配置********************************** #解决中文显示问题 plt.rcParams['font.sans-serif']=['SimHei'] plt.rcParams['axes.unicode_minus'] = False #****************************************************数据处理********************************** df = pd.read_csv("D:\b临时需求\放款情况20210609\a33.csv") n = range(len(df.mth)) x = [str(x) for x in list(df.mth)] df.dtypes #疑问 #1.设定x,y坐标轴间隔 #2.中文显示,搞定 #3.网格线显示,搞定 #4.数值显示,简化阅读繁琐程度 #5.设置折线的颜色 #6.旋转坐标标签 #****************************************************画图********************************** #设置刻度 #y_major_locator=MultipleLocator(1000000) #ax=plt.gca() #ax.yaxis.set_major_locator(y_major_locator) #plt.ylim(-1000000,4000000) # ##旋转标签 #plt.xticks(rotation=0) #plt.yticks(rotation=0) plt.pie( df.cnt,labels=x,autopct='%1.1f%%') #plt.bar(x, df.cnt, color='y',label='放款案件量') #plt.plot(x, df.cnt, c='y',marker='o', mec='r', mfc='w',label='放款案件量') #显示图例 plt.legend(loc=2) #显示网格 plt.grid() #添加标签 plt.xlabel('年月') #X轴标签 plt.ylabel("案件量") #Y轴标签 plt.title("近10年放款案件量",fontsize=20) #标题 plt.show() plt.savefig('D:\b临时需求\放款情况20210609\近10年放款案件量.jpg',dpi = 900) #****************************************************end**********************************

 

最后

以上就是传统云朵最近收集整理的关于python画折线图参数配置python画折线图参数配置的全部内容,更多相关python画折线图参数配置python画折线图参数配置内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(83)

评论列表共有 0 条评论

立即
投稿
返回
顶部