Як прызначыць індывідуальныя пазнакі значэнняў на восях у Matlab? (How to assign individual labels to values on the axes in Matlab?)


問題描述

Як прызначыць індывідуальныя пазнакі значэнняў на восях у Matlab? (How to assign individual labels to values on the axes in Matlab?)

I have a matrix in matlab. Each row/column has a unique label. these labels are in a row‑matrix. How do I print these labels on the figure next to that row/column number? Nevermind the cluminess in display, I want to see the labels against the rows rather than the row numbers.

‑‑‑‑‑

參考解法

方法 1:

If I understand your problem correctly, you have a plot like 

pcolor(magic(4));

and labels similar to 

lbl = ['a'; 'b'; 'c'; 'd'];

Following my example you have four labels for both X and/or Y. All you need to do from here is set the XTicks of your axes to the number of lables you have, then set the XTickLabels like so:

set(gca,'XTick',1:length(lbl),'XTickLabel',lbl)

(by stackoverflowGeodesic)

參考文件

  1. How to assign individual labels to values on the axes in Matlab? (CC BY‑SA 3.0/4.0)

#matlab #octave #plot #matlab-figure






相關問題

MATLAB:多線程和多核之間的區別 (MATLAB: difference between Multithreading and Multicore)

在 matlab 中用 imread 讀取圖像文件會給出什麼樣的表示? (reading a image file with imread in matlab gives what kind of representation?)

Як прызначыць індывідуальныя пазнакі значэнняў на восях у Matlab? (How to assign individual labels to values on the axes in Matlab?)

覆蓋 MATLAB 默認靜態 javaclasspath 的最佳方法 (Best way to override MATLAB's default static javaclasspath)

如何在 Matlab 中為這個 3D 繪圖設置動畫? (How to animate this 3D plot in Matlab?)

如何轉換 x = [x_de,x_nu]; 從matlab到python? (How do I convert x = [x_de,x_nu]; from matlab to python?)

opnet 和 matlab 接口 (opnet and matlab interfacing)

Matlab:使用正非整數邊緣權重執行最小切割 (Matlab: perform min cut with positive non-integer edge weights)

帶矩陣的圖像疊加 (Image overlay with matrix)

在矩形 [a,b]x[c,d] 上離散最小二乘逼近。使用函數 1,x,y,sin(x) 和 sin(y) 作為基礎 (Discete least sqauare approximation on rectangle [a,b]x[c,d].Use functions 1,x,y,sin(x) and sin(y) as the basis)

如果這個變量在調用之間發生了變化,為什麼匿名函數的固定參數沒有更新? (Why is fixed argument of anonymous function not updated, if this variable has changed between calls?)

在 MATLAB 中通過 HTTP 接收數據 (Receive data via HTTP in MATLAB)







留言討論