English 中文(简体)
以程序方式增长 Mattlotlib 的数字
原标题:Programmatically grow a figure in matplotlib

"https://i.sstatic.net/m5d4s.png" alt="说明"/ >

如何在保持高度常态的同时, 我如何在 Mattplotlib 中增加数字的大小, 以适应可变的子绘图数?

我将绘制大量的数字, 每一个数字都包含一个主要子子图( 绿色), 覆盖图像高度的90%。 此外, 我将添加一个可变的注解子图( orange) 数, 每一个图都应该达到 10% 的高度。 换句话说, 一个带有一个注解的图的基数将会达到 100% 的高度, 一个带有 5 个注解的图总高度为 140 % 。

命令允许我绘制主绘图, 然后在我添加每个子绘图时绘制数字。

问题回答

我不认为这是一个自动选项 。 我可能错了 。 有 < a href=" http:// matplotlib. sourceforge. net/ api/ figument_ api. html# matplotlib. fiorg. figure. set_ figh88" rel="nofollow"\\ code> figude. set_ figh88 调整大小的英寸。 问题是, 轴与图形尺寸相对是定义的, 所以在您调整大小之前的图上的任何子绘图都会被缩放, 以填补40%的额外空间 。

您必须写出一个常规, 既调整数字和比例的高度, 也取代数字中的任何部分。 并非不可能这样做, 但我再次认为这个特性还不存在 。

br@ymir:~/temp$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> fig=plt.figure()
>>> fig.get_size_inches()
array([ 8.,  6.])
>>> fig.set_size_inches([8.,12.])
>>> ax=fig.add_subplot(111)
>>> ax.plot([1,1,2],[3,4,5], ro- )
[<matplotlib.lines.Line2D object at 0x2428590>]
>>> ax1 = fig.add_subplot(212)
>>> ax1.plot([2,3,4],[8,9,11], bs- )
[<matplotlib.lines.Line2D object at 0x2461450>]
>>> fig.subplots_adjust()

produces enter image description here

你可以轻而易举地微调它。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签