How to get (x,y) coordinates of a categorical bar graph?
Show older comments
Hello, I am using bar(a,b) to plot a bar graph, with the x-axis containg categorical data (a is a categorical array), and the y-axis containg numerical data (b is a vector of numerical values).
If I want to plot additional lines on this figure, or add text using text() function, I need to reference the (x,y) position on the bar graph. However, I'm limited in which x-positions I choose, since vector a only references x positions at the center of each category. Is there a way to reference numerical x positions?
Example:
In the image below, I know how to add text near the blue circle (which can be referenced by the first category along the x-axis and a y-value of -20), but don't know how to add text near the red circle (which can be referenced by a y-value of -20, but no x-value).

Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties 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!