Creating bar charts for top tags

Basics-Copy3.ipynb (48.5 KB)

Screen Link:
My Code:

tag = []
times_used = []
for row in top_times_tags_used:
plt.barh(top_times_tags_used[0], top_times_tags_used[1])
plt.title("Times Each Tag was Used")
plt.xlabel("Times Tag Used")

import matplotlib.pyplot as plt
from numpy import arange
%magic inline

fig, ax = plt.subplots()
bar_heights = top_times_tags_used.iloc[0].values
bar_positions = arange(25) + 0.25, bar_heights, 0.5)

What I expected to happen:
Bar plots to be created

What actually happened:

 typeerror: ‘int’ object is not subscriptable

for the first set of code and

ValueError: incompatible sizes: argument 'height' must be length 25 or scalar

for the second set of code

I’ve been trying to plot the top tags for a couple days now but keep running into errors. Suggestions please? Attached at the top is a copy of my notebook file.

Click here to view the jupyter notebook file in a new tab

1 Like

A bar plot takes only one argument. You do not need to specify both x and y.

The below worked. Used the pandas dataframe or series plotting style.

top_times_tags_used.plot(kind='barh', figsize=(16,8))

I tried this but am not able to generate a plot, even with I entered

import matplotlib.pyplot as plt

top_times_tags_used.plot(kind='barh', figsize=(16,8))

and got the output

<matplotlib.figure.Figure at 0x7f780a46ba90>
<matplotlib.figure.Figure at 0x7f780a2f7ac8>
/dataquest/system/env/python3/lib/python3.4/site-packages/plotly/matplotlylib/ UserWarning:

I found a path object that I don't think is part of a bar chart. Ignoring.
1 Like


This is a plot from your work. Kindly run all cells from above.

This is the cell with the first plot error.


Thanks for your advice. I tried logging out for a couple days, hard refresh, and reloading and am still getting the user warning error for both plots. From what others have posted in the community, this seems to be a technical glitch. I’m glad it should be plotting though.


For the guided projects, I usually prefer working on my own machine.

Maybe that was why I was able to make the plot.

Yes, I will keep that in mind as a possible option. And it is plotting now on the learning page!

Hi @vroomvroom:

Just another suggestion: If you don’t really have space on your local machine and the DQ platform is too slow, you can try doing your projects on Google Colab. Note that it is slightly different from the DQ platform (you will have to load in the datasets on your own). As most of the datasets we work with are csv files, here is an article on how to do so.

For more intense workflows like Deep Learning, Colab can also be helpful especially if you do not have a separate graphics card on your laptop (AMD, Nvidia etc.), as I heard from the experience of others that dedicated graphics takes rather long to run and train the models.

Hope this helps and happy learning!


Yes it does, thank you!

1 Like