This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
pub_counts_10.reverse() # reverse order so that largest bar is on top | |
pub_names_10.reverse() # (Plotly will graph the bottom bar first) | |
bar_chart = go.Figure(go.Bar( | |
x = pub_counts_10, | |
y = pub_names_10, | |
orientation='h', # horizontal bar chart | |
marker=dict( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
with open("math-topic-page.html", encoding='utf-8') as f: | |
contents = f.read() | |
soup = BeautifulSoup(contents, 'lxml') | |
for sect in soup.find_all('section'): | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for a in sect.find_all('a'): | |
# i'm looking for an <a> tag in the <section> that starts with the string " in" | |
if (len(a.text) > 4 and a.text[0].isspace() and a.text[1:3] == "in"): | |
# The publication name is inside the <a> tag following the substring " in" | |
pub_name = a.text[4:] | |
if pub_name in pubs: | |
pub_count[pubs.index(pub_name)] += 1 | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub_count, pubs = zip(*sorted(zip(pub_count, pubs), reverse=True)) | |
pub_count_10 = list(pub_count)[0:10] | |
pub_names_10 = list(pubs)[0:10] | |
# pub_counts_10 = [131, 80, 32, 30, 26, 24, 18, 17, 16, 15] | |
# pub_names_10 = [['Cantors Paradise', 'Towards Data Science', 'MathAdam', 'Geek Culture', 'Nerd For Tech', | |
# 'Analytics Vidhya', 'Not Zero', 'The Breakthrough', 'DataDrivenInvestor', 'Math Simplified'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
fig2 = go.Figure( | |
data=[go.Pie( | |
labels=['Self-published','Top 10 Pubs.','Other Pubs.'], | |
values=[self_pub_count, top_ten_count, other_pubs_count], # these are counts generated from my data | |
marker=dict( | |
colors=['rgba(235, 141, 0, 0.75)', 'rgba(0, 45, 168, 0.5)', 'rgba(29, 122, 246,0.25)'], | |
line=dict(color='rgba(0, 45, 168, 1)', width=3) # style the pie sectors | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# topic_list = ["Accessibility", "Addiction", "Android Dev", "Artificial Intelligence",...] | |
# monthly_counts = {"Accessibility": 26, "Addiction": 71, "Android Dev": 132, "Artificial Intelligence": 101, ...} | |
html_string = "" | |
heading_list = [] | |
for topic in topic_list: | |
# In Medium articles, the large headings are <h3> tags | |
string = "<h3>"+topic+"</h3>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg> | |
<circle cx=50 cy=50 r=20 stroke=darkblue fill=lightblue></circle> | |
</svg> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script src="https://d3js.org/d3.v6.min.js"></script> | |
</head> | |
<body> | |
<svg> | |
<circle cx=50 cy=50 r=20 stroke=darkblue fill=lightblue></circle> | |
</svg> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function expandShrink(){ | |
d3.select("#blueCircle") | |
.transition() | |
.duration(1600) | |
.attr("r", 50) // increase radius to 50px | |
.transition() | |
.duration(800) | |
.attr("fill", "yellow") // change to yellow (why not!) | |
.transition() | |
.duration(800) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
articleData = [ | |
{ | |
"title": "A Ranking Problem", | |
"upvotes": 1, | |
"views": 76, | |
"reads": 31, | |
"firstPublishedAt": 1630705429358, | |
"readingTime": 5, | |
"claps": 1, | |
"internalReferrerViews": 20, |
OlderNewer