Hm, I tried both suggestions, and still no grid (removed PDF for simplicity):
import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(1,1,1) x = np.linspace(0,10,50) y = np.sin(x) plt.clf() plt.clf() plt.plot(x,y) leg = plt.legend(['legend 1']) plt.title('Sample title') ax.set_ylabel('Sample ylabel') ax.set_xlabel('Sample xlabel') ax.set_xticks(np.arange(0, 10, 20)) ax.set_xticks(np.arange(0, 10, 5), minor=True) ax.set_yticks(np.arange(-1,1,20)) ax.set_yticks(np.arange(-1,1,20), minor=True) ax.minorticks_on() ax.grid('on') plt.show() > And if you meant 'grid', I guess > > ax.grid('on') > > should be added. > > * Youngung Jeong, ì ìì * > > On Mon, Jun 1, 2015 at 4:38 PM, Sterling Smith <smit...@fusion.gat.com> > wrote: > >> Stephen, >> >> In your script, you give >> ax.minorticks_on >> but you need to call that function for anything to occur >> ax.minorticks_on() >> >> >> Also, did you see >> http://matplotlib.org/examples/pylab_examples/axes_props.html >> in case your original question was not answered. >> >> -Sterling >> >> On Jun 1, 2015, at 1:24PM, step...@theboulets.net wrote: >> >> > I only see that you added "plt.show()", but neither the grid or the >> axis >> > labels are showing up. >> > >> >> Here is what I see with a couple of things modified ? >> >> did you expect something else ? >> >> >> >> from matplotlib.backends.backend_pdf import PdfPages >> >> import matplotlib.pyplot as plt >> >> import numpy as np >> >> >> >> fig = plt.figure() >> >> ax = fig.add_subplot(1,1,1) >> >> >> >> x = np.linspace(0,10,50) >> >> y = np.sin(x) >> >> >> >> with PdfPages('grid_test.pdf') as pdf: >> >> plt.clf() >> >> >> >> plt.clf() >> >> plt.plot(x,y) >> >> leg = plt.legend(['legend 1']) >> >> plt.title('Sample title') >> >> ax.set_ylabel('Sample ylabel') >> >> ax.set_xlabel('Sample xlabel') >> >> >> >> ax.set_xticks(np.arange(0, 10, 20)) >> >> ax.set_xticks(np.arange(0, 10, 5), minor=True) >> >> ax.set_yticks(np.arange(-1,1,20)) >> >> ax.set_yticks(np.arange(-1,1,20), minor=True) >> >> >> >> ax.minorticks_on >> >> plt.show() >> >> >> >> pdf.savefig() >> >> >> >> >> >> [cid:8C80F2A2-AD50-4E09-B0EF-0596312F5093@ornl.gov] >> >> >> >> >> >> >> >> On Jun 1, 2015, at 2:49 PM, >> >> <step...@theboulets.net<mailto:step...@theboulets.net>> >> >> wrote: >> >> >> >> I am having an issue with the grid not appearing that I cannot figure >> out. >> >> Can anyone help? Thanks. --StephenB >> >> >> >> from matplotlib.backends.backend_pdf import PdfPages >> >> import matplotlib.pyplot as plt >> >> import numpy as np >> >> >> >> fig = plt.figure() >> >> ax = fig.add_subplot(1,1,1) >> >> >> >> x = np.linspace(0,10,50) >> >> y = np.sin(x) >> >> >> >> with PdfPages('grid_test.pdf') as pdf: >> >> plt.clf() >> >> >> >> plt.clf() >> >> plt.plot(x,y) >> >> leg = plt.legend(['legend 1']) >> >> plt.title('Sample title') >> >> ax.set_ylabel('Sample ylabel') >> >> ax.set_xlabel('Sample xlabel') >> >> >> >> ax.set_xticks(np.arange(0, 10, 20)) >> >> ax.set_xticks(np.arange(0, 10, 5), minor=True) >> >> ax.set_yticks(np.arange(-1,1,20)) >> >> ax.set_yticks(np.arange(-1,1,20), minor=True) >> >> >> >> ax.minorticks_on >> >> >> >> pdf.savefig() >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> >> Matplotlib-users mailing list >> >> Matplotlib-users@lists.sourceforge.net<mailto: >> Matplotlib-users@lists.sourceforge.net> >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> >> >> >> > >> > >> > >> > >> ------------------------------------------------------------------------------ >> > _______________________________________________ >> > Matplotlib-users mailing list >> > Matplotlib-users@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users