how do i bar plot a complete x axis and not just the last value <p>I am bar plotting probabilities as a function of successes in binomial trials. I am getting in my figure the expected Y values but only the last x value, which should span from 0 to 10. Here is my code:</p> <pre><code>close all; clc; p = 0.2; figure; for j = 1:500 for i = 1:10 a = rand(); success = fix(a*10); y = nchoosek(10,success)*(p^success)*(1-p)^(10-success); bar(success,y); hold on; end end </code></pre>