I realize that this question has been asked before(Python Pyplot Bar Plot bars disappear when using log scale), but the answer given did not work for me. I set my pyplot.bar(x_values, y_values, etc, log = True) but got an error that says:
"TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'"
I have been searching in vain for an actual example of pyplot code that uses a bar plot with the y-axis set to log but haven't found it. What am I doing wrong?
here is the code:
import matplotlib.pyplot as pyplot
ax = fig.add_subplot(111)
fig = pyplot.figure()
x_axis = [0, 1, 2, 3, 4, 5]
y_axis = [334, 350, 385, 40000.0, 167000.0, 1590000.0]
ax.bar(x_axis, y_axis, log = 1)
pyplot.show()
I get an error even when I removre pyplot.show. Thanks in advance for the help
Are you sure that is all your code does? Where does the code throw the error? During plotting? Because this works for me:
In [16]: import numpy as np
In [17]: x = np.arange(1,8, 1)
In [18]: y = np.exp(x)
In [20]: import matplotlib.pyplot as plt
In [21]: fig = plt.figure()
In [22]: ax = fig.add_subplot(111)
In [24]: ax.bar(x, y, log=1)
Out[24]:
[<matplotlib.patches.Rectangle object at 0x3cb1550>,
<matplotlib.patches.Rectangle object at 0x40598d0>,
<matplotlib.patches.Rectangle object at 0x4059d10>,
<matplotlib.patches.Rectangle object at 0x40681d0>,
<matplotlib.patches.Rectangle object at 0x4068650>,
<matplotlib.patches.Rectangle object at 0x4068ad0>,
<matplotlib.patches.Rectangle object at 0x4068f50>]
In [25]: plt.show()
Here's the plot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With