惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
P
Proofpoint News Feed
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
The Last Watchdog
The Last Watchdog
F
Fortinet All Blogs
S
Schneier on Security
Help Net Security
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Check Point Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
I
InfoQ
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
T
Troy Hunt's Blog
人人都是产品经理
人人都是产品经理
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
Forbes - Security
Forbes - Security
Vercel News
Vercel News
S
Security Affairs
美团技术团队
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
U
Unit 42
Recorded Future
Recorded Future
W
WeLiveSecurity
PCI Perspectives
PCI Perspectives
P
Palo Alto Networks Blog
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 【当耐特】

博客园 - longbigfish

部署(https证书) https证书问题(本地) 参数更新 Ubuntu 24安装Neo4j详细教程 protect 紧急 手机 刷脏页的两种模式 python中的多线程陷阱与pytorch分布式执行机制 git之复合指令和submodule rpc编程示例 mpi编程 cifs远程挂载 使用脚本进入一个命令行控制台,并预设执行的命令列表 cifs挂载远程文件出现 No such device or address错误 longtable 跨越多个页面时,如何在跨页时自动断行并加上横线及去掉页眉 matplotlib中文显示-微软雅黑 latex编译过程-关于嵌入所有字体 linux启动全过程 连接并同步windows下的git仓库 反向ssh
python做图笔记
longbigfish · 2018-07-16 · via 博客园 - longbigfish

1. 工具选择

  了解了基本python,rodeo,anaconda套件这三种工具。

  (1)基本python,下载安装python的最新版(目前是python3.7).注意要使用安装版。安装好后,一般系统路径会加入python的安装目录和其下的scripts。scripts里包含pip。

        安装完成后,可以在cmd命令行里键入python进入python界面,也可以打开自带的python界面。在这里面就可以进行python代码编写和运行了。

        如果要安装包,需要打开cmd命令行,使用pip install packet_name 进行在线安装。或者将包下载下来,一般是whl格式,使用pip install "D:\doloads\packet"进行安装。

        我们这里安装numpy、scipy、matplotlib、pandas。

        然后就可以进行做图了。使用plt.show()后会弹出一个新界面展示图形,上面有保存按钮,可以将其保存为各种格式。

  (2)rodeo安装后自带python以及matplotlib等基本包。但是在里面安装其他包不是很好使。而且对于matplotlib的有些特性不支持,比如 plt.rcParams 。绘图只能在软件内部一个框里显示,保存操作只能保存为png,要保存为pdf需要使用命令。

  (3)anaconda安装后有一整套工具,而且包含了较新版本的python,比如目前包含python3.6,以及丰富的包。安装后的工具有anaconda promt命令行,spyder等,主要使用这两个。anaconda promt命令行用来进行包的安装的管理,使用conda list可以列出所有已经安装的包及其版本。spyder用来作为ide,可以设置在弹出框里显示绘图,弹出框按钮类似与基本python的弹出框。

2. 最终选择anaconda,使用spyder进行编辑。遇到了一个问题就是,画柱形图使用hatch填充,不设置颜色(使用默认的颜色序列)或设置彩色序列,保存为pdf时,使用sumatrapdf,minipdf等工具打开不显示填充内容,只显示整个颜色快。

      后来通过各种debug发现, 如果画bar时,设置颜色为黑白,edgecolor='black',color='lightgray', 就很正常。发现这里设置color='red'也会正常。

      再次发现,只要在for循环中使用  for i, bar_height in zip(range(0,5),dlist):# enumerate(dlist) ,在bar设置了颜色就不行

      而for循环使用  for bar_height in dlist: 就可以

      于是,for循环里不设置i,而使用colors.pop(0)设置颜色。 这下好了!

    貌似bar里面的  edgecolor='black' 参数也有关系

3. 中文支持 参考 https://segmentfault.com/a/1190000005144275

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
即可