<jupyter_start><jupyter_text>Ch4.0 Simple Line Plots<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
x = np.linspace(0, 10, 1000)
print(x)
plt.plot(x, np.sin(x));<jupyter_output><empty_output><jupyter_text>call the ``plot`` function multiple times:<jupyter_code>plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x));<jupyter_output><empty_output><jupyter_text>Adjusting the Plot: Line Colors and Styles<jupyter_code>plt.plot(x, np.sin(x - 0), color='blue')        # specify color by name
plt.plot(x, np.sin(x - 1), color='g')           # short color code (rgbcmyk)
plt.plot(x, np.sin(x - 2), color='0.75')        # Grayscale between 0 and 1
plt.plot(x, np.sin(x - 3), color='#FFDD44')     # Hex code (RRGGBB from 00 to FF)
plt.plot(x, np.sin(x - 4), color=(1.0,0.2,0.3)) # RGB tuple, values 0 to 1
plt.plot(x, np.sin(x - 5), color='chartreuse'); # all HTML color names supported<jupyter_output><empty_output><jupyter_text>the line style can be adjusted using the ``linestyle`` keyword:<jupyter_code>plt.plot(x, x + 0, linestyle='solid')
plt.plot(x, x + 1, linestyle='dashed')
plt.plot(x, x + 2, linestyle='dashdot')
plt.plot(x, x + 3, linestyle='dotted');

# For short, you can use the following codes:
plt.plot(x, x + 4, linestyle='-')  # solid
plt.plot(x, x + 5, linestyle='--') # dashed
plt.plot(x, x + 6, linestyle='-.') # dashdot
plt.plot(x, x + 7, linestyle=':');  # dotted<jupyter_output><empty_output><jupyter_text>``linestyle`` and ``color`` codes can be combined into a single non-keyword argument to the ``plt.plot()`` function:<jupyter_code>plt.plot(x, x + 0, '-g')  # solid green
plt.plot(x, x + 1, '--c') # dashed cyan
plt.plot(x, x + 2, '-.k') # dashdot black
plt.plot(x, x + 3, ':r');  # dotted red
plt.plot?<jupyter_output><empty_output><jupyter_text>Adjusting the Plot: Axes Limits<jupyter_code>plt.plot(x, np.sin(x))

plt.xlim(-1, 11)
plt.ylim(-1.5, 1.5);<jupyter_output><empty_output><jupyter_text>either axis to be displayed in reverse<jupyter_code>plt.plot(x, np.sin(x))

plt.xlim(10, 0)
plt.ylim(1.2, -1.2);
plt.plot(x, np.sin(x))
plt.axis([-1, 11, -1.5, 1.5]);<jupyter_output><empty_output><jupyter_text>automatically tighten the bounds around the current plot:<jupyter_code>plt.plot(x, np.sin(x))
plt.axis('tight');<jupyter_output><empty_output><jupyter_text>ensure an equal aspect ratio so that on your screen, one unit in ``x`` is equal to one unit in ``y``:<jupyter_code>plt.plot(x, np.sin(x))
plt.axis('equal');<jupyter_output><empty_output><jupyter_text>Labeling Plots<jupyter_code>plt.plot(x, np.sin(x))
plt.title("A Sine Curve")
plt.xlabel("x")
plt.ylabel("sin(x)");<jupyter_output><empty_output><jupyter_text>When multiple lines are being shown within a single axes, it can be useful to create a plot legend that labels each line type.Again, Matplotlib has a built-in way of quickly creating such a legend.It is done via the (you guessed it) ``plt.legend()`` method.Though there are several valid ways of using this, I find it easiest to specify the label of each line using the ``label`` keyword of the plot function:<jupyter_code>plt.plot(x, np.sin(x), '-g', label='sin(x)')
plt.plot(x, np.cos(x), ':b', label='cos(x)')
plt.axis('equal')

plt.legend();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17322354376334248, 'fraction_numerical': 0.01982311680390363, 'mean_word_length': 5.599597585513078, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '637060', 'license': 'Apache-2.0', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1279, 'n_words': 323, 'path': 'III_DataEngineer_BDSE10/1905_Python/TeacherCode/datascience/Ch4.0_Simple_Line_Plots.ipynb', 'repo_name': 'chaoannricardo/StudyNotes', 'size': '3279'}