<p dir="auto">When using custom formatters/locators, duplicate axis labels are produced if the the formatters are set for both major and minor labels. I.e, this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from matplotlib import ticker

# Setup the figure
fig = plt.figure()
ax = fig.add_subplot(111) 

# Setup a formatter (just returns the same label)
fmt = ticker.StrMethodFormatter(&quot;{x:}&quot;)
ax.xaxis.set_major_formatter(fmt)
ax.xaxis.set_minor_formatter(fmt)

# Setup a locator
loc = ticker.LinearLocator(9)
ax.xaxis.set_major_locator(loc)
ax.xaxis.set_minor_locator(loc)

# Rotate the labels, just to show that they are duplicated (one set of labels will get rotated, one will not)
for lab in ax.xaxis.get_ticklabels():
     lab.set_rotation(45)

plt.draw()
plt.show()"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
from matplotlib import ticker

# Setup the figure
fig = plt.figure()
ax = fig.add_subplot(111) 

# Setup a formatter (just returns the same label)
fmt = ticker.StrMethodFormatter("{x:}")
ax.xaxis.set_major_formatter(fmt)
ax.xaxis.set_minor_formatter(fmt)

# Setup a locator
loc = ticker.LinearLocator(9)
ax.xaxis.set_major_locator(loc)
ax.xaxis.set_minor_locator(loc)

# Rotate the labels, just to show that they are duplicated (one set of labels will get rotated, one will not)
for lab in ax.xaxis.get_ticklabels():
     lab.set_rotation(45)

plt.draw()
plt.show()
</code></pre></div>
<p dir="auto">Produces duplicate labels (note: The set_rotation is not needed to produce the duplicates, but just shows that they actually are duplicated!)</p>
<p dir="auto">If I remove the call to set_minor_locator/formatter, the code works as expected:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from matplotlib import ticker
fig = plt.figure()
ax = fig.add_subplot(111) 
fmt = ticker.StrMethodFormatter(&quot;{x:}&quot;)
ax.xaxis.set_major_formatter(fmt)

loc = ticker.LinearLocator(9)
ax.xaxis.set_major_locator(loc)

for lab in ax.xaxis.get_ticklabels():
     lab.set_rotation(45)

plt.draw()
plt.show()"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
from matplotlib import ticker
fig = plt.figure()
ax = fig.add_subplot(111) 
fmt = ticker.StrMethodFormatter("{x:}")
ax.xaxis.set_major_formatter(fmt)

loc = ticker.LinearLocator(9)
ax.xaxis.set_major_locator(loc)

for lab in ax.xaxis.get_ticklabels():
     lab.set_rotation(45)

plt.draw()
plt.show()
</code></pre></div>
<p dir="auto">I've been looking through the code for a day, but can't find anywhere where there is an obvious error and I don't think I am doing anything particularly unusual in my code...</p>
<p dir="auto">Any idea what might be causing this?</p>
<p dir="auto">As far as I can tell, in order to produce this behaviour you need to set both a formatter and a locator. I've only tested with the formatter/locator classes given in the code above so far.</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
I generated a very large dotplot (figsize=(100,10)), but it only shows partial x-axis.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#!/usr/bin/env python

import matplotlib
matplotlib.use('Agg') # To solve remote session issues
import matplotlib.pyplot as plt
import sys, subprocess

depth_file = sys.argv[1]

window = int(100e3)
total_job = int(subprocess.check_output(['wc', '-l', depth_file]).split(' ')[0])

plt.figure(figsize=(100,10), dpi=600)
tick = int(10e6) # ticks interval: 10 Mb
x, y = [], []
pre = -1
n = 0
depth = 0
with open(depth_file, 'r') as inf:
	for line in inf:
		n += 1
		line = line.strip().split('\t')[1:]
		line[0] = int(line[0])
		line[1] = int(line[1])
		if n % window == 0 or line[0] == total_job:
			pos   = (line[0] - 1) / window + 1
			depth = depth*1.0 / n
			if depth &gt;= 100:
				depth = 100
				c = 'y^'
				a = 0.4
			elif depth &lt;= 10 and depth &gt;0:
				c = 'b.'
				a = 0.8
			elif depth == 0:
				c = 'rv'
				a = 0.8
			else:
				c = 'k.'
				a = 0.4
			plt.plot(pos, depth, c, alpha=a, clip_on=False)#, ms=2)
			n = 0
			depth = 0
		else:
			depth += line[1]
		process = round(line[0] * 100.0 / total_job, 1)
		if process &gt; pre:
			print '\rProcessing: %s' % str(process) + &quot;%...&quot;,
			sys.stdout.flush()
		pre = process
plt.xlim(0, 119556435/window+1)
plt.ylim(0, 100)
plt.xticks(map(lambda x: (x+1)*tick/window, range(total_job/tick)),
           map(lambda x: str((x+1)*10) + 'Mb', range(total_job/tick)),
           fontsize=28)
plt.yticks([0, 50, 100], [&quot;0&quot;, &quot;50&quot;, &quot;100&quot;], fontsize=28)
plt.xlabel('Position', fontsize=34)
plt.ylabel('Depth', fontsize=34)
#plt.gca().set_aspect('equal', adjustable='box')
plt.title(depth_file, loc='left')
plt.grid(b='on', lw=0.4, ls='--', axis='x')
plt.tight_layout()
plt.savefig('%s.w100k.png' % depth_file, dpi=600, transparent=True)
print 'Done.'"><pre class="notranslate"><span class="pl-c">#!/usr/bin/env python</span>

<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>
<span class="pl-s1">matplotlib</span>.<span class="pl-en">use</span>(<span class="pl-s">'Agg'</span>) <span class="pl-c"># To solve remote session issues</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">sys</span>, <span class="pl-s1">subprocess</span>

<span class="pl-s1">depth_file</span> <span class="pl-c1">=</span> <span class="pl-s1">sys</span>.<span class="pl-s1">argv</span>[<span class="pl-c1">1</span>]

<span class="pl-s1">window</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-c1">100e3</span>)
<span class="pl-s1">total_job</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-s1">subprocess</span>.<span class="pl-en">check_output</span>([<span class="pl-s">'wc'</span>, <span class="pl-s">'-l'</span>, <span class="pl-s1">depth_file</span>]).<span class="pl-en">split</span>(<span class="pl-s">' '</span>)[<span class="pl-c1">0</span>])

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>(<span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>), <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">600</span>)
<span class="pl-s1">tick</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-c1">10e6</span>) <span class="pl-c"># ticks interval: 10 Mb</span>
<span class="pl-s1">x</span>, <span class="pl-s1">y</span> <span class="pl-c1">=</span> [], []
<span class="pl-s1">pre</span> <span class="pl-c1">=</span> <span class="pl-c1">-</span><span class="pl-c1">1</span>
<span class="pl-s1">n</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>
<span class="pl-s1">depth</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>
<span class="pl-k">with</span> <span class="pl-en">open</span>(<span class="pl-s1">depth_file</span>, <span class="pl-s">'r'</span>) <span class="pl-k">as</span> <span class="pl-s1">inf</span>:
	<span class="pl-k">for</span> <span class="pl-s1">line</span> <span class="pl-c1">in</span> <span class="pl-s1">inf</span>:
		<span class="pl-s1">n</span> <span class="pl-c1">+=</span> <span class="pl-c1">1</span>
		<span class="pl-s1">line</span> <span class="pl-c1">=</span> <span class="pl-s1">line</span>.<span class="pl-en">strip</span>().<span class="pl-en">split</span>(<span class="pl-s">'<span class="pl-cce">\t</span>'</span>)[<span class="pl-c1">1</span>:]
		<span class="pl-s1">line</span>[<span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-s1">line</span>[<span class="pl-c1">0</span>])
		<span class="pl-s1">line</span>[<span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-s1">line</span>[<span class="pl-c1">1</span>])
		<span class="pl-k">if</span> <span class="pl-s1">n</span> <span class="pl-c1">%</span> <span class="pl-s1">window</span> <span class="pl-c1">==</span> <span class="pl-c1">0</span> <span class="pl-c1">or</span> <span class="pl-s1">line</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-s1">total_job</span>:
			<span class="pl-s1">pos</span>   <span class="pl-c1">=</span> (<span class="pl-s1">line</span>[<span class="pl-c1">0</span>] <span class="pl-c1">-</span> <span class="pl-c1">1</span>) <span class="pl-c1">/</span> <span class="pl-s1">window</span> <span class="pl-c1">+</span> <span class="pl-c1">1</span>
			<span class="pl-s1">depth</span> <span class="pl-c1">=</span> <span class="pl-s1">depth</span><span class="pl-c1">*</span><span class="pl-c1">1.0</span> <span class="pl-c1">/</span> <span class="pl-s1">n</span>
			<span class="pl-k">if</span> <span class="pl-s1">depth</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">100</span>:
				<span class="pl-s1">depth</span> <span class="pl-c1">=</span> <span class="pl-c1">100</span>
				<span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s">'y^'</span>
				<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-c1">0.4</span>
			<span class="pl-k">elif</span> <span class="pl-s1">depth</span> <span class="pl-c1">&lt;=</span> <span class="pl-c1">10</span> <span class="pl-c1">and</span> <span class="pl-s1">depth</span> <span class="pl-c1">&gt;</span><span class="pl-c1">0</span>:
				<span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s">'b.'</span>
				<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-c1">0.8</span>
			<span class="pl-k">elif</span> <span class="pl-s1">depth</span> <span class="pl-c1">==</span> <span class="pl-c1">0</span>:
				<span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s">'rv'</span>
				<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-c1">0.8</span>
			<span class="pl-k">else</span>:
				<span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s">'k.'</span>
				<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-c1">0.4</span>
			<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">pos</span>, <span class="pl-s1">depth</span>, <span class="pl-s1">c</span>, <span class="pl-s1">alpha</span><span class="pl-c1">=</span><span class="pl-s1">a</span>, <span class="pl-s1">clip_on</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)<span class="pl-c">#, ms=2)</span>
			<span class="pl-s1">n</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>
			<span class="pl-s1">depth</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>
		<span class="pl-k">else</span>:
			<span class="pl-s1">depth</span> <span class="pl-c1">+=</span> <span class="pl-s1">line</span>[<span class="pl-c1">1</span>]
		<span class="pl-s1">process</span> <span class="pl-c1">=</span> <span class="pl-en">round</span>(<span class="pl-s1">line</span>[<span class="pl-c1">0</span>] <span class="pl-c1">*</span> <span class="pl-c1">100.0</span> <span class="pl-c1">/</span> <span class="pl-s1">total_job</span>, <span class="pl-c1">1</span>)
		<span class="pl-k">if</span> <span class="pl-s1">process</span> <span class="pl-c1">&gt;</span> <span class="pl-s1">pre</span>:
			<span class="pl-k">print</span> <span class="pl-s">'<span class="pl-cce">\r</span>Processing: %s'</span> <span class="pl-c1">%</span> <span class="pl-en">str</span>(<span class="pl-s1">process</span>) <span class="pl-c1">+</span> <span class="pl-s">"%..."</span>,
			<span class="pl-s1">sys</span>.<span class="pl-s1">stdout</span>.<span class="pl-en">flush</span>()
		<span class="pl-s1">pre</span> <span class="pl-c1">=</span> <span class="pl-s1">process</span>
<span class="pl-s1">plt</span>.<span class="pl-en">xlim</span>(<span class="pl-c1">0</span>, <span class="pl-c1">119556435</span><span class="pl-c1">/</span><span class="pl-s1">window</span><span class="pl-c1">+</span><span class="pl-c1">1</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">ylim</span>(<span class="pl-c1">0</span>, <span class="pl-c1">100</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">xticks</span>(<span class="pl-en">map</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: (<span class="pl-s1">x</span><span class="pl-c1">+</span><span class="pl-c1">1</span>)<span class="pl-c1">*</span><span class="pl-s1">tick</span><span class="pl-c1">/</span><span class="pl-s1">window</span>, <span class="pl-en">range</span>(<span class="pl-s1">total_job</span><span class="pl-c1">/</span><span class="pl-s1">tick</span>)),
           <span class="pl-en">map</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-en">str</span>((<span class="pl-s1">x</span><span class="pl-c1">+</span><span class="pl-c1">1</span>)<span class="pl-c1">*</span><span class="pl-c1">10</span>) <span class="pl-c1">+</span> <span class="pl-s">'Mb'</span>, <span class="pl-en">range</span>(<span class="pl-s1">total_job</span><span class="pl-c1">/</span><span class="pl-s1">tick</span>)),
           <span class="pl-s1">fontsize</span><span class="pl-c1">=</span><span class="pl-c1">28</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">yticks</span>([<span class="pl-c1">0</span>, <span class="pl-c1">50</span>, <span class="pl-c1">100</span>], [<span class="pl-s">"0"</span>, <span class="pl-s">"50"</span>, <span class="pl-s">"100"</span>], <span class="pl-s1">fontsize</span><span class="pl-c1">=</span><span class="pl-c1">28</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">xlabel</span>(<span class="pl-s">'Position'</span>, <span class="pl-s1">fontsize</span><span class="pl-c1">=</span><span class="pl-c1">34</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">ylabel</span>(<span class="pl-s">'Depth'</span>, <span class="pl-s1">fontsize</span><span class="pl-c1">=</span><span class="pl-c1">34</span>)
<span class="pl-c">#plt.gca().set_aspect('equal', adjustable='box')</span>
<span class="pl-s1">plt</span>.<span class="pl-en">title</span>(<span class="pl-s1">depth_file</span>, <span class="pl-s1">loc</span><span class="pl-c1">=</span><span class="pl-s">'left'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">grid</span>(<span class="pl-s1">b</span><span class="pl-c1">=</span><span class="pl-s">'on'</span>, <span class="pl-s1">lw</span><span class="pl-c1">=</span><span class="pl-c1">0.4</span>, <span class="pl-s1">ls</span><span class="pl-c1">=</span><span class="pl-s">'--'</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-s">'x'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">tight_layout</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'%s.w100k.png'</span> <span class="pl-c1">%</span> <span class="pl-s1">depth_file</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">600</span>, <span class="pl-s1">transparent</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-k">print</span> <span class="pl-s">'Done.'</span></pre></div>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating System: Ubuntu 14.04</li>
<li>Matplotlib Version: 2.0.2</li>
<li>Python Version: 2.7.13</li>
<li>Jupyter Version (if applicable):</li>
<li>Other Libraries:</li>
</ul>