**Tell us what’s happening:**

I need to create a bar plot that has each bar represent the average monthly views, which the bars grouped together for each year

**Your code so far**

I tried to seperate the data by month and year to get average monthly views but I am unsure how to move forward from here to plot a bar graph. Would appreciate any advice as to what I can do to help solve this exercise even if it requires me to start from scratch.

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36`

**Challenge:** Data Analysis with Python Projects - Page View Time Series Visualizer

**Link to the challenge:**

Hey @19ngohtizhen, could you upload your entire code so I can check it out?

Hi @bsandma1 , sure.

Also if it helps I need to create this graph

I tried to manually insert the values into a list as you can see from the bottom part of the screenshot.

However when plotting the graph for may eventually the graphs overlap and I’m not sure how to fix that either.

So, as I told another person having similar graph issues on the data analysis projects, a lot of the issues came from 2 main things, for me at least:

- Knowing when to use matplotlib, seaborn or a combination of the two
- Finding an overcomplicated example on google, when the solution is much simpler

I’m assuming that you got the first graph (the one you scribbled out) to show correctly. In that graph I only used matplotlib, because that’s all that was needed. Now for the second graph, you have a ton of code, and it’s all matplotlib, but I plotted about 95% of what I needed using one seaborn function. Seaborn has a function `sns.barplot()`

and you just need to look at the keyword arguments of `barplot()`

and use whatever is necessary to pop the graph out. After that, you make any necessary tweaks to the graph using matplotlib.

So, my first bit of code was this:

```
f, ax = plt.subplots(figsize=(8,7))
sns.barplot(# Everything inside here is for you to fill out)
```

I created a figure first because, though seaborn makes the entire graph on its on, it needs a figure to sit inside for the replit to save it and display it as a picture.

I then created the seaborn barplot. I left the parameters of the function for you to figure out but that’s really all there is to this chart, ASSUMING your data is correct.

After the seaborn graph part, I only had to use matplotlib (`plt`

) a couple more times to tweak a couple of minor things, which you can do because you will have created a matplotlib figure (`f, ax = plt.subplots(figsize=(8,7))`

) to work with.

I hope this helps, let me know if anything doesn’t make sense!

1 Like

Hello sorry for the late reply, I was finally able to successfully replicate the figure using seaborn. I thought that I had to plot it using plt.bar but utilising seaborn I was able to achieve the results required. Thank you again for the help, much appreciated!

1 Like