Matlab传奇与情节不符

时间:2016-06-22 08:40:01

标签: matlab plot matlab-figure legend legend-properties

我使用以下代码生成我的绘图(我希望稍后将其包含在我的LateX文档中):

public class MainActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener{

// Declare View variables
private Button mRefreshButton;
private Switch mWifiSwitch;
private ListView mAPListView;
private List<ScanResult> mWifiList;
private List<String> mListOfProviders;
private ListAdapter mAdapter;
private WifiManager mWifiManager;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mListOfProviders = new ArrayList<String>();
    mAPListView = (ListView) findViewById(R.id.APListView);
    mRefreshButton = (Button) findViewById(R.id.refreshButton);
    mWifiSwitch = (Switch) findViewById(R.id.WiFiSwitch);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    boolean wasEnabled = mWifiManager.isWifiEnabled();
    if (wasEnabled){
        mWifiSwitch.setChecked(true);
    }
    mWifiSwitch.setOnCheckedChangeListener(this);

    //wifiReciever = new WifiScanReceiver();
    mWifiManager.startScan();
    mWifiList = mWifiManager.getScanResults();

}


@Override
public void onClick(View view)
{

}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked){
        mWifiManager.setWifiEnabled(true);
    }
    else {
        mWifiManager.setWifiEnabled(false);
    }
}

图表如下:

When to use the Visual Studio Additional dependencies?

显然,“绑定长波”图例与图表中的颜色和线条规格不匹配。 据我所知,它与标量/向量有关,但我无法弄清楚错误的位置。

如何进一步处理?

1 个答案:

答案 0 :(得分:2)

您实际上正在创建四个绘图对象,但仅为其中三个提供图例。如果我们细分您的plot语句,我们可以对这些图表进行计数(请记住,使用矩阵调用plot将每个绘制为不同的图表。)

plot(time, wave3, 'k', ...          <--- This is one plot
     time, [-1;1]*env, '--k', ...   <--- This is TWO plots (one negative, one positive)
     time, bound, '-.r', ...        <--- This is one plot
     'Linewidth',1.2);

当你只用三个标签来呼叫legend时,它只会为前三个绘图对象创建一个图例条目

由于您可能不希望信封有两个条目,因此您应该将plot的输出分配给变量pass the handles explicitly to the legend

p = plot(time, wave3, 'k', ...
         time, [-1; 1] * env, '--k', ...
         time, bound, '-.r', ...
         'LineWidth', 1.2);

% Skip the third plot since that will just be the "negative" envelope
legend(p([1 2 4]), {'Short waves','Wave group envelope','Bound long wave'});

enter image description here