rotateXLabels( ax, angle, varargin )

版本 (18.1 KB) 作者: Ben Tordoff
Rotate x-tick labels to any angle, preserving font settings and coping with resize, zoom, pan etc

21.8K 次下载

更新时间 2016/9/1


<b>NB: As of R2014b this functionality is built into MATLAB axes using the 'XTickLabelRotation' property.</b>
This function rotates the x-tick labels on a plot. An arbitrary angle can be specified for the text and the label justification adjusts appropriately to ensure the labels lie below the ticks. The axes font properties are preserved in the labels, which will update in response to font changes. Changes to the axes limits are also handled.
Main features:
* Arbitrary angle of rotation
* Justification adjusts appropriately for the specified angle
* Axes font property changes are reflected
* Labels move correctly when zooming and panning

As with other functions that achieve the same result, this works by replacing the xtick labels with text objects. Handles to the created text objects are returned for you to tinker with.


Ben Tordoff (2023). rotateXLabels( ax, angle, varargin ) (, MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2010a
Windows macOS Linux
Help CenterMATLAB Answers 中查找有关 Labels and Annotations 的更多信息
标签 添加标签

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明

Updated license

* On MATLAB R2014b, just use XTickLabelRotation instead

Improve behavior when "cla" is called on the axes.

Switch to using data coordinates internally to allow printing to work. Please keep the old version in case this breaks something else!

Should now honour the "XAxisLocation" property of the axes.

Switch to using normalized units for labels to prevent loss of accuracy with hundreds/thousands of labels.