<jupyter_start><jupyter_text>Playing with MatplotlibPlease note I am making no assumptions nor any conclusions as I have not studied this data, it's actual original source, the source I got it from or even looked at most of the dataset itself. It is just some data to make graphs with and part of a tutorial.Compared to the `percent_bachelors.ipynb` which was following a tutorial this is me actuall playing.With the xkcd style.<jupyter_code>import pandas as pd

#Demo used a direct link to the hosted file but a) slower and b) someone else's bandwidth
women_majors = pd.read_csv('percent_bachelors.csv', encoding='utf-8')

under_20 = women_majors.loc[0, women_majors.loc[0] < 20]
print(under_20)<jupyter_output>Agriculture           4.229798
Architecture         11.921005
Business              9.064439
Computer Science     13.600000
Engineering           0.800000
Physical Sciences    13.800000
Name: 0, dtype: float64<jupyter_text>Calling Matplotlib ... magic[Literally](https://ipython.readthedocs.io/en/stable/interactive/plotting.htmlid1) referred to as magic. Then again [Clarke's Third Law](https://en.wikipedia.org/wiki/Clarke%27s_three_laws).Calling it with the `inline` backend so the output (graphs) are shown under the code block that produced them<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Call XKCD!<jupyter_code>plt.xkcd()
under_20_graph = women_majors.plot(x = 'Year', y = under_20.index, figsize = (12,8))

import matplotlib.style as style
print(style.available)

colours = [[0,0,0], [230/255,159/255,0], [86/255,180/255,233/255], [0,158/255,115/255],
          [213/255,94/255,0], [0,114/255,178/255]]
#Defining our colour set
colours = [[0,0,0], [230/255,159/255,0], [86/255,180/255,233/255], [0,158/255,115/255],
          [213/255,94/255,0], [0,114/255,178/255]]
#Set the graph name and the data it is going to plot
fte_graph = women_majors.plot(x = 'Year', y = under_20.index, figsize = (12,8), color = colours, legend = False, dashes = [8, 5, 50, 5], marker = "x")
#Place some text in the correct position to be a title with weighing and larger size
fte_graph.text(x = 1966.65, y = 62.7, s = "Some title for this graph that is interesting", fontsize = 26, weight = "bold", alpha = .75)
#Place some text in the correct position to be a subtitle
fte_graph.text(x = 1966.65, y = 57, s = "A sub title text that goes on and on and on so hopefuly it will\nword wrap onto the second line and look awesome", fontsize = 19, alpha = .85)
#Place some text in the correct position and colour to generate a sig bar
fte_graph.text(x = 1965.8, y = -7, s = '    In your general direction                                                             Source: National Center for Education Statistics    ', fontsize = 14, backgroundcolor = 'grey')
#Widen the x axis
fte_graph.set_xlim(left = 1969, right = 2011)
#Make the x axis label invisible
fte_graph.xaxis.label.set_visible(False)
#Put a bold line over y = 0
fte_graph.axhline(y = 0, color = 'black', linewidth = 1.3, alpha = .7)
#Making the axis labels larger
fte_graph.tick_params(axis = 'both', which = 'major', labelsize = 18)
#Changing the x axis tick labels
fte_graph.set_yticklabels(labels = [-10, '0   ', '10   ', '20   ', '30   ', '40   ', '50%'])
#Line labels
fte_graph.text(x = 1994, y = 44, s = 'Agriculture', color = colours[0], weight = 'bold', rotation = 33)
fte_graph.text(x = 1985, y = 42.2, s = 'Architecture', color = colours[1], weight = 'bold', rotation = 18)
fte_graph.text(x = 2004, y = 51, s = 'Business', color = colours[2], weight = 'bold', rotation = -5)
fte_graph.text(x = 2001, y = 30, s = 'Computer Science', color = colours[3], weight = 'bold', rotation = -42.5)
fte_graph.text(x = 1987, y = 11.5, s = 'Engineering', color = colours[4], weight = 'bold')
fte_graph.text(x = 1976, y = 25, s = 'Physical Sciences', color = colours[5], weight = 'bold', rotation = 27,)
# The slices will be ordered and plotted counter-clockwise.

labels = under_20.index
sizes = under_20
colours = [[0,0,0], [230/255,159/255,0], [86/255,180/255,233/255], [0,158/255,115/255],
          [213/255,94/255,0], [0,114/255,178/255]]
explode = (0, 0, 0, 0.2, 0, 0.3) # only "explode" the 2nd slice (i.e. 'Hogs')

plt.pie(sizes, explode=explode, labels=labels, colors=colours,
        autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.show()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xticks([])
plt.yticks([])
ax.set_ylim([-30, 10])

data = np.ones(100)
data[70:] -= np.arange(30)

plt.annotate(
    'THE DAY I REALIZED\nI COULD COOK BACON\nWHENEVER I WANTED',
    xy=(70, 1), arrowprops=dict(arrowstyle='->'), xytext=(15, -10))

plt.plot(data)

plt.xlabel('time')
plt.ylabel('my overall health')

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.bar([-0.125, 1.0-0.125], [0, 100], 0.25)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([0, 1])
ax.set_xlim([-0.5, 1.5])
ax.set_ylim([0, 110])
ax.set_xticklabels(['CONFIRMED BY\nEXPERIMENT', 'REFUTED BY\nEXPERIMENT'])
plt.yticks([])

plt.title("CLAIMS OF SUPERNATURAL POWERS")

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14984079415620902, 'fraction_numerical': 0.0885933695448586, 'mean_word_length': 4.2250489236790605, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '231341', 'license': 'MIT', 'n_tokens_mistral': 2264, 'n_tokens_neox': 1919, 'n_words': 570, 'path': 'percent_bachelors_xkcd.ipynb', 'repo_name': 'garethhay/playing_with_matplotlib', 'size': '5339'}