<jupyter_start><jupyter_text>Bar Chart--- Let's import all the dependencies first.<jupyter_code># primary data structure library
import pandas as pd       

# primary plotting library
import matplotlib as mpl       

# importing the pyplot layer of matplotlib for easy usage
import matplotlib.pyplot as plt        

# optional: for ggplot-like style of plots
mpl.style.use(['ggplot'])        

# using the inline backend
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Now we'll create the DataFrame.<jupyter_code># dict for dummy data to be used in dataframe
data = { 'A': [45,67,23,18,54,82,87,43,67,78]}       

# list for indexes to be used in dataframe
index = [1, 2, 3,4,5,6,7,8,9,10]        

# making dataframe
df = pd.DataFrame(data, index=index)   

# showing dataframe
df.T<jupyter_output><empty_output><jupyter_text>To create a bar chart, we can pass one of two arguments via `kind` parameter in `plot()`:* `kind=bar` creates a *vertical* bar chart* `kind=barh` creates a *horizontal* bar chartLet's create the vertical bar chart first.<jupyter_code># ploting the graph
df.plot(kind ='bar',   # type of plot
             alpha=0.6,         # transparency of bars
             figsize=(10, 6)   # size of plot
            )

# giving title and labels
plt.title('Title of the Plot')
plt.ylabel('Label on Y-axis')
plt.xlabel('Label on X-axis')

# showing the plot
plt.show()<jupyter_output><empty_output><jupyter_text>Wait! something is not so pleasant here. The markings on x-axis are at 90°. Let's correct that.<jupyter_code># ploting the graph
df.plot(kind ='bar',
             alpha=0.6,   
             rot=0,   # rotating the markings on x-axis
             figsize=(10, 6)
            )

# giving titles and labels
plt.title('Title of the Plot')
plt.ylabel('Label on Y-axis')
plt.xlabel('Label on X-axis')

# showing the plot
plt.show()<jupyter_output><empty_output><jupyter_text>Let's plot the horizontal bar graph and also change the colour of bars.<jupyter_code># ploting the graph
df.plot(kind ='barh',   # type of plot
             alpha=0.6,     
             figsize=(10, 6),
             color='steelblue'  # changing the colors of the bars
            )

# giving titles and labels
plt.title('Title of the Plot')
plt.ylabel('Label on Y-axis')
plt.xlabel('Label on X-axis')

# showing the plot
plt.show()<jupyter_output><empty_output><jupyter_text>Now let's try and annotate the bars.<jupyter_code>df.plot(kind ='barh', 
             alpha=0.6,       
             figsize=(10, 6),   
             color='steelblue'
            )

# annotate value labels to each bar
for index, value in enumerate(df['A']): 
    label = value
    
    # place text at the end of bar (subtracting 3 from x, and 0.1 from y to make it fit within the bar)
    plt.annotate(label, xy=(value-3, index - 0.10), color='white')

plt.title('Title of the Plot')
plt.ylabel('Label on Y-axis')
plt.xlabel('Label on X-axis')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11406460296096904, 'fraction_numerical': 0.020524899057873486, 'mean_word_length': 3.205091937765205, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '77034', 'license': 'MIT', 'n_tokens_mistral': 1038, 'n_tokens_neox': 973, 'n_words': 312, 'path': 'Code/Bar Chart/Notebook.ipynb', 'repo_name': 'Tarun-Kamboj/Data_Visualization_with_Python', 'size': '2972'}