Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Bar plot in Matlab with specified values on the x-axis

  1. Apr 8, 2015 #1
    In the plot below
    Code (Text):

    I like all the values of x to be displayed on the x-axis. For example by plotting this bar, the values of x=0.11,0.13, 0.15, 0.17, 0.19 are not displayed on the x-axis. I appreciate any help.
  2. jcsd
  3. Apr 8, 2015 #2


    User Avatar

    Staff: Mentor

    In the plot window, you can select Edit -> Axes Properties... There you can set where tics appear.
  4. Apr 8, 2015 #3


    User Avatar
    Gold Member



    After plotting, you can create a handle to the axes object (gca stands for, "get current axes") and then change the XTick property to whatever you'd like, such as your original x values:
    ax = gca;
    ax.XTick = x;

    Note: this assumes you're using R2014b+. For older releases you use the get/set functions to fetch or change properties of the axes.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Bar plot in Matlab with specified values on the x-axis