python(数据分析)第4天:绘制网格

阅读: 评论:0

python(数据分析)第4天:绘制网格

python(数据分析)第4天:绘制网格

import matplotlib.pyplot as plt
import random
import matplotlib
from matplotlib import cycler
from matplotlib.font_manager import FontProperties# 支持的中文字体
font1 = FontProperties(fname=r"c:windows")y = [1, 2, 3, 2, 4, 1, 4, 3, 6, 3, 1, 2, 3, 4, 6, 7, 9, 6, 7, 4]
x = range(11, 31)plt.figure(figsize=(20, 8))plt.plot(x, y)# 调整x轴上的字符串刻度
_x_ticks = ["{}岁".format(i) for i in x ]
icks(x, _x_ticks, fontproperties=font1)
# 绘制网格
id()
plt.show()

调整y轴更密集一点

import matplotlib.pyplot as plt
import random
import matplotlib
from matplotlib import cycler
from matplotlib.font_manager import FontProperties# 支持的中文字体
font1 = FontProperties(fname=r"c:windows")y = [1, 2, 3, 2, 4, 1, 4, 3, 6, 3, 1, 2, 3, 4, 6, 7, 9, 6, 7, 4]
x = range(11, 31)plt.figure(figsize=(20, 8))plt.plot(x, y)# 调整x轴上的字符串刻度
_x_ticks = ["{}岁".format(i) for i in x ]
icks(x, _x_ticks, fontproperties=icks(range(0,9))# 绘制网格
id()plt.show()

设置网格透明度 id(alpha=0.2)

import matplotlib.pyplot as plt
import random
import matplotlib
from matplotlib import cycler
from matplotlib.font_manager import FontProperties# 支持的中文字体
font1 = FontProperties(fname=r"c:windows")y = [1, 2, 3, 2, 4, 1, 4, 3, 6, 3, 1, 2, 3, 4, 6, 7, 9, 6, 7, 4]
x = range(11, 31)plt.figure(figsize=(20, 8))plt.plot(x, y)# 调整x轴上的字符串刻度
_x_ticks = ["{}岁".format(i) for i in x]
icks(x, _x_ticks, fontproperties=icks(range(0, 14))# 绘制网格
id(alpha=0.2)plt.show()

本文发布于:2024-01-29 16:56:41,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170651860516817.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:网格   数据   python
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23