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

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World