Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dark Axis Line at y = 0 in Matplotlib

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()

box and whisker plot

like image 822
Chris Redford Avatar asked Sep 17 '14 19:09

Chris Redford


People also ask

How do you draw a line in y 0 matplotlib?

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.

How do I change the opacity of a line in matplotlib?

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.


1 Answers

You need a call to axhline:

axhline(0, color='black')

enter image description here

like image 117
Chris Redford Avatar answered Sep 19 '22 08:09

Chris Redford