overlapping ticks in x axis

Hello,

I have attached the histogram that I generated. When specifying large numbers like 1000 or more, the xticks tend to overlap and it gives a clumsy impression. Is there a way to avoid this?. What can be done to give gaps between the ticks?. Say in my case just show 3 to 4 ticks in x axis rather than specifying all the ticks. The following is my code:

def plotHistogram(veh_no, value, vehicle_no, fig_no):

     font = {'family' : 'serif',
         'weight' : 'normal',
         'size' : 10}
     rc('font', **font)
     count = 1
     legends = []
     print veh_no
     plt.figure(num=fig_no,dpi=105)
     for i in range(len(value)):
         ax = plt.subplot(2,2,i+1)
         n, bins, patches = plt.hist(value[i],100,label=veh_no[i])
         plt.ylabel('frequency',position=(0.5,0.5))
         plt.xlabel('x valuels')
         plt.grid()
         min_val = int(round(min(value[i]),0))
         max_val = int(round(max(value[i]),0))
         ax.set_xlim(min_val-2,max_val+2)
         locs,labels = plt.xticks()
         plt.xticks(locs, map(lambda x: "%g" % x, locs))
     plt.savefig('figurename.eps',dpi=70)
     count += 1

Thank You
Vineeth

test_hist.eps (123 KB)

Vineeth,

I think that you are looking for
from matplotlib.ticker import MaxNLocator

-Sterling

···

On Mar 3, 2013, at 5:38PM, vineeth wrote:

Hello,

I have attached the histogram that I generated. When specifying large numbers like 1000 or more, the xticks tend to overlap and it gives a clumsy impression. Is there a way to avoid this?. What can be done to give gaps between the ticks?. Say in my case just show 3 to 4 ticks in x axis rather than specifying all the ticks. The following is my code:

def plotHistogram(veh_no, value, vehicle_no, fig_no):

   font = {'family' : 'serif',
       'weight' : 'normal',
       'size' : 10}
   rc('font', **font)
   count = 1
   legends = []
   print veh_no
   plt.figure(num=fig_no,dpi=105)
   for i in range(len(value)):
       ax = plt.subplot(2,2,i+1)
       n, bins, patches = plt.hist(value[i],100,label=veh_no[i])
       plt.ylabel('frequency',position=(0.5,0.5))
       plt.xlabel('x valuels')
       plt.grid()
       min_val = int(round(min(value[i]),0))
       max_val = int(round(max(value[i]),0))
       ax.set_xlim(min_val-2,max_val+2)
       locs,labels = plt.xticks()
       plt.xticks(locs, map(lambda x: "%g" % x, locs))
   plt.savefig('figurename.eps',dpi=70)
   count += 1

Thank You
Vineeth
<test_hist.eps>------------------------------------------------------------------------------
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_feb_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Sterling,

Thank you, ya I got it working using MaxNLocator

···

On Tue, Mar 5, 2013 at 12:49 PM, Sterling Smith <smithsp@…3304…> wrote:

Vineeth,

I think that you are looking for

from matplotlib.ticker import MaxNLocator

-Sterling

On Mar 3, 2013, at 5:38PM, vineeth wrote:

Hello,

I have attached the histogram that I generated. When specifying large numbers like 1000 or more, the xticks tend to overlap and it gives a clumsy impression. Is there a way to avoid this?. What can be done to give gaps between the ticks?. Say in my case just show 3 to 4 ticks in x axis rather than specifying all the ticks. The following is my code:

def plotHistogram(veh_no, value, vehicle_no, fig_no):

font = {‘family’ : ‘serif’,

   'weight' : 'normal',
   'size'   : 10}

rc(‘font’, **font)

count = 1

legends = []

print veh_no

plt.figure(num=fig_no,dpi=105)

for i in range(len(value)):

   ax = plt.subplot(2,2,i+1)
   n, bins, patches = plt.hist(value[i],100,label=veh_no[i])
   plt.ylabel('frequency',position=(0.5,0.5))
   plt.xlabel('x valuels')
   plt.grid()
   min_val = int(round(min(value[i]),0))
   max_val = int(round(max(value[i]),0))
   ax.set_xlim(min_val-2,max_val+2)
   locs,labels = plt.xticks()
   plt.xticks(locs, map(lambda x: "%g" % x, locs))

plt.savefig(‘figurename.eps’,dpi=70)

count += 1

Thank You

Vineeth

<test_hist.eps>------------------------------------------------------------------------------

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_feb_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Don’t tell GOD how Big your storm is…TELL THE STORM HOW BIG YOUR GOD IS!!!