<div dir="ltr">When you use `plt.xticks` you are saying "please put ticks at these locations", thus you will only see ticks at [0, 10, .., 100], independent of what your limits are.<div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 7, 2019 at 3:22 AM Sreyan Chakravarty <<a href="mailto:sreyan32@gmail.com">sreyan32@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Given the code:<div><br></div><div>plt.axis([-5, 105, 0, 5])                  # x-axis from -5 to 105,<br>                                           # y-axis from 0 to 5<br><br>plt.xticks([10 * i for i in range(11)])</div><div><br></div><div>I see xticks only marks from 0, where as the axis starts from -5.</div><div><br></div><div>So does xticks only start marking from 0 even though the x-axis starts from -5 ?</div><div><br></div><div>Full Code:</div><div><br></div><div>from matplotlib import pyplot as plt<br>from collections import Counter<br><br>grades = [83, 95, 91, 87, 70, 0, 85, 82, 100, 67, 73, 77, 0]<br><br># Bucket grades by decile, but put 100 in with the 90s<br>histogram = Counter(min(grade // 10 * 10, 90) for grade in grades)<br><br>plt.bar([x + 5 for x in histogram.keys()],  # Shift bars right by 5<br>        histogram.values(),                 # Give each bar its correct height<br>        10,                                 # Give each bar a width of 10<br>        edgecolor=(0, 0, 0))                # Black edges for each bar<br><br>plt.axis([-5, 105, 0, 5])                  # x-axis from -5 to 105,<br>                                           # y-axis from 0 to 5<br><br>#xticks takes the highest value in the list given and then<br>plt.xticks([10 * i for i in range(11)])    # x-axis labels at 0, 10, ..., 100<br>plt.xlabel("Decile")<br>plt.ylabel("# of Students")<br>plt.title("Distribution of Exam 1 Grades")<br>plt.show()<br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-4171487423804131354gmail_signature"><div dir="ltr">Regards,<div>Sreyan Chakravarty</div></div></div></div></div>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Thomas Caswell<br><a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a></div>