以下代码将创建一个图表,如果子图表中的图表上看起来有几个不可见的数据。
ax[i].autoscale_view(True,True,True)
?print ax[i].lines
会显示[]
?from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
import numpy as np
# example data with properties:
# len(lines) == 4 and len(lines[0]) == 10
# len(x) == 10
lines = [(1.2310957583605482, 1.283772297331087, 1.61856069891319, 2.1602226857314735, 1.0277068564151643, 1.1715166081037471, 1.463648931121718, 1.2329321041327499, 1.4080120164965291, 1.2225064185740224), (0.33323810593968223, 0.32582779060567746, 0.32836534361310366, 0.51831090602571572, 0.29791484909192673, 0.35713207695246518, 0.29463171650130665, 0.34633265872428215, 0.39298012050485071, 0.410877623134692), (10, 11, 13, 17, 8, 10, 12, 10, 11, 10), (0.9911659269366481, 0.989291500800633, 0.9880005820749531, 0.9820511801663299, 0.978444258093041, 0.9737543029212308, 0.9711834357704919, 0.9632772617693266, 0.95740331184712, 0.9523058427743931)]
x = [0.0, 0.00101010101010101, 0.00202020202020202, 0.0030303030303030303, 0.00404040404040404, 0.00505050505050505, 0.006060606060606061, 0.007070707070707071, 0.00808080808080808, 0.00909090909090909]
n=len(lines) # copy in lines and x data from below
fig, ax = plt.subplots(n, sharex=True, figsize = (8, 8))
for i, y in enumerate(lines):
xy = zip(x, y)
lc = LineCollection([xy], linewidth = 2)
ax[i].add_collection(lc)
plt.show()