《Python数据可视化之matplotlib实践》 源码 第四篇 扩展 第十一章

Posted Hello_BeautifulWorld

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《Python数据可视化之matplotlib实践》 源码 第四篇 扩展 第十一章相关的知识,希望对你有一定的参考价值。

图  11.2 

 

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np


plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")
plt.plot(2+np.arange(3), [0, 1, 0])
plt.title("Line Chart")


plt.text(2.25, 0.8, "FONT")


plt.show()
View Code

 

 

 

==================================

 

图  11.3 

 

 

import matplotlib.pyplot as plt
import numpy as np


plt.rcParams["lines.linewidth"]=8.0
plt.rcParams["lines.linestyle"]="--"


plt.rcParams["font.family"]="serif"
plt.rcParams["font.serif"]="New Century Schoolbook"  ###
plt.rcParams["font.style"]="normal"
plt.rcParams["font.variant"]="small-caps"
plt.rcParams["font.weight"]="black"
plt.rcParams["font.size"]=12.0


plt.rcParams["text.color"]="blue"


plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")
plt.plot(2+np.arange(3), [0, 1, 0])
plt.title("Line Chart")


plt.text(2.25, 0.8, "FONT")


plt.show()
View Code

 

 

==================================

 

图  11.4 

 

 

import matplotlib.pyplot as plt
import numpy as np


plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")


plt.plot(2+np.arange(3), [0, 1, 0], linewidth=8.0, linestyle="--")
plt.title("Line Chart", color="red", family="New Century Schoolbook", 
          style="normal", variant="small-caps", weight="black", size=18) ###


plt.text(2.25, 0.8, "FONT", color="blue", fontdict={"family":"New Century Schoolbook", 
          "style":"normal", "variant":"small-caps", "weight":"black", "size":28}) ###


plt.show()
View Code

 

 

==================================

 

图  11.5

 

 

 

 

import matplotlib.pyplot as plt


fig=plt.figure()
ax=fig.add_subplot(111)


pi=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]




families=["serif", "sans-serif", "fantasy", "monospace"]
ax.text(-1, 1, "family", fontsize=18, horizontalalignment="center")
for i, family in enumerate(families):
    ax.text(-1, pi[i], family, family=family, horizontalalignment="center")




    
sizes=["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"]
ax.text(-0.5, 1, "size", fontsize=18, horizontalalignment="center")
for i, size in enumerate(sizes):
    ax.text(-0.5, pi[i], size, size=size, horizontalalignment="center")


  



styles=["normal", "italic", "oblique"]
ax.text(0, 1, "style", fontsize=18, horizontalalignment="center")
for i, style in enumerate(styles):
    ax.text(0, pi[i], style, family="sans-serif", style=style, horizontalalignment="center")





variants=["normal", "small-caps"]
ax.text(0.5, 1, "variant", fontsize=18, horizontalalignment="center")
for i, variant in enumerate(variants):
    ax.text(0.5, pi[i], variant, family="serif", variant=variant, horizontalalignment="center")






weights=["light", "normal", "semibold", "bold", "black"]
ax.text(1, 1, "weight", fontsize=18, horizontalalignment="center")
for i, weight in enumerate(weights):
    ax.text(1, pi[i], weight, weight=weight, horizontalalignment="center")





ax.axis([-1.5, 1.5, 0.1, 1.1])
ax.set_xticks([])
ax.set_yticks([])

plt.show()
View Code

 

 

 

 

==================================

 

以上是关于《Python数据可视化之matplotlib实践》 源码 第四篇 扩展 第十一章的主要内容,如果未能解决你的问题,请参考以下文章

Python数据可视化之matplotlib实践 源码 第一篇 入门 第三章

Python数据可视化之matplotlib实践 源码 第一篇 入门 第三章

《Python数据可视化之matplotlib实践》 源码 第四篇 扩展 第十一章

Python 数据可视化之-[Matplotlib]

Python 数据可视化之-[Matplotlib]

Python数据可视化之Matplotlib实现各种图表