简体   繁体   English

Matlab:具有ksdensity的图以具有伪3D外观

[英]Matlab: A plot with ksdensity to have a pseudo 3D look

I would like to make a histogram plot using ksdensity in 3D. 我想在3D中使用ksdensity制作直方图。 My plot looks similar to the example here; 我的情节看起来与这里的示例相似。

http://www.mathworks.com/help/stats/fit-kernel-distributions-to-grouped-data-using-ksdensity.html http://www.mathworks.com/help/stats/fit-kernel-distributions-to-grouped-data-using-ksdensity.html

In my example I have 15 different histograms, and this plot in 2D is very congested. 在我的示例中,我有15个不同的直方图,而此二维图非常拥挤。 I am trying to space them out along a 3rd axis so they can be observed better. 我正在尝试沿着第3轴将它们隔开,以便可以更好地观察它们。

This is the explicit solution of your problem: 这是您的问题的显式解决方案:

figure(1)
hold on; grid on
for i = 1:15
    path = ['tmp_',num2str(i),'.out'];
    fid = fopen(path, 'r');
    a = textscan(fid,'%f');

    % Appearantly the first line is a string in some of your files
    % This if statement will take care of it ;)
    if isempty(a{1})
        fgetl(fid);
        a = textscan(fid,'%f');
    end
    tmp = a{1};
    % Some of your files (all but one I think) contain element numbering
    % This if statement takes care of it ;)
    if length(tmp) > 180000
        tmp = tmp(2:2:end);
    end
    fclose(fid);
    [f, xi] = ksdensity(tmp);
    plot3(xi, ones(length(f))*i, f)
end
view(3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM