Why is my matplotlib bar chart compressing the x-axis when I do 'log'
<p>I am trying to make a bar chart with matplotlib for python. I can make a normal chart, but when I put it in logarithmic mode so that I can see the data better, the x-axis looks as if it is compressing. What is going on?
Note: all data records have a minimum value of 1.</p>

<pre><code>    x = [t[0] for t in data]
    y = [t[1]  for t in data]

    x_pos = np.arange(len(x))

    plt.bar(x_pos, y, color='blue', log=False)
    plt.xlabel(x_label)
    plt.ylabel(y_label)
    plt.title(title)
    plt.xlim([0, len(x)])
    #plt.yscale('log')
    #plt.semilogy(x_pos, np.exp(-x_pos/5.0))
    plt.savefig(output_path + '/' + filename)
</code></pre>

<p>Yields: <a href="https://i.stack.imgur.com/esNft.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/esNft.png" alt="enter image description here"></a></p>

<p>But just by changing <code>log=False</code> to <code>log=True</code> I get:
<a href="https://i.stack.imgur.com/ez9FK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ez9FK.png" alt="enter image description here"></a></p>

<p>What am I doing wrong? I just want to get a compressed view of the first graph on the y axis. As you can see, I also tried <code>yscale('log')</code> but I get the same result.</p>

<p>Thanks!</p>

<p>EDIT: Looks like it has something to do with the previous lines, when I remove the first line it works fine, but is unsorted:</p>

<pre><code>data = sorted(data, key=lambda tup: tup[1], reverse=True)

    # tuples (pair,count)
    x = [t[0] for t in data]
    y = [t[1]  for t in data]
</code></pre>