在x轴和y轴上显示带有自定义值的imagesc

时间:2016-03-03 10:49:10

标签: matlab axis-labels image-scaling

我使用MATLABS函数imagesc绘制一个6x6的双精度矩阵。这是我得到的情节:

Plot

我想要做的是将x轴和y轴上的值更改为我自己选择的值。

例如,我想用自己的向量[10,16,53,97,136 191]替换值1-6,以便它们显示在x轴和/或y轴上。

谢谢!

1 个答案:

答案 0 :(得分:4)

您可以为此修改 import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.content.DialogInterface.OnClickListener; public class ComputerResultActivity extends Activity { TextView result; Button btnRestart; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.computerresult); result = (TextView) findViewById(R.id.coderesult); btnRestart=(Button)findViewById(R.id.buttonrestart); StringBuffer sb=new StringBuffer(); sb.append("Correct Ans:"+ Computer_Test1_Activity.correct); sb.append("\n Wrong Ans:"+ Computer_Test1_Activity.wrong); sb.append("\n Final Score:"+ Computer_Test1_Activity.marks); result.setText(sb); Computer_Test1_Activity.correct=0; Computer_Test1_Activity.wrong=0; btnRestart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent in=new Intent(getApplicationContext(),ComputerActivity.class); startActivity(in); } }); } /*@Override public boolean OnCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.computerresult, menu); return true; }*/ } XTickLabel属性。

在MATLAB r2014b或更高版本中,您应该:

YTickLabel

在之前的版本中

ax=gca;
ax.XTickLabel = {'10', '16', '53', '97', '136', '191'};
ax.YTickLabel = {'10', '16', 'look a banana', '97', 'yeah you can write whatever', '191'};

更多信息:

Change Axis Tick Value Locations and Labels, The Mathworks