查看matplotlib文档,似乎将AxesSubplot添加到Figure的标准方法是使用Figure.add_subplot : from matplotlib import pyplot fig = pyplot.figure() ax = fig.add_subplot(1,1,1) ax.hist( some params …. ) 我希望能够独立于graphics创buildAxesSubPlot类对象,所以我可以在不同的graphics中使用它们。 就像是 fig = pyplot.figure() histoA = some_axes_subplot_maker.hist( some params ….. ) histoA = some_axes_subplot_maker.hist( some other params ….. ) # make one figure with both plots fig.add_subaxes(histo1, 211) fig.add_subaxes(histo1, 212) fig2 = pyplot.figure() # make a figure […]
当我尝试使用pip升级我的matplotlib时,它输出: Downloading/unpacking matplotlib from https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.4.0.tar.gz#md5=1daf7f2123d94745feac1a30b210940c Downloading matplotlib-1.4.0.tar.gz (51.2MB): 51.2MB downloaded Running setup.py (path:/tmp/pip_build_root/matplotlib/setup.py) egg_info for package matplotlib ============================================================================ Edit setup.cfg to change the build options BUILDING MATPLOTLIB matplotlib: yes [1.4.0] python: yes [2.7.6 (default, Mar 22 2014, 22:59:38) [GCC 4.8.2]] platform: yes [linux2] REQUIRED DEPENDENCIES AND EXTENSIONS numpy: yes [version 1.8.2] six: yes [using six […]
当我为三维图设置相等的宽高比时,z轴不会变为“相等”。 所以这: fig = pylab.figure() mesFig = fig.gca(projection='3d', adjustable='box') mesFig.axis('equal') mesFig.plot(xC, yC, zC, 'r.') mesFig.plot(xO, yO, zO, 'b.') pyplot.show() 给我以下几点: 显然z轴的单位长度不等于x和y单位。 我怎样才能使所有三个轴的单位长度相等? 我能find的所有解决scheme都不起作用。 谢谢。
我是不成功的浏览网页的解决scheme为以下简单的问题: 如何使用顶点值绘制三维多边形(比如填充的矩形或三angular形)? 我尝试了很多想法,但都失败了,请看: from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection import matplotlib.pyplot as plt fig = plt.figure() ax = Axes3D(fig) x = [0,1,1,0] y = [0,0,1,1] z = [0,1,0,1] verts = [zip(x, y,z)] ax.add_collection3d(PolyCollection(verts),zs=z) plt.show() 我提前感谢任何想法/评论。 根据接受的答案进行更新: import mpl_toolkits.mplot3d as a3 import matplotlib.colors as colors import pylab as pl import scipy as sp ax […]
为了删除图中的框架,我写了 frameon=False 与pyplot.figure完美的pyplot.figure ,但与matplotlib.Figure它只能删除灰色背景,框架保持。 另外,我只想要显示线条,其余的graphics都是透明的。 用pyplot我可以做我想做的事情,我想用matplotlib来做这个事情,我有一个很长的理由,我不想提到我的问题。
我有一组数据,我想绘制为一个线图。 对于每个系列,缺less一些数据(但是每个系列都不相同)。 目前matplotlib不会画出跳过缺失数据的行:例如 import matplotlib.pyplot as plt xs = range(8) series1 = [1, 3, 3, None, None, 5, 8, 9] series2 = [2, None, 5, None, 4, None, 3, 2] plt.plot(xs, series1, linestyle='-', marker='o') plt.plot(xs, series2, linestyle='-', marker='o') plt.show() 导致线路中存在空白的情节。 我怎么能告诉matplotlib通过差距画线? (我宁愿不必插入数据)。
到目前为止,我有以下代码: colors = ('k','r','b') ax = [] for i in range(3): ax.append(plt.axes()) plt.plot(datamatrix[:,0],datamatrix[:,i],colors[i]+'o') ax[i].set(autoscale_on=True) 对于每个坐标轴的autoscale_on=True选项,我认为每个坐标图应该有自己的y轴限制,但是看起来它们都共享相同的值(即使它们共享不同的坐标轴)。 我如何设置它们以扩展显示每个datamatrix[:,i] (只是显式调用.set_ylim() ?)另外,如何为第三个variables创build偏移y轴( datamatrix[:,2] )可能需要上面的? 谢谢大家。
我使用文件中的数据创build了一个直方图,没有任何问题。 现在我想在同一个直方图中叠加另一个文件中的数据,所以我做了类似的事情 n,bins,patchs = ax.hist(mydata1,100) n,bins,patchs = ax.hist(mydata2,100) 但是问题在于,对于每个intervale来说,只有价值最高的酒吧出现,另一个是隐藏的。 我想知道我怎么能用不同的颜色同时绘制直方图
我正在使用matplotlib做直方图。 基本上,我想知道是否有任何方法来手动设置垃圾箱的大小,而不是垃圾箱的数量。 任何有任何想法的人都非常感激。 谢谢
在matplotlib图中,如何使ax1.set_xticklabels()更小的刻度标签的字体大小? 而且,怎样才能把它从水平转到垂直呢?