【问题标题】:Matlab question: fixing the scale of Y axis in histMatlab问题:修复hist中Y轴的比例
【发布时间】:2011-07-12 17:33:30
【问题描述】:

我想画几个直方图。但是我希望 Y 轴是固定的,比如从 1000 到 1 乘 100。我该如何指定它们。

请指教。

【问题讨论】:

    标签: matlab plot histogram


    【解决方案1】:

    考虑这个例子:

    %# some data
    X = randn(1000,3);
    nbins = 10;
    
    %# compute frequencies and bins
    %#[count,bins] = hist(X, nbins);
    count = zeros(10,size(X,2));
    bins = zeros(10,size(X,2));
    for i=1:size(X,2)
        [count(:,i),bins(:,i)] = hist(X(:,i),nbins);
    end
    
    %# show histograms
    for i=1:size(X,2)
        subplot(1,size(X,2),i)
        bar(bins(:,i), count(:,i),'hist')
        set(gca, 'YTick',0:100:4000, 'YLim',[0 400])
    end
    

    【讨论】:

      【解决方案2】:

      axis 命令就是您要查找的内容。您指定[XMIN XMAX YMIN YMAX]。此示例将所有直方图的上限设置为 5。此外,您今天在没有进行任何研究的情况下问了很多关于 MATLAB 的问题。请询问搜索引擎并表明您至少尝试过。

      clf;
      subplot(1,2,1); hist(rand(1,10)); axis([0 1 0 5]);
      subplot(1,2,2); hist(rand(1,10)); axis([0 1 0 5]);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-06-10
        • 1970-01-01
        • 1970-01-01
        • 2018-07-09
        • 1970-01-01
        • 2020-06-01
        • 1970-01-01
        相关资源
        最近更新 更多