Skip to Content
Python数据科学手册
book

Python数据科学手册

by Jake VanderPlas
January 2018
Intermediate to advanced
470 pages
13h 23m
Chinese
Posts & Telecom Press
Content preview from Python数据科学手册
192
|
第
4
章
层的
Matplotlib API
画图的做法,但我依然觉得
Matplotlib
是数据可视化技术中不可或缺的
一环。
4.1
 
Matplotlib
常用技巧
在深入学习
Matplotlib
数据可视化的功能之前,你需要知道几个
Matplotlib
的使用技巧。
4.1.1
 导入
Matplotlib
就像之前用 np 作为
NumPy
的简写形式、pd 作为
Pandas
的简写形式一样,我们也可以在
导入
Matplotlib
时用一些它常用的简写形式:
In[1]: import matplotlib as mpl
import matplotlib.pyplot as plt
plt
是最常用的接口,在本章后面的内容中会经常用到。
4.1.2
 设置绘图样式
我们将使用
plt.style
来选择图形的绘图风格。现在选择经典(
classic
)风格,这样画出
的图就都是经典的
Matplotlib
风格了:
In[2]: plt.style.use('classic')
在后面的内容中,我们将根据需要调整绘图风格。
Matplotlib
在
1.5
版之后开始支持不同的
风格列表(
stylesheets
)。如果你用的
Matplotlib
版本较旧,那么就只能使用默认的绘图风
格。关于风格列表的更多信息,请参见
4.13
节。
4.1.3
 用不用
show()
?
如何显示图形
如果数据可视化图不能被看见,那就一点儿用也没有了。但如何显示你的图形,就取决于
具体的开发环境了。
Matplotlib
的最佳实践与你使用的开发环境有关。简单来说,就是有 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

流畅的Python

流畅的Python

Luciano Ramalho
Python数据分析基础

Python数据分析基础

Clinton W. Brownley
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 9787115475893