From: <st...@th...> - 2015-06-01 19:06:57
|
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() |
From: Bilheux, Jean-C. <bil...@or...> - 2015-06-01 19:21:52
Attachments:
Screen Shot 2015-06-01 at 3.21.04 PM.png
|
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:8C8...@or...] On Jun 1, 2015, at 2:49 PM, <st...@th...<mailto:st...@th...>> 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 Mat...@li...<mailto:Mat...@li...> https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: <st...@th...> - 2015-06-01 20:24:44
|
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:8C8...@or...] > > > > On Jun 1, 2015, at 2:49 PM, > <st...@th...<mailto:st...@th...>> > 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 > Mat...@li...<mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > |
From: Sterling S. <sm...@fu...> - 2015-06-01 20:37:57
|
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, st...@th... 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:8C8...@or...] >> >> >> >> On Jun 1, 2015, at 2:49 PM, >> <st...@th...<mailto:st...@th...>> >> 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 >> Mat...@li...<mailto:Mat...@li...> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Youngung J. <you...@gm...> - 2015-06-01 21:24:32
|
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 <sm...@fu...> 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, st...@th... 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:8C8...@or...] > >> > >> > >> > >> On Jun 1, 2015, at 2:49 PM, > >> <st...@th...<mailto:st...@th...>> > >> 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 > >> Mat...@li...<mailto: > Mat...@li...> > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > >> > >> > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: <st...@th...> - 2015-06-03 13:28:06
|
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 <sm...@fu...> > 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, st...@th... 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:8C8...@or...] >> >> >> >> >> >> >> >> On Jun 1, 2015, at 2:49 PM, >> >> <st...@th...<mailto:st...@th...>> >> >> 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 >> >> Mat...@li...<mailto: >> Mat...@li...> >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> >> >> >> > >> > >> > >> > >> ------------------------------------------------------------------------------ >> > _______________________________________________ >> > Matplotlib-users mailing list >> > Mat...@li... >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > |
From: Youngung J. <you...@gm...> - 2015-06-03 14:54:08
|
I think the problem is associated with the way np.arange is used. "np.arange(0,10,20)" would return array[0] If you still would like to manually configure the tick positions the way you seemed to want, you can use "np.linspace". Below worked for me. ---- 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) ax.plot(x,y) ax.grid('on') leg = plt.legend(['legend 1']) plt.title('Sample title') ax.set_ylabel('Sample ylabel') ax.set_xlabel('Sample xlabel') ax.set_xticks(np.linspace(0, 10, 11)) ax.set_yticks(np.linspace(-1,1,11)) ax.minorticks_on() plt.show() * Youngung Jeong* On Wed, Jun 3, 2015 at 9:27 AM, <st...@th...> wrote: > 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 <sm...@fu...> > > 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, st...@th... 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:8C8...@or...] > >> >> > >> >> > >> >> > >> >> On Jun 1, 2015, at 2:49 PM, > >> >> <st...@th...<mailto:st...@th...>> > >> >> 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 > >> >> Mat...@li...<mailto: > >> Mat...@li...> > >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> >> > >> >> > >> >> > >> > > >> > > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > _______________________________________________ > >> > Matplotlib-users mailing list > >> > Mat...@li... > >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Mat...@li... > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: <st...@th...> - 2015-06-03 13:39:33
|
But this works: 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') plt.ylabel('Sample ylabel') plt.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.grid(True) plt.show() > 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 <sm...@fu...> >> 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, st...@th... 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:8C8...@or...] >>> >> >>> >> >>> >> >>> >> On Jun 1, 2015, at 2:49 PM, >>> >> <st...@th...<mailto:st...@th...>> >>> >> 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 >>> >> Mat...@li...<mailto: >>> Mat...@li...> >>> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> >>> >> >>> >> >>> > >>> > >>> > >>> > >>> ------------------------------------------------------------------------------ >>> > _______________________________________________ >>> > Matplotlib-users mailing list >>> > Mat...@li... >>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Bilheux, Jean-C. <bil...@or...> - 2015-06-03 13:54:53
|
Works for me too using plt.grid() but I can't find the way to customize the grid (size, type…)? trying http://matplotlib.org/examples/pylab_examples/axes_props.html doesn't do anything for me ! On Jun 3, 2015, at 9:39 AM, <st...@th...> wrote: > But this works: > > 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') > plt.ylabel('Sample ylabel') > plt.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.grid(True) > plt.show() > > >> 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 <sm...@fu...> >>> 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, st...@th... 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:8C8...@or...] >>>>>> >>>>>> >>>>>> >>>>>> On Jun 1, 2015, at 2:49 PM, >>>>>> <st...@th...<mailto:st...@th...>> >>>>>> 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 >>>>>> Mat...@li...<mailto: >>>> Mat...@li...> >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>> ------------------------------------------------------------------------------ >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>> >> >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |