This is giving me major grid lines, as shown below.
How do I get one dark axis line for just y = 0?
fig, ax1 = subplots(figsize=(3,6))
ax1.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.5)
bound = 20
ylim([-bound,bound])
boxplot(data)
show()
In matplotlib, to draw a horizontal line at 0 we have to set the value of the y coordinate 0. Here we use hlines() method and pass the y, xmin, xmax, color, linestyle, and linewidth as an argument.
Matplotlib allows you to regulate the transparency of a graph plot using the alpha attribute. By default, alpha=1. If you would like to form the graph plot more transparent, then you'll make alpha but 1, such as 0.5 or 0.25.
You need a call to axhline
:
axhline(0, color='black')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With