python画图

1.使用python的pyplot绘制函数:

https://blog.csdn.net/huuinn/article/details/78975223

2.非连续图,折线图

https://www.cnblogs.com/chaoren399/p/5792168.html

3.Python可视化中Matplotlib(3.线条的详细样式及线性、保存图片、plot的详细风格和样式)、背景色、点和线的详细设置

https://blog.csdn.net/wei18791957243/article/details/83831266

4.matplotlib命令与格式:设置栅格,axes脊柱(坐标轴),背景颜色(useless)
https://blog.csdn.net/helunqu2017/article/details/78650339

5.python 出现'matplotlib' has no attribute 'imshow'错误, 解决方法

https://blog.csdn.net/liaowhgg/article/details/84977891

查看自己的import,正确写法应该是from matplotlib import pyplot as plt, 再使用plt.imshow()方法
而不是直接import matplotbib后就使用plt.imshow()方法

6.plt画图添加注释latex文本等,还有折线的颜色参数设置

https://www.cnblogs.com/zhizhan/p/5615947.html

7.设置plt的大小

plt.figure(figsize=(6, 6.5))

8.plt画图不能显示中文

https://blog.csdn.net/zzsg2005/article/details/78065075

ERROR9:RuntimeError: Locator attempting to generate 2561 ticks from 439.0 to 2999.0: exceeds Locator.MAXTICKS

因为你的数据值太大了,你的figure图无法放下你的数据,试着把你的刻度调大,让你的x轴或者y轴能放下数据

9.Matplotlib的子图subplot的使用

https://www.jianshu.com/p/de223a79217a

10.解决使用 plt.savefig 保存图片时一片空白(savefig在show前,解之)

11.【数据展示】matplotlib设置画面大小:

plt.figure(figsize=(8, 6))  # 宽800 长600

https://blog.csdn.net/a19990412/article/details/81407640

12.plt.scatter()画散点图

https://blog.csdn.net/qq_38486203/article/details/80578260

https://blog.csdn.net/m0_37393514/article/details/81298503

详细解释一下参数alpha,这个alpha是0到1之间的实数,越大点的颜色越深,越靠近0.5点越稀疏

14.Matplotlib(三) rcParams 自定义样式控制

https://blog.csdn.net/jeffery0207/article/details/81283036

https://blog.csdn.net/lanchunhui/article/details/51132008

15.

plt.figure(facecolor='w')  # facecolor:背景颜色

16. 使用seaborn,seaborn会覆盖plt的设置。

import seaborn as sns
import matplotlib.pyplot as plt
import pylab as mpl  # import matplotlib as mpl

# 设置汉字格式
# sans-serif就是无衬线字体,是一种通用字体族。
# 常见的无衬线字体有 Trebuchet MS, Tahoma, Verdana, Arial, Helvetica,SimHei 中文的幼圆、隶书等等
mpl.rcParams['font.sans-serif'] = ['FangSong']  # 指定默认字体
mpl.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题

item_list = ['背包', '双肩包', 'pu', '电脑包', '帆布背包', '行李', '书包', '网球拍', '托特', '肩背']
score_list = [1.0, 0.92254084, 0.8217171, 0.82024956, 0.7901638, 0.78987044, 0.7873092, 0.78265584, 0.78169274, 0.78014624]


f, ax = plt.subplots(figsize=(12, 20))
# orient='h'表示是水平展示的,alpha表示颜色的深浅程度
# sns.set_style("ticks")
sns.barplot(y=item_list, x=score_list, orient='h', alpha=0.8, color='red', palette="Set1")  # orient='v'表示成竖直显示
# sns.palplot(sns.color_palette("hls", 8))
# 设置y轴、X轴的坐标名字与字体大小
plt.ylabel('商品', fontsize=16)
plt.xlabel('推荐指数', fontsize=16)
# 设置X轴的各列下标字体是水平的
plt.xticks(rotation='horizontal')
# 设置Y轴下标的字体大小
plt.yticks(fontsize=15)
# plt.style.use('dark_background')
plt.show()

16.plt如何显示一定时间后自动关闭

 https://www.jianshu.com/p/e2e1979b0e9a

请勿使用plt.show()

而改用为:

 

plt.ion()
...
plt.pause(15)  #显示秒数
plt.close()

 

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值