图 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,
图 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 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 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
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
==================================