Tags:147-6,ticks on the plot are not disppearing

Screen Link: <-https://app.dataquest.io/m/147/improving-plot-aesthetics/6/hiding-tick-marks-->

My Code:

fig,ax=plt.subplots()
ax.plot(women_degrees["Year"],women_degrees["Biology"],color="blue",label="Women")
ax.plot(women_degrees["Year"],100-women_degrees["Biology"],color="red",label="Men")
ax.tick_params(bottom="off", top="off", left="off", right="off")
#ax.set_title("Percentage of Biology Degrees Awarded By Gender")
ax.legend(loc="upper right")

What I expected to happen:
Ticks are not disappearing when I run it on the jupiter notebook.Kindly help

What actually happened:

Replace this line with the output/error
Actual O/P  of the plot should be without any external ticks across all the axis

Hi @gsaran76, perhaps you could check out this article.

As mentioned in the article, it may be due to the versioning of matplotlib. Try setting the arguments in ax.tick_params() to False instead of off.

Hope this helps!

5 Likes

Latest version of matplotlib expects booleans in the bottom, top, left, right.

https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.axes.Axes.tick_params.html

so you may change the "off" to False.

ax.tick_params(bottom=False, top=False, left=False, right=False)
4 Likes