Musings of a dad with too much time on his hands and not enough to do. Wait. Reverse that.

Tag: tools (Page 23 of 35)

Ctrl + Shift + N

At work, I had a task of moving around a lot of files into new folders in Windows Explorer–and, unfortunately, not the kind of work I could script out.

After about the tenth time of right-clicking in Explorer, moving my mouse to “New” in the context menu, and waiting for the second menu to appear so that I could create a New Folder…I had had about enough. Surely there’s a quicker way to create a new folder in Windows Explorer. Well, there is: Ctrl + Shift + N

I do use several Windows shortcut keys, but, boy, are there a ton more out there! Check them all out here.

College Tuition vs. Starting Salary

A few months ago, Machine Learning Plus published a great article demonstrating the power of matplotlib by showcasing 50 cool visuals you can accomplish with the package. Inspired, I wanted to see if I could replicate some of these visuals, but with data I’m interested in.

So, I started with their bubble chart, but instead of using the strange, Midwest data they used, I thought I’d work in a space that’s been preoccupying my time of late: college tuition. What sort of bubble chart could I craft that depicted college tuition in some way? What about a bubble chart depicting the intersection of college tuitions and their corresponding average starting salaries? That might help parents and students better understand the return on investment associated with various colleges. Here’s what I came up with:

First, I decided to narrow down my work to just Ohio colleges. At Payscale.com, I found a dataset of median starting salaries by Ohio college for 2018.

Unfortunately, the Payscale.com dataset did not include college tuition prices. However, CollegeCalc.org did have a dataset of Ohio college tuition prices for 2018-2019.

Much of my work revolved around cleaning up these data sources and merging them together for the final visual. As you might imagine, each dataset tended to have slight name variations between schools. For example, the Payscale.com dataset had an entry for Kettering College whereas the CollegeCalc.org site calls that school Kettering College of Medical Arts. So, I had to do a fair amount of work making sure both datasets called each school the same name so that I could properly match on those names.

The Payscale.com dataset included some language to differentiate public schools from private, which I used to color my bubbles blue and red, respectively. The CollegeCalc.org dataset included the school size which I used to size each bubble.

Machine Learning Plus’s bubble chart includes a cool “encircling” device that draws a circle around certain datapoints to draw the user’s attention to those points. Instead of doing that, I thought it’d be interesting to draw a “break even” line. All things equal, if you pay, say, $10,000 in tuition for 4 years, you’re tuition investment would break even if your first job out of school paid $40,000. I drew a line to that effect on the graph: datapoints above that line would have a positive return on investment whereas datapoints below that line would have a negative return on investment. I didn’t want to muddy up the chart labeling each bubble with the name of the college, but I still thought it’d be fun to calculate which schools are above and below the line, so I found a way to do that, added the calculation as a column to the dataframe, and printed out the Top 5 “Best” returns on investment and the Top 5 “Worse” returns on investment.

Top 5 biggest ROI schools: 
68              Central State University
40        Kent State University at Salem
45     Kent State University at Trumbull
56    Kent State University at Ashtabula
46              Shawnee State University
Name: School Name, dtype: object

Top 5 least ROI schools: 
8              Oberlin College
1               Kenyon College
3           Denison University
18      The College of Wooster
6     Ohio Wesleyan University
Name: School Name, dtype: object

Obviously, my “break even” assessment is very simplistic. There are many other variables I don’t account for: room and board, fees, financial aid, merit scholarships, taxes, and the like. The median starting salaries are across all graduates from a given school–from Philosophy majors to Computer Science. So, your mileage will certainly vary. For me, the bigger take-aways were 1) the challenge of obtaining, cleaning, and merging the datasets, 2) charting out the results in a cool way, and 3) calculating the datapoints above and below my break-even line. All my work is here in case you want to check it out. Look for more matplotlib charts inspired by the Machine Learning Plus article in the future!

Watermarking Matplotlib charts

A few weeks ago, I read an interesting article about watermarking your ggplot charts in R. R is certainly a fantastic tool, but as my go-to language for visualizations these days is Python, I had to ask myself, “self, how would you watermark your matplotlib charts?” Well, one answer is the text method of the Figure object.

Consider this polar chart I wrote some time ago:

colleges = ['College A', 'College B', 'College C', 'College D', 'College E']
scores = [76, 54, 58, 63, 65]

theta = np.arange(len(colleges))/float(len(colleges)) * 2 * np.pi
fig = plt.figure(figsize=(8, 8))
ax = plt.subplot(111, projection='polar')
ax.plot(theta, scores, color='green', marker='o')
ax.plot([theta[0], theta[-1]], [scores[0], scores[-1]], 'g-')  # hack to complete the circle
ax.set_rmax(max(scores) + 5)
ax.set_rticks(np.arange(0, max(scores) + 5, step=10))
ax.set_xticks(theta)
labels = ax.set_xticklabels(colleges)

# hack to get the labels to show nicely
[l.set_ha('right') for l in labels if l.get_text() in ['College C', 'College D']]
[l.set_ha('left') for l in labels if l.get_text() in ['College A']]

for i, txt in enumerate(scores):
    ax.annotate(txt, (theta[i], scores[i]))

ax.grid(True)

ax.set_title('College Scorecard')
plt.tight_layout()

# watermarking my chart
fig.text(0.95, 0.06, 'DadOverflow.com',
         fontsize=12, color='gray',
         ha='right', va='bottom', alpha=0.5)

plt.show()

I’ve highlighted the part of the code that watermarks the chart. This code produces the following chart:

Hey, how about that cool watermark in the lower right-hand corner? Snazzy, right? One challenge I’ve found is that as you change the size of your chart, you’ll have to play around a little with the x and y coordinates of your watermark. Nevertheless, this seems to me like a great way to brand your charts.

« Older posts Newer posts »

© 2024 DadOverflow.com

Theme by Anders NorenUp ↑