Skip to content

Extra Grid Line On Plot (PyPlot) #11758

Closed
@skitko

Description

@skitko

Bug report

Bug summary

When changing the color of major gridlines in a plot, some major grid lines will occasionally have a gray, slightly transparent line placed over it.

Code for reproduction

# Paste your code here
#
#
import numpy as np
import matplotlib.pyplot as plt

aX = np.array([4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])			# x-axis
aY = np.array([1,4,10,20,35,56,80,104,125,140,146,140,125,104,80,56,35,20,10,4,1])	# y-axis
aY = aY / aY.sum()

plt.plot(aX, aY)														# plot curve and show

plt.xlim((0, 30))
plt.ylim(ymin = 0)
plt.grid(True, 'major', color='k')
plt.minorticks_on()
plt.grid(True, 'minor', 'y')
plt.show()

Actual outcome

image

Note the major grid line at 0.06 seems to be "shaded over". Additionally, this issue doesn't happen if aY = aY / aY.sum() is commented out.

# If applicable, paste the console output here
#
#

Expected outcome

I would expect that all major grid lines have the color specified by plt.grid(True, 'major', color='k').

Matplotlib version

  • Operating system: Windows 7 Professional 64bit
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.2
  • Jupyter version (if applicable): N/A
  • Other libraries: numpy

I installed python from the available .exe file. I installed matplotlib according to the instructions on the website (with pip).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions