2024-04-25 19:32:12 发布
网友
我在Matplotlib网站上看到了this example。我想知道是否有可能增加体型。
我试过了
f.figsize(15,15)
但它什么也做不了。
或者,使用figsize参数创建figure()对象,然后使用add_subplot添加子块。E、 g
figsize
figure()
add_subplot
import matplotlib.pyplot as plt import numpy as np f = plt.figure(figsize=(10,3)) ax = f.add_subplot(121) ax2 = f.add_subplot(122) x = np.linspace(0,4,1000) ax.plot(x, np.sin(x)) ax2.plot(x, np.cos(x), 'r:')
这种方法的好处是语法更接近于subplot()的调用,而不是subplots()。E、 子块似乎不支持使用GridSpec来控制子块的间距,但是subplot()和add_subplot()都支持。
subplot()
subplots()
GridSpec
add_subplot()
如果您已经使用figure对象:
f.set_figheight(15) f.set_figwidth(15)
但是,如果您使用.subplots()命令(如您所示的示例)创建一个新图形,您还可以使用:
f, axs = plt.subplots(2,2,figsize=(15,15))
或者,使用
figsize
参数创建figure()
对象,然后使用add_subplot
添加子块。E、 g这种方法的好处是语法更接近于
subplot()
的调用,而不是subplots()
。E、 子块似乎不支持使用GridSpec
来控制子块的间距,但是subplot()
和add_subplot()
都支持。如果您已经使用figure对象:
但是,如果您使用.subplots()命令(如您所示的示例)创建一个新图形,您还可以使用:
相关问题 更多 >
编程相关推荐