将单个阵列中的多个概率图(在Matlab中使用probplot)组合成不同大小的数组

时间:2018-12-17 03:49:39

标签: matlab

我试图在同一张图中获得多个概率图,但无法执行相同操作。请您提供帮助,这是我一直在尝试的示例代码

package main

import (
    "encoding/json"
    "fmt"
)
type Config struct {
    Server struct {
        Host string `json:"host"`
        Port string `json:"port"`
        } `json:"server"`
    Postgres struct {
        Host     string `json:"host"`
        User     string `json:"user"`
        Password string `json:"password"`
        DB       string `json:"db"`
    } `json:"database"`
}

func main() {
    jsonConfig := []byte(`{
        "server":{
            "host":"localhost",
            "port":"8080"},
        "database":{
            "host":"localhost",
            "user":"db_user",
            "password":"supersecret",
            "db":"my_db"}}`)
    var config Config
    err := json.Unmarshal(jsonConfig, &config)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Config: %+v\n", config)
}

在这里不起作用。

1 个答案:

答案 0 :(得分:2)

您只想第一次创建图形,并获得创建轴的手柄。然后,随后您需要告诉probplot使用相同的轴,例如

cmap=colormap(jet(10));
close;

h1 = nan(1,10);  % Preallocate a vector to store all the line handles

for pp = 1:10

    numelements = randi(10e4,1,1);
    data = rand(numelements,1)*2;

    if pp == 1
        figure(1);
        h1(pp) = probplot('lognormal',data,'noref');
        ha = get(h1(pp),'Parent'); % get the handle to the created axis
    else
        h1(pp) = probplot(ha,'lognormal',data,'noref'); % reuse the same axis
    end

    set(h1(pp),'marker','+','color',cmap(pp,:),'markersize',10);

    hold on;  % This doesn't do anything and can be removed.
end