<jupyter_start><jupyter_text>Chapter 4 - Practical Data Visualization Segment 1 - Creating standard data graphics<jupyter_code>import numpy as np
from numpy.random import randn
import pandas as pd
from pandas import Series, DataFrame

import matplotlib.pyplot as plt
from matplotlib import rcParams<jupyter_output><empty_output><jupyter_text>Creating a line chart from a list object  Plotting a line chart in matplotlib<jupyter_code>x = range(1,10)
y = [1,2,3,4,0,4,3,2,1]

plt.plot(x,y)<jupyter_output><empty_output><jupyter_text>Plotting a line chart from a Pandas object<jupyter_code>import pathlib
import os
address = pathlib.Path(os.getcwd()).parent
address = pathlib.Path(os.path.join(address, 'Data/mtcars.csv'))
cars = pd.read_csv(address)
cars.columns = ['car_names','mpg','cyl','disp', 'hp', 'drat', 'wt', 'qsec', 'vs', 'am', 'gear', 'carb']

mpg = cars['mpg']
mpg.plot()
df = cars[['cyl','wt','mpg']]
df.plot()<jupyter_output><empty_output><jupyter_text>Creating bar charts Creating a bar chart from a list<jupyter_code>plt.bar(x, y)<jupyter_output><empty_output><jupyter_text>Creating bar charts from Pandas objects<jupyter_code>mpg.plot(kind="bar")
mpg.plot(kind="barh")<jupyter_output><empty_output><jupyter_text>Creating a pie chart<jupyter_code>x = [1,2,3,4,0.5]
plt.pie(x)
plt.show()<jupyter_output><empty_output><jupyter_text>Saving a plot<jupyter_code>plt.pie(x)
plt.savefig('pie_chart.png')
plt.show()
%pwd<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1462912087912088, 'fraction_numerical': 0.013736263736263736, 'mean_word_length': 8.46103896103896, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '593999', 'license': 'MIT', 'n_tokens_mistral': 594, 'n_tokens_neox': 566, 'n_words': 112, 'path': 'Pt_1/04_01_Creating_standard_data_graphics/04_01_end.ipynb', 'repo_name': 'vladcuevas/Python-Data-Science-Labs', 'size': '1456'}