I'm trying to get minor ticks and gridlines plotted in all plots when using lmplot, using the code below:
sns.set(context="notebook", style='white', font_scale=2)
g=sns.lmplot(data=data ,
x="x",
y="y",
col="item", # or use rows to display xplots in rows (one on top of the other)
fit_reg=False,
col_wrap=2,
scatter_kws={'linewidths':1,'edgecolor':'black', 's':100}
)
g.set(xscale='linear', yscale='log', xlim=(0,0.4), ylim=(0.01, 10000))
for ax in g.axes.flatten():
ax.tick_params(axis='y', which='both', direction='out', length=4, left=True)
ax.grid(b=True, which='both', color='gray', linewidth=0.1)
for axis in [ax.yaxis, ax.xaxis]:
formatter = FuncFormatter(lambda y, _: '{:.16g}'.format(y))
axis.set_major_formatter(formatter)
sns.despine()
g.tight_layout()
# Show the results
plt.show()
So far, only major ticks and gridlines are shwon in all plots.
Thanks for any advice for solving this
Your code work fine for me. I think the problem is that when the major labels are too big, matplotlib chooses not to display the minor ticks, and hence the minor grid lines. You may either change
font_scale, or increase the size of your figure (seeheight=inlmplot())Consider the following code with
font_scale=1compare with the result using
font_scale=2