How to draw vertical lines in between categorical x-axis ticks
古いコメントを表示
I have some data that I display using the plot function, with categorical labels on the x-axis. I would like to draw vertical lines in between some of the x-axis tick marks, but not all. I would appreciate suggestions on how to do this. I'm using Matlab 2017a.
I can easily draw a vertical line exactly on the x-axis tick marks, using something like this:
plot([xNames(5), xNames(5)],[0 1],'k')
where xNames is my array with the categorical names. But I would like to adjust this so that a vertical line is drawn between, e.g., xNames(5) and xNames(6).
採用された回答
その他の回答 (1 件)
Jos (10584)
2018 年 1 月 4 日
編集済み: Jos (10584)
2018 年 1 月 4 日
Use the average?
v = (xNames(5)+ xNames(6))/2
plot([v v], ...)
You might also be interested in various utilities on the File Exchange that can plot vertical and horizontal grid lines at specific places, like my own GRIDXY
3 件のコメント
HW
2018 年 1 月 5 日
Jos (10584)
2018 年 1 月 5 日
insert a new category name between 5 and 6 and use that?
HW
2018 年 1 月 5 日
カテゴリ
ヘルプ センター および File Exchange で Introduction to Installation and Licensing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!