Add VT2-examples: all 6 chapters of 'Visualize This' (110 files) — data scraping, ETL, trends, categorical, multivariate, spatial, distribution analysis
This commit is contained in:
1 parent
088771a9cf
commit
b42b866a8c
110 files changed
+400895
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
# import seaborn as sns
|
||||
# import math
|
||||
|
||||
# Load data
|
||||
marjobs = pd.read_csv("data/physician-marry.tsv", delimiter="\t")
|
||||
marsorted = marjobs.sort_values(by=['p'],
|
||||
ascending=False)[0:10] # Top 10.
|
||||
|
||||
# Prepare data for circles using bubble plot
|
||||
mardf = pd.DataFrame({
|
||||
"x": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"y": [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
|
||||
"r": list(marsorted.p * 50000)
|
||||
})
|
||||
|
||||
# sns.set(rc={'pdf.fonttype': 42 })
|
||||
|
||||
# p1 = sns.relplot(x="x", y="y", size="r", sizes=(40,2000), data=mardf)
|
||||
# fig = p1.get_figure()
|
||||
# p1.savefig("symbols-chart-mar.pdf")
|
||||
|
||||
|
||||
# Figure size
|
||||
plt.rcParams['figure.figsize'] = (7, 10)
|
||||
plt.rcParams['pdf.fonttype'] = 42
|
||||
|
||||
# Plot
|
||||
plt.scatter("x", "y", s="r", data=mardf)
|
||||
|
||||
# Text
|
||||
for i in range(0, len(marsorted)):
|
||||
thelabel = str(round(100*marsorted.iloc[i].p)) + "%, "
|
||||
thelabel += marsorted.iloc[i].occname
|
||||
plt.text(1, 10-i, thelabel)
|
||||
|
||||
# Save as PDF
|
||||
plt.savefig("symbols-chart-mar.pdf")
|
||||
Reference in new issue
Block a user