[Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: ax[1].get_ylim() (-0.61935483870967734, 0.61935483870967734) and doing a set_ylim doesn't have any effect. This seems to be caused by the set_aspect('equal'), since removing it results in plots with the correct limits -- but aspect that is not quite equal. It is affected by the figsize parameter in the call to subplots. It seems I can get the correct y limits and aspect if I keep the set_aspect('equal') and fiddle with the figsize. But that certainly doesn't seem to be a desirable behavior. Ideally, the set_ylim (or set_xlim) would be respected as well as the apect ratio and extra blank space around the figure would be added as needed to fit the figsize. By the way, using no figsize argument to subplots results in y limits even smaller than the data limits. Also, this problem does not occur for single (non-stacked) plots and the use of subplots_adjust also does not seem to affect the problem. I'm using matplotlib 1.2.0 I did notice that this issue is similar to that discussed in this thread: http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html Regards, Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If you want to fix the data limits, then you have to make the box adjustable. This can cause problems with shared axes, but you can try it with ax[0].set_aspect('equal', adjustable='box-forced'). Eric ax[1].get_ylim() (-0.61935483870967734, 0.61935483870967734) and doing a set_ylim doesn't have any effect. This seems to be caused by the set_aspect('equal'), since removing it results in plots with the correct limits -- but aspect that is not quite equal. It is affected by the figsize parameter in the call to subplots. It seems I can get the correct y limits and aspect if I keep the set_aspect('equal') and fiddle with the figsize. But that certainly doesn't seem to be a desirable behavior. Ideally, the set_ylim (or set_xlim) would be respected as well as the apect ratio and extra blank space around the figure would be added as needed to fit the figsize. By the way, using no figsize argument to subplots results in y limits even smaller than the data limits. Also, this problem does not occur for single (non-stacked) plots and the use of subplots_adjust also does not seem to affect the problem. I'm using matplotlib 1.2.0 I did notice that this issue is similar to that discussed in this thread: http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html Regards, Jon -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Agree with Eric. I guess if you remove sharex=True, it will work. Chao On Wed, Mar 20, 2013 at 10:27 PM, Eric Firing [via matplotlib] ml-node+s1069221n40690...@n5.nabble.com wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If you want to fix the data limits, then you have to make the box adjustable. This can cause problems with shared axes, but you can try it with ax[0].set_aspect('equal', adjustable='box-forced'). Eric ax[1].get_ylim() (-0.61935483870967734, 0.61935483870967734) and doing a set_ylim doesn't have any effect. This seems to be caused by the set_aspect('equal'), since removing it results in plots with the correct limits -- but aspect that is not quite equal. It is affected by the figsize parameter in the call to subplots. It seems I can get the correct y limits and aspect if I keep the set_aspect('equal') and fiddle with the figsize. But that certainly doesn't seem to be a desirable behavior. Ideally, the set_ylim (or set_xlim) would be respected as well as the apect ratio and extra blank space around the figure would be added as needed to fit the figsize. By the way, using no figsize argument to subplots results in y limits even smaller than the data limits. Also, this problem does not occur for single (non-stacked) plots and the use of subplots_adjust also does not seem to affect the problem. I'm using matplotlib 1.2.0 I did notice that this issue is similar to that discussed in this thread: http://www.mail-archive.com/matplotlib-users@.../msg05783.htmlhttp://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html Regards, Jon -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list [hidden email] http://user/SendEmail.jtp?type=nodenode=40690i=0 https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- If you reply to this email, your message will be added to the discussion below: http://matplotlib.1069221.n5.nabble.com/set-limits-not-obeyed-for-stacked-plots-when-set-aspect-equal-used-tp40689p40690.html To start a new topic under matplotlib - users, email ml-node+s1069221n...@n5.nabble.com To unsubscribe from matplotlib, click herehttp://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx . NAMLhttp://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- *** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 -- View this message in context: http://matplotlib.1069221.n5.nabble.com/set-limits-not-obeyed-for-stacked-plots-when-set-aspect-equal-used-tp40689p40691.html Sent from the matplotlib - users mailing list archive at Nabble.com.-- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar___
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
On 2013-03-20 14:25, Eric Firing wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If I understand right, though, in this case what should give is the spacing around the axes but inside the figure (as suggested in the original post). You should be able to fix the aspect ratio of the *axes* and also the dimensions of the *figure*, and let the slack be taken up by blank space around the axes. It would still be possible for the dimensions of the axes box to change, just not their aspect ratio (i.e., zooming in on an oblong region would just result in a lot of blank space). -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
On 2013-03-20 14:25, Eric Firing wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If I understand right, though, in this case what should give is the spacing around the axes but inside the figure (as suggested in the original post). You should be able to fix the aspect ratio of the *axes* and also the dimensions of the *figure*, and let the slack be taken up by blank space around the axes. It would still be possible for the dimensions of the axes box to change, just not their aspect ratio (i.e., zooming in on an oblong region would just result in a lot of blank space). -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
On 2013/03/20 3:16 PM, Brendan Barnwell wrote: On 2013-03-20 14:25, Eric Firing wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If I understand right, though, in this case what should give is the spacing around the axes but inside the figure (as suggested in the original post). You should be able to fix the aspect ratio of the *axes* and also the dimensions of the *figure*, and let the slack be taken up by blank space around the axes. It would still be possible for the dimensions of the axes box to change, just not their aspect ratio (i.e., zooming in on an oblong region would just result in a lot of blank space). That is exactly what I suggested--use the kwarg adjustable='box-forced' when axes are shared. I think this will not work quite right for zooming and panning, which is the reason the normal adjustable='box' is rejected when axes are shared. Eric -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Eric, I don't see it that way. Specifying an equal aspect ratio just means that I want the scaling of the axes to the same. Then specifying the data limits gives the overall scaling of the figure effectively. This works perfectly well for a single set of axes. The bounding space is allotted so that it all works. The problem only arises when I have the figures stacked. Then it seems that the bounding space becomes fixed for some reason and instead the axis limits are what gives instead of the space around the axes. By the way, the adjustable='box-forced' option to set_aspect generates an exception, ValueError: adjustable must be datalim for shared axes Jon On Wed, 2013-03-20 at 11:25 -1000, Eric Firing wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If you want to fix the data limits, then you have to make the box adjustable. This can cause problems with shared axes, but you can try it with ax[0].set_aspect('equal', adjustable='box-forced'). Eric ax[1].get_ylim() (-0.61935483870967734, 0.61935483870967734) and doing a set_ylim doesn't have any effect. This seems to be caused by the set_aspect('equal'), since removing it results in plots with the correct limits -- but aspect that is not quite equal. It is affected by the figsize parameter in the call to subplots. It seems I can get the correct y limits and aspect if I keep the set_aspect('equal') and fiddle with the figsize. But that certainly doesn't seem to be a desirable behavior. Ideally, the set_ylim (or set_xlim) would be respected as well as the apect ratio and extra blank space around the figure would be added as needed to fit the figsize. By the way, using no figsize argument to subplots results in y limits even smaller than the data limits. Also, this problem does not occur for single (non-stacked) plots and the use of subplots_adjust also does not seem to affect the problem. I'm using matplotlib 1.2.0 I did notice that this issue is similar to that discussed in this thread: http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg05783.html Regards, Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set limits not obeyed for stacked plots when set_aspect('equal') used
Hmm. It seems that the adjustable='box-forced' option to set_aspect does work. I don't know what went wrong the first time I tried it (probably a typo). So that solves my problem. Thanks Eric. It does seem to me that this should be the default behavior, though I can appreciate the difficulty with panning and zooming. Jon On Wed, 2013-03-20 at 18:16 -0700, Brendan Barnwell wrote: On 2013-03-20 14:25, Eric Firing wrote: On 2013/03/20 8:57 AM, Jonathan Slavin wrote: Hi all, I've run across a minor but annoying bug. It can be demonstrated pretty simply: fig, ax = plt.subplots(2,1,sharex=True,figsize=(7.,7.)) fig.subplots_adjust(hspace=0.0) x = 4.25*(np.arange(6.) - 2.5)/10. y = 0.6*x/max(x) ax[0].plot(x,y) ax[0].set_xlim(-1.2,1.2) ax[0].set_aspect('equal') ax[1].plot(x,y) ax[0].set_ylim(-0.6,0.6) ax[1].set_ylim(-0.6,0.6) ax[1].set_aspect('equal') plt.show() The problem is that the y limits on the two plots are slightly different from those set: I think the problem is that you are trying to specify too many things: you are specifying the box dimensions when you make the axes, then you are specifying xlim, and then you are specifying ylim, but then you are asking for a 1:1 aspect ratio. Something has to give! The aspect ratio handling is designed to provide the specified aspect ratio under a wide range of circumstances, including zooming and panning, and to do that, it has to be able to change something. You can choose to let the box dimensions be changeable, or the data limits. If I understand right, though, in this case what should give is the spacing around the axes but inside the figure (as suggested in the original post). You should be able to fix the aspect ratio of the *axes* and also the dimensions of the *figure*, and let the slack be taken up by blank space around the axes. It would still be possible for the dimensions of the axes box to change, just not their aspect ratio (i.e., zooming in on an oblong region would just result in a lot of blank space). -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Aligning xticks and labels with WeekdayLocator
On 19/03/2013 18:35, Paul Hobson wrote: On Tue, Mar 19, 2013 at 11:30 AM, Paul Hobson pmhob...@gmail.com mailto:pmhob...@gmail.com wrote: On Mon, Mar 18, 2013 at 8:34 PM, Mark Lawrence breamore...@yahoo.co.uk mailto:breamore...@yahoo.co.uk wrote: Matplotlib 1.2.0, Windows Vista, Python 3.3.0. I want the first major xtick label aligned with the first date that's plotted. This never happens with the value of day below set in the range zero to six. The first major tick label actually occurs as follows. Day Label date 0 25/03/2013 1 02/04/2013 2 10/04/2013 3 21/03/2013 4 29/03/2013 5 06/04/2013 6 17/03/2013 What am I doing wrong? If day is set to seven then no xticks are displayed but labels for 14/03/2013 and 13/03/2014 are displayed. I expected a ValueError or similar using this number. Could you explain this behaviour please? import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter, MultipleLocator from matplotlib.dates import DateFormatter, WeekdayLocator import datetime dates = [datetime.date(2013, 3, 14), datetime.date(2014, 3, 13)] values = [0, 1] plt.ylabel('Balance') plt.grid() ax = plt.subplot(111) plt.plot_date(dates, values, fmt = 'rx-') plt.axis(xmin=dates[0], xmax=dates[-1]) day = ? ax.xaxis.set_major_locator(WeekdayLocator(byweekday=day, interval=4)) ax.xaxis.set_minor_locator(WeekdayLocator(byweekday=day)) ax.xaxis.set_major_formatter(DateFormatter('%d/%m/%y')) ax.yaxis.set_major_formatter(FormatStrFormatter('£%0.2f')) ax.yaxis.set_minor_locator(MultipleLocator(5)) plt.setp(plt.gca().get_xticklabels(), rotation = 45, fontsize = 10) plt.setp(plt.gca().get_yticklabels(), fontsize = 10) plt.show() Mark, I've found that rotation_mode='anchor' works best when rotation != 0 So that makes it: plt.setp(plt.gca().get_xticklabels(), rotation = 45, fontsize = 10, rotation_mode='anchor' ) HTH, -paul I misread your question. Try setting your x-axis limits after defining the locators and formatters. -p Please accept my apologies for the delay in replying, plus I should also have mentioned originally that I've only encountered this problem with WeekdayLocator. Setting the x-axis limits after defining the locators and formatters makes no difference. I've resolved my issue by reverting back to using MonthLocator, which I originally disliked as the minor tick locations made the display look poor around that darned month of February. My solution has been to ignore all rrule type computing and use the following code. xticks = ax.get_xticks() minorTicks = [] for i,xt in enumerate(xticks, start=1): try: diff = (xticks[i] - xt) / 4 for i in range(1, 4): minorTicks.append(xt + i * diff) except IndexError: pass ax.set_xticks(minorTicks, minor=True) It works a treat, but if there's a simpler solution please let me know :) -- Cheers. Mark Lawrence -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users