0

So I got this task where the user provides a list of extenstions and then I need to plot a histogram of their occurrence, saving it to a png and pdf file. The output plot needs to have a title and its axis need to be identified as well. example : Input: [’aux’, ’log’, ’pdf’, ’py’, ’gz’, ’tex’, ’py’, ’pyc’, ’csv’, ’txt’, ’bin’, ’csv’] and then this is plotted to show a histogram of how many occurrences each extenstion have. Now I wrote this code but whenever I want to give x and y axis a titel or give my whole plot a titel I get error. I don't know what I am doing wrong as I searched everywhere and everyone is doing the same as me. Thanks!

import pandas
from collections import Counter


strings = input("Enter a list of extenstions separated by space")
list = strings.split()
letter_counts = Counter(list)
print(letter_counts)
df = pandas.DataFrame.from_dict(letter_counts, orient='index')
df.plot(kind='bar',x='extension',y='times', titel='Figure 1')
Mohammed
  • 195
  • 1
  • 3
  • 12
  • 2
    It seems typo `titel` - need `title` ? – jezrael Nov 11 '20 at 07:13
  • I would suggest you to use "file extensions" in the description instead of "extensions". – CypherX Nov 11 '20 at 07:16
  • title was typo, I get y and x axis from the question referred to. Got it solves. It was just like this to set axis names `ax = df.plot(kind='bar', title='Graph of occurences') ax.set(xlabel="Extenstions", ylabel="Times")` – Mohammed Nov 11 '20 at 07:24

0 Answers0