python绘制饼图的如何设置高度宽度,在Python中调整matplotlib中各个子图的高度

if I have a series of subplots with one column and many rows, i.e.:

plt.subplot(4, 1, 1) # first subplot

plt.subplot(4, 1, 2) # second subplot

# ...

how can I adjust the height of the first N subplots? For example, if I have 4 subplots, each on its own row, I want all of them to have the same width but the first 3 subplots to be shorter, i.e. have their y-axes be smaller and take up less of the plot than the y-axis of the last plot in the row. How can I do this?

thanks.

解决方案

There are multiple ways to do this. The most basic (and least flexible) way is to just call something like:

import matplotlib.pyplot as plt

plt.subplot(6,1,1)

plt.subplot(6,1,2)

plt.subplot(6,1,3)

plt.subplot(2,1,2)

Which will give you something like this:

wFDve.png

However, this isn't very flexible. If you're using matplotlib >= 1.0.0, look into using GridSpec. It's quite nice, and is a much more flexible way of laying out subplots.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值