python - Using seaborn and contourf, how can I plot gridlines? -


using following code, first contour plot has grid lines. second plot, have imported seaborn, grid lines don't show up. need add make grid lines show on second plot.

import numpy np import matplotlib mpl import matplotlib.pyplot plt   dx=0.05 x=np.arange(0,5+dx,dx) y=x x,y = np.meshgrid(x,y) z = np.sin(x)**10+np.cos(10+y*y)*np.cos(x)  nbins=10 levels=mpl.ticker.maxnlocator(nbins=nbins).tick_values(z.min(),z.max())  plt.figure() plt.contourf(x,y,z,levels=levels) plt.colorbar() plt.grid('on')  import seaborn sns sns.set_context("notebook") sns.set_style("whitegrid")  plt.figure() plt.contourf(x,y,z,levels=levels) plt.colorbar() plt.grid('on') plt.show() 

first picture

second picture

you either need change either axes.axisbelow rc parameter or zorder of contourf plot. do

sns.set(context="notebook", style="whitegrid",         rc={"axes.axisbelow": false}) 

when set style or

plt.contourf(x, y, z, levels=levels, zorder=0) 

when draw plot.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -