
python
土豆面包
这个作者很懒,什么都没留下…
展开
-
matplotlib调整清晰度和图像大小
问题有时我们在使用matplotlib作图时,图片不清晰或者图片大小不是我们想要的,例如下图上图的相关代码如下:import matplotlib.pyplot as pltx = [10,20,30,40,50,60,70,80,90,1000]y1 = [7,17,27,37,43,49,57,65,71,77]y2 = [7,17,27,37,45,54,59,67,75,83]y3 = [8,18,28,38,47,56,64,73,80,89]y4 = [10,20,30,40原创 2021-06-15 20:06:57 · 28710 阅读 · 1 评论 -
matplotlib修改背景颜色和插入背景图片
文章目录matplotlib怎么修改背景颜色?1.通过matplotlib的相关参数修改2.插入背景图片matplotlib怎么修改背景颜色?1.通过matplotlib的相关参数修改使用matplotlib画图时,可以通过rcParams['axes.facecolor']来修改背景颜色import matplotlib.pyplot as plt# 修改背景颜色plt.rcParams['axes.facecolor']='snow'x = [10,20,30,40,50,60,70,原创 2021-06-15 19:25:39 · 18508 阅读 · 4 评论 -
python处理矩阵运算、转置矩阵、逆矩阵、单位矩阵
文章目录python处理矩阵运算转置矩阵单位矩阵&反向单位矩阵逆矩阵矩阵相乘python处理矩阵运算转置矩阵import numpy as npmatrix = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]# 转置矩阵transposed_matrix = np.transpose(matrix)# ndarrayprint(type(transposed_matrix))"""[[1 1 1] [2 2 2] [3 3 3]]""" print(t原创 2021-06-02 13:44:33 · 2537 阅读 · 0 评论 -
python画柱状图和折线图
文章目录柱状图折线图柱状图在画柱状图时,横坐标上的文字可能会重叠,我们可以根据自己的需要改变label的间距以及调节颜色的透明程度等。以下图为例:对应的代码为:# 柱状图import matplotlib.pyplot as plt # 调节x轴之间的间距params = { 'figure.figsize': '8, 4'}plt.rcParams.update(params)X=['sport','world','business','us','entertainmen原创 2021-05-09 11:30:53 · 3240 阅读 · 0 评论 -
mac上安装pyenv,对python版本进行切换
在开发Python程序的时候,有时候可能需要在不同版本的Python上进行测试。pyenv就是这么一个管理多版本Python的工具。下面介绍如何在mac os系统上安装pyenvgithub地址:https://github.com/pyenv/pyenv具体步骤如下:1 如果没有安装git,使用以下命令:sudo apt install git并根据提示输入密码2 检查terminal的shell版本echo $SHELL3 根据终端的shell版本,依次向terminal中输入以下命令:原创 2021-01-24 10:29:44 · 747 阅读 · 0 评论