<jupyter_start><jupyter_text>Plot Time Series<jupyter_code>import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
dates = np.arange(np.datetime64("2021-01-01"), np.datetime64("2021-01-22"))
dates[:10]
prices = np.random.default_rng(42).normal(500, 30, len(dates))
prices[:10]<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code>plt.plot_date(dates, prices, 
              ls="solid",
              c="orange",
              marker="^",
              markersize=10)<jupyter_output><empty_output><jupyter_text>Date Format<jupyter_code>import matplotlib.dates as mdates

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%a, %d %m"))
plt.plot_date(dates, prices, ls="solid")

plt.grid()
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Major Tick on X-axis<jupyter_code>plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%a, %d %m"))
plt.gca().xaxis.set_major_locator(mdates.DayLocator(interval=7))
plt.plot_date(dates, prices, ls="solid")

plt.grid()
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Minor Tick on X-axis<jupyter_code>plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%a, %d %m"))
plt.gca().xaxis.set_major_locator(mdates.DayLocator(interval=7))
plt.gca().xaxis.set_minor_locator(mdates.DayLocator())
plt.plot_date(dates, prices, ls="solid")

plt.grid()
plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16140602582496413, 'fraction_numerical': 0.025107604017216643, 'mean_word_length': 7.063583815028902, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '268415', 'license': 'MIT', 'n_tokens_mistral': 593, 'n_tokens_neox': 542, 'n_words': 61, 'path': 'matplotlib/time_series.ipynb', 'repo_name': 'windsuzu/PythonTricks42', 'size': '1394'}