I need to update grid parameters (visible, which, axis, **kwargs) to customize the major and minor grid lines style. i tried using plt.grid(which='minor', linewidth=0.5, linestyle='dotted')
but it did not work; it only works if figure and subplot was created using matplotlib.pyplot.subplots()
.
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
from matplotlib.figure import Figure
class MatplotlibWidget(QWidget):
def __init__(self, parent=None):
self.canvas = Canvas(Figure(figsize=(8, 6)))
self.axes = self.canvas.figure.subplots()
i got this working by invoking grid() method of the axes to configure grid lines. refer to documentation here: matplotlib.axes.Axes.grid
axes.grid(which='minor', linewidth=0.5, linestyle='dotted')