フィルターのクリア

Tracking boxplot x axis labels

4 ビュー (過去 30 日間)
Eugenio Daviso
Eugenio Daviso 2017 年 5 月 18 日
コメント済み: dpb 2017 年 5 月 26 日
I am using the boxplot function to visualize data in a hierarchical way. Since the function allows me to define the order and hierarchy of the boxes, is there a way I can retrieve the organized tick labels in a string (cell) array?
Example: By changing the order of the strings a,b,c,d (which are the different values associated to the vector_data) the tick labels on the X axis will change. How can I track that change? Can I get a table showing how the x axis tick labels are organized? What is the figure object that has that info?
comp=[a,b,c,d];
boxplot(vector_data(:,1),comp,'FactorGap',[3,1],'PlotStyle','compact','MedianStyle','line','BoxStyle','outline');
Thank you!
  2 件のコメント
dpb
dpb 2017 年 5 月 18 日
Don't follow the problem; provide a working example that illustrates what you have and what you're trying to accomplish.
Eugenio Daviso
Eugenio Daviso 2017 年 5 月 19 日
編集済み: Eugenio Daviso 2017 年 5 月 19 日
I have the attached boxplot and want to create a table of the hierarchical way of the labels on the X axis as they are plotted - left-to-right. As you can see there are four levels: Which property (or object) of the figure has that information?

サインインしてコメントする。

採用された回答

dpb
dpb 2017 年 5 月 26 日
OK, I came in late and just picked up on the 'ticklabel' part of the conversation. Went back to the beginning and looked at the original image for the first time. Those aren't tick labels but text. To retrieve them must do some "handle diving" to retrieve the text in the boxplot hggroup.
>> hTxt=findobj(findobj(gca,'Type','hggroup'),'Type','Text'); % the text object handles array
>> txtLabel=cellstr(char(hTxt.String)); % the content in cellstr array
ans =
'A06'
'A04'
'A05'
'A02'
'A03'
'A01'
''
'b'
'a'
'b'
''
'a'
''
''
'B'
''
''
'A'
''
''
'BB'
''
''
'AA'
>>
  2 件のコメント
Eugenio Daviso
Eugenio Daviso 2017 年 5 月 26 日
Thank you! THAT is what I needed!!
dpb
dpb 2017 年 5 月 26 日
It does help to read the original question sometimes! :)

サインインしてコメントする。

その他の回答 (1 件)

Sangeetha Jayaprakash
Sangeetha Jayaprakash 2017 年 5 月 22 日
編集済み: dpb 2017 年 5 月 22 日
I assume that you are trying to get the ticklabels of the X axis for the attached boxplot. You can get the current axes, and then get the Xticklabels from that handle as shown:
ax = gca;
ticks = ax.Xticklabels
For more information on "gca" function, refer this link:
ERRATUM
Use
ticks = ax.Xticklabel % plural name been removed for singular form
Or, beginning w/ R2016b, there's a new function xticklabels
doc xticklabels % for details if late-enough version
  4 件のコメント
Eugenio Daviso
Eugenio Daviso 2017 年 5 月 25 日
編集済み: Eugenio Daviso 2017 年 5 月 25 日
It works for a plot but it does not work on boxplots. I am attaching the figure so you can see that when I recall the x label property (per your instruction) the output is an empty matrix.
dpb
dpb 2017 年 5 月 26 日
See new Answer that actually addresses original problem...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by