问题
Using matplotlib subplots()
in Jupyter Notebook, and using "seaborn-whitegrid" plot.style()
.
I am trying to add minor gridlines to my x-axis, which is in log.
What am I missing?
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('seaborn-whitegrid')
x, y = [(1, 9, 65, 142, 330), (0, 0.16, 0.50, 0.84, 1)]
fig, axes = plt.subplots(3,5, figsize=(8.5,5.5), constrained_layout=True)
#counter = 0
for ax in axes.flat:
ax.plot(x,y)
ax.set_title('Dataset-A', fontsize=8)
ax.set_xlabel('x', fontsize=8)
ax.set_ylabel('CFD', fontsize=8)
ax.set_xscale('log')
ax.set_xlim([1, 1000])
ax.set_ylim([0, 1])
ax.grid(True, axis='both', which='minor', color='red')
#counter += 1 ##will use to iterate through real dataset
来源:https://stackoverflow.com/questions/65727726/matplotlib-add-gridlines-not-working-as-expected