How do I insert special tick labels onto an axis?
Show older comments
I have a vector of years and corresponding depths which I would like to plot in a bar chart. The years are labelled on the x axis. Say these years are 1800, 1820, 1840, 1860, ...., 1980. The first data point is at 1818. However, I would like to label one special year of 1788 on the x-axis before these automatic labels, with the y values being 0 for each x-axis point until 1818, which is the first one.
I have added the point (1788,0) to my data set which I am plotting, however I am having trouble adding the label at an appropriate distance relative to all the other labels.
This is what I have previously tried:
set(gca, 'xticklabel', {1788, 1800, 1820, 1840, 1860, 1880, 1900, 1920, 1940, 1960, 1980}) However, this gives me the label '1788' on the x-axis at the same spacing as all the other labels, but I want it to be positioned at the appropriate scale.
I have also tried With xticksat= [1788] but this doesn't work at all and gives me an error when I try to run the function.
Does anybody have any suggestions?
Help would be very much appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Axis Labels 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!