Why am I getting an empty matplotlib figure object?

Viewed 33

I am trying to use matplotlib and pandas libraries to explore a bitcoin related dataset. I am attaching the code and output I got down below. Ideally I want a bar graph with the expected data which I am indeed getting, but along with an empty matplotlib figure object. I don't know what I am doing the error.

import matplotlib.pyplot as plt

%matplotlib inline
%config InlineBackend.figure_format = 'svg'
plt.style.use("fivethirtyeight")

...

# Colors for the bar plot
COLORS = [
    "orange",
    "green",
    "orange",
    "cyan",
    "cyan",
    "blue",
    "silver",
    "orange",
    "red",
    "green",
]

# Plotting market_cap_usd as before but adding the colors and scaling the y-axis
fig, ax = plt.subplots(nrows=1, ncols=1)
ax = cap10.plot.bar(color=COLORS, log=True)
# Giving the figure title
fig.suptitle("Top 10 market capitalization")  # <-----

# Annotating the y axis with 'USD'
ax.set_ylabel("USD")
# Final touch! Removing the xlabel as it is not very informative
ax.set_xticklabels([])
```
So far I have tried reading through the official matplotlib documentation`, but I couldn't find anything yet to not return that empty figure object. However, I noticed that whenever the cell has the below code, it automatically returns an output.
```python
    fig, ax = plt.subplots(nrows=1,ncols=2)
```
[![The Output][1]][1]


  [1]: https://i.stack.imgur.com/5GYAQ.png
0 Answers
Related