Non-numeric x-axis labelling?
56 views (last 30 days)
Show older comments
Daisy Chapman
on 17 Apr 2021
Commented: Daisy Chapman
on 17 Apr 2021
I have three data sets with the same number of points, that each represent the period from high tide to low tide, with a data set corresponding to data from a given day. The data is aligned so that high tide for all three is the same data point, and low tide is the same data point, but these occur at different times of day. 30 data points covers 1 hour.
I want to label the x-axis as HT, HT+1 (to denote 1 hour after high tide), HT+2 (to denote 2 hours after high tide) etc but have no idea how to do this, and can't succinctly describe what I'm trying to do so I'm struggling to find information when I search. Does anyone have any guidance or knowledge about how to do this?
Thanks!
0 Comments
Accepted Answer
Clayton Gotberg
on 17 Apr 2021
Edited: Clayton Gotberg
on 17 Apr 2021
plot(<plot data>)
x_label_locations = [0 1 2]
x_labels = {'HT','HT+1','HT+2'}
xticks(x_label_locations)
xticklabels(x_labels)
If you prefer, you can also assign these directly to the axes properties:
plot(<plot data>)
x_label_locations = [0 1 2]
x_labels = {'HT','HT+1','HT+2'}
ax = gca; % Get current axes being plotted to
ax.XTick = x_label_locations;
Ax.XTickLabel = x_labels;
More Answers (0)
See Also
Categories
Find more on Oceanography and Hydrology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!