python绘图中的轴

2024-04-19 07:52:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要在同一个图形中绘制多个绘图,如下所示:

enter image description here

代码大致如下:

from __future__ import division
from matplotlib import pyplot as plt
import numpy as np

fig, ax = plt.subplots(nrows=3, ncols=4, sharex=True, sharey=True, figsize=(16, 12))
fig.text(0.5, 0.04, '$\mathrm{V_{Gas}^{HI}}$ [km/s]', ha='center')
fig.text(0.04, 0.5, '$\mathrm{W_{50}^{median}}$', va='center', rotation='vertical')

for i in range (1,13):
    ax = plt.subplot(3,4,i)
    n, bins, patches = plt.hist(data, 50, color='red',histtype='step', weights=weight)
    plt.plot((a,b), (maxim, maxim),"b-")
    plt.plot((a-c/2,a), (maxim, maxim),"b--")
    plt.plot((b,b+c/2), (maxim, maxim),"b--")

基本上我画了直方图和一些线。我的问题是为什么第一个图没有x轴上的标签?你知道吗


Tags: textfromimporttrue图形绘图plotas