Skip to content

Instantly share code, notes, and snippets.

@blmoore
Last active August 29, 2015 14:06
Show Gist options
  • Save blmoore/5bd422f7fe8258be5305 to your computer and use it in GitHub Desktop.
Save blmoore/5bd422f7fe8258be5305 to your computer and use it in GitHub Desktop.
The top 50 science stars of Twitter
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://dimplejs.org/dist/dimple.v1.1.1.min.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 520px;
height: 480px;
}
</style>
</head>
<body>
<div id='chart1fa314f8532' class='rChart dimple'></div>
<script type="text/javascript">
var opts = {
"dom": "chart1fa314f8532",
"width": 520,
"height": 480,
"x": "Citations",
"y": "Followers",
"type": "bubble",
"groups": "Name",
"id": "chart1fa314f8532"
},
data = [
{
"Name": "Neil deGrasse Tyson",
"Occupation": "Astrophysicist",
"Handle": "@neiltyson",
"Followers": 2400000,
"Citations": 151,
"K.Index": 11129,
"Tweets": 3962,
"Institute": "Hayden Planetarium",
"Country": "United States"
},
{
"Name": "Brian Cox",
"Occupation": "Physicist",
"Handle": "@ProfBrianCox",
"Followers": 1440000,
"Citations": 33301,
"K.Index": 1188,
"Tweets": 10300,
"Institute": "University of Manchester",
"Country": "United Kingdom"
},
{
"Name": "Richard Dawkins",
"Occupation": "Biologist",
"Handle": "@RichardDawkins",
"Followers": 1020000,
"Citations": 49631,
"K.Index": 740,
"Tweets": 19000,
"Institute": "University of Oxford",
"Country": "United Kingdom"
},
{
"Name": "Ben Goldacre",
"Occupation": "Physician",
"Handle": "@bengoldacre",
"Followers": 341000,
"Citations": 1086,
"K.Index": 841,
"Tweets": 47300,
"Institute": "London School of Hygiene & Tropical Medicine",
"Country": "United Kingdom"
},
{
"Name": "Phil Plait",
"Occupation": "Astronomer",
"Handle": "@BadAstronomer",
"Followers": 320000,
"Citations": 254,
"K.Index": 1256,
"Tweets": 47000,
"Institute": "Bad Astronomy",
"Country": "United States"
},
{
"Name": "Michio Kaku",
"Occupation": "Theoretical physicist",
"Handle": "@michiokaku",
"Followers": 310000,
"Citations": 5281,
"K.Index": 461,
"Tweets": 1130,
"Institute": "The City College of New York",
"Country": "United States"
},
{
"Name": "Sam Harris",
"Occupation": "Neuroscientist",
"Handle": "@SamHarrisOrg",
"Followers": 224000,
"Citations": 2416,
"K.Index": 428,
"Tweets": 2600,
"Institute": "Project Reason",
"Country": "United States"
},
{
"Name": "Hans Rosling",
"Occupation": "Global health scientist",
"Handle": "@HansRosling",
"Followers": 180000,
"Citations": 1703,
"K.Index": 384,
"Tweets": 2708,
"Institute": "Karolinska Institute",
"Country": "Sweden"
},
{
"Name": "Tim Berners-Lee",
"Occupation": "Computer scientist",
"Handle": "@timberners_lee",
"Followers": 179000,
"Citations": 51204,
"K.Index": 129,
"Tweets": 542,
"Institute": "Massachusetts Institute of Technology",
"Country": "United States"
},
{
"Name": "P.Z. Myers",
"Occupation": "Biologist",
"Handle": "@pzmyers",
"Followers": 155000,
"Citations": 1364,
"K.Index": 355,
"Tweets": 25400,
"Institute": "University of Minnesota, Morris",
"Country": "United States"
},
{
"Name": "Steven Pinker",
"Occupation": "Cognitive scientist",
"Handle": "@sapinker",
"Followers": 142000,
"Citations": 49933,
"K.Index": 103,
"Tweets": 1612,
"Institute": "Harvard University",
"Country": "United States"
},
{
"Name": "Richard Wiseman",
"Occupation": "Psychologist",
"Handle": "@RichardWiseman",
"Followers": 134000,
"Citations": 4687,
"K.Index": 207,
"Tweets": 22400,
"Institute": "University of Hertfordshire",
"Country": "United Kingdom"
},
{
"Name": "Lawrence M. Krauss",
"Occupation": "Theoretical physicist",
"Handle": "@LKrauss1",
"Followers": 99700,
"Citations": 10155,
"K.Index": 120,
"Tweets": 1548,
"Institute": "Arizona State University",
"Country": "United States"
},
{
"Name": "Atul Gawande",
"Occupation": "Surgeon/public health scientist",
"Handle": "@Atul_Gawande",
"Followers": 96800,
"Citations": 13763,
"K.Index": 106,
"Tweets": 2118,
"Institute": "Harvard University",
"Country": "United States"
},
{
"Name": "Oliver Sacks",
"Occupation": "Neurologist",
"Handle": "@OliverSacks",
"Followers": 76300,
"Citations": 13883,
"K.Index": 83,
"Tweets": 746,
"Institute": "New York University",
"Country": "United States"
},
{
"Name": "Dan Ariely",
"Occupation": "Psychologist/behavioral economist",
"Handle": "@danariely",
"Followers": 73000,
"Citations": 16307,
"K.Index": 76,
"Tweets": 1091,
"Institute": "Massachusetts Institute of Technology",
"Country": "United States"
},
{
"Name": "Eric Topol",
"Occupation": "Geneticist",
"Handle": "@EricTopol",
"Followers": 44800,
"Citations": 151281,
"K.Index": 23,
"Tweets": 4966,
"Institute": "The Scripps Research Institute",
"Country": "United States"
},
{
"Name": "Brian Greene",
"Occupation": "Theoretical physicist",
"Handle": "@bgreene",
"Followers": 38700,
"Citations": 11133,
"K.Index": 45,
"Tweets": 191,
"Institute": "Columbia University",
"Country": "United States"
},
{
"Name": "Marcus du Sautoy",
"Occupation": "Mathematician",
"Handle": "@MarcusduSautoy",
"Followers": 34200,
"Citations": 1461,
"K.Index": 77,
"Tweets": 3555,
"Institute": "University of Oxford",
"Country": "United Kingdom"
},
{
"Name": "Sean Carroll",
"Occupation": "Theoretical physicist",
"Handle": "@seanmcarroll",
"Followers": 33200,
"Citations": 14208,
"K.Index": 36,
"Tweets": 7295,
"Institute": "California Institute of Technology",
"Country": "United States"
},
{
"Name": "Robert Winston",
"Occupation": "Fertility scientist",
"Handle": "@ProfRWinston",
"Followers": 31900,
"Citations": 7324,
"K.Index": 43,
"Tweets": 445,
"Institute": "Imperial College London",
"Country": "United Kingdom"
},
{
"Name": "Bruce Betts",
"Occupation": "Planetary scientist",
"Handle": "@RandomSpaceFact",
"Followers": 28500,
"Citations": 91,
"K.Index": 155,
"Tweets": 1619,
"Institute": "The Planetary Society",
"Country": "United States"
},
{
"Name": "Carolyn Porco",
"Occupation": "Planetary scientist",
"Handle": "@carolynporco",
"Followers": 26100,
"Citations": 2717,
"K.Index": 48,
"Tweets": 12700,
"Institute": "Space Science Institute",
"Country": "United States"
},
{
"Name": "Sebastian Thrun",
"Occupation": "Computer scientist",
"Handle": "@SebastianThrun",
"Followers": 25200,
"Citations": 57110,
"K.Index": 17,
"Tweets": 185,
"Institute": "Stanford University",
"Country": "United States"
},
{
"Name": "Jonathan Eisen",
"Occupation": "Biologist",
"Handle": "@phylogenomics",
"Followers": 24900,
"Citations": 41289,
"K.Index": 19,
"Tweets": 46100,
"Institute": "University of California, Davis",
"Country": "United States"
},
{
"Name": "Vaughan Bell",
"Occupation": "Neuroscientist",
"Handle": "@vaughanbell",
"Followers": 23500,
"Citations": 821,
"K.Index": 63,
"Tweets": 10900,
"Institute": "King's College London",
"Country": "United Kingdom"
},
{
"Name": "J. Craig Venter",
"Occupation": "Genomicist",
"Handle": "@JCVenter",
"Followers": 23500,
"Citations": 75338,
"K.Index": 15,
"Tweets": 365,
"Institute": "J. Craig Venter Institute",
"Country": "United States"
},
{
"Name": "Robert Simpson",
"Occupation": "Astronomer",
"Handle": "@orbitingfrog",
"Followers": 21500,
"Citations": 2280,
"K.Index": 42,
"Tweets": 11500,
"Institute": "University of Oxford",
"Country": "United Kingdom"
},
{
"Name": "Michael E. Mann",
"Occupation": "Meteorologist",
"Handle": "@MichaelEMann",
"Followers": 20900,
"Citations": 15049,
"K.Index": 22,
"Tweets": 20000,
"Institute": "Pennsylvania State University",
"Country": "United States"
},
{
"Name": "Jerry Coyne",
"Occupation": "Biologist",
"Handle": "@Evolutionistrue",
"Followers": 19500,
"Citations": 16657,
"K.Index": 20,
"Tweets": 7711,
"Institute": "University of Chicago",
"Country": "United States"
},
{
"Name": "Gary King",
"Occupation": "Statistician",
"Handle": "@kinggary",
"Followers": 19400,
"Citations": 36311,
"K.Index": 16,
"Tweets": 3080,
"Institute": "Harvard University",
"Country": "United States"
},
{
"Name": "Mike Brown",
"Occupation": "Astronomer",
"Handle": "@plutokiller",
"Followers": 18300,
"Citations": 7870,
"K.Index": 24,
"Tweets": 9764,
"Institute": "California Institute of Technology",
"Country": "United States"
},
{
"Name": "Pamela L. Gay",
"Occupation": "Astronomer",
"Handle": "@starstryder",
"Followers": 17800,
"Citations": 238,
"K.Index": 71,
"Tweets": 12700,
"Institute": "Southern Illinois University, Edwardsville",
"Country": "United States"
},
{
"Name": "Jean Francois Gariepy",
"Occupation": "Neuroscientist",
"Handle": "@JFGariepy",
"Followers": 17700,
"Citations": 153,
"K.Index": 82,
"Tweets": 3231,
"Institute": "Duke University",
"Country": "United States"
},
{
"Name": "Bob Metcalfe",
"Occupation": "Computer scientist",
"Handle": "@BobMetcalfe",
"Followers": 16400,
"Citations": 424,
"K.Index": 55,
"Tweets": 16100,
"Institute": "University of Texas, Austin",
"Country": "United States"
},
{
"Name": "Daniel Gilbert",
"Occupation": "Psychologist/behavioral economist",
"Handle": "@DanTGilbert",
"Followers": 15500,
"Citations": 26752,
"K.Index": 14,
"Tweets": 1294,
"Institute": "Harvard University",
"Country": "United States"
},
{
"Name": "Daniel Levitin",
"Occupation": "Neuroscientist",
"Handle": "@danlevitin",
"Followers": 15400,
"Citations": 5688,
"K.Index": 22,
"Tweets": 3036,
"Institute": "McGill University",
"Country": "Canada"
},
{
"Name": "Andrew Maynard",
"Occupation": "Environmental health scientist",
"Handle": "@2020science",
"Followers": 15300,
"Citations": 10411,
"K.Index": 18,
"Tweets": 16200,
"Institute": "University of Michigan Risk Science Center",
"Country": "United States"
},
{
"Name": "Paul Bloom",
"Occupation": "Psychologist",
"Handle": "@paulbloomatyale",
"Followers": 15100,
"Citations": 14135,
"K.Index": 16,
"Tweets": 1973,
"Institute": "Yale University",
"Country": "United States"
},
{
"Name": "Seth Shostak",
"Occupation": "Astronomer",
"Handle": "@SethShostak",
"Followers": 14500,
"Citations": 424,
"K.Index": 48,
"Tweets": 294,
"Institute": "SETI Institute",
"Country": "United States"
},
{
"Name": "Matt Lieberman",
"Occupation": "Neuroscientist",
"Handle": "@social_brains",
"Followers": 14500,
"Citations": 12763,
"K.Index": 16,
"Tweets": 3088,
"Institute": "University of California, Los Angeles",
"Country": "United States"
},
{
"Name": "Daniel MacArthur",
"Occupation": "Genomicist",
"Handle": "@dgmacarthur",
"Followers": 14100,
"Citations": 6884,
"K.Index": 19,
"Tweets": 15600,
"Institute": "Harvard Medical School",
"Country": "United States"
},
{
"Name": "John Allen Paulos",
"Occupation": "Mathematician",
"Handle": "@JohnAllenPaulos",
"Followers": 14000,
"Citations": 1489,
"K.Index": 31,
"Tweets": 4144,
"Institute": "Temple University",
"Country": "United States"
},
{
"Name": "Ves Dimov",
"Occupation": "Immunologist",
"Handle": "@DrVes",
"Followers": 13900,
"Citations": 211,
"K.Index": 58,
"Tweets": 32200,
"Institute": "University of Chicago",
"Country": "United States"
},
{
"Name": "Simon Baron-Cohen",
"Occupation": "Psychopathologist",
"Handle": "@sbaroncohen",
"Followers": 13600,
"Citations": 84132,
"K.Index": 8,
"Tweets": 119,
"Institute": "University of Cambridge",
"Country": "United Kingdom"
},
{
"Name": "Amy Mainzer",
"Occupation": "Astronomer",
"Handle": "@AmyMainzer",
"Followers": 13600,
"Citations": 1444,
"K.Index": 31,
"Tweets": 2221,
"Institute": "Jet Propulsion Laboratory",
"Country": "United States"
},
{
"Name": "Brian Krueger",
"Occupation": "Genomicist",
"Handle": "@LabSpaces",
"Followers": 12500,
"Citations": 154,
"K.Index": 58,
"Tweets": 36700,
"Institute": "Duke University",
"Country": "United States"
},
{
"Name": "Karen James",
"Occupation": "Biologist",
"Handle": "@kejames",
"Followers": 12200,
"Citations": 1007,
"K.Index": 31,
"Tweets": 61800,
"Institute": "Mount Desert Island Biological Laboratory",
"Country": "United States"
},
{
"Name": "Michael Eisen",
"Occupation": "Biologist",
"Handle": "@mbeisen",
"Followers": 11800,
"Citations": 68785,
"K.Index": 8,
"Tweets": 16300,
"Institute": "University of California, Berkeley",
"Country": "United States"
},
{
"Name": "Micah Allen",
"Occupation": "Neuroscientist",
"Handle": "@neuroconscience",
"Followers": 11600,
"Citations": 81,
"K.Index": 66,
"Tweets": 21900,
"Institute": "University College London",
"Country": "United Kingdom"
}
],
xAxis = {
"type": "addLogAxis",
"showPercent": false,
"overrideMin": 10
},
yAxis = {
"type": "addLogAxis",
"showPercent": false,
"overrideMin": 10000
},
zAxis = [],
colorAxis = [],
legend = [];
var svg = dimple.newSvg("#" + opts.id, opts.width, opts.height);
//data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
var myChart = new dimple.chart(svg, data);
if (opts.bounds) {
myChart.setBounds(opts.bounds.x, opts.bounds.y, opts.bounds.width, opts.bounds.height);//myChart.setBounds(80, 30, 480, 330);
}
//dimple allows use of custom CSS with noFormats
if(opts.noFormats) { myChart.noFormats = opts.noFormats; };
//for markimekko and addAxis also have third parameter measure
//so need to evaluate if measure provided
//x axis
var x;
if(xAxis.measure) {
x = myChart[xAxis.type]("x",opts.x,xAxis.measure);
} else {
x = myChart[xAxis.type]("x", opts.x);
};
if(!(xAxis.type === "addPctAxis")) x.showPercent = xAxis.showPercent;
if (xAxis.orderRule) x.addOrderRule(xAxis.orderRule);
if (xAxis.grouporderRule) x.addGroupOrderRule(xAxis.grouporderRule);
if (xAxis.overrideMin) x.overrideMin = xAxis.overrideMin;
if (xAxis.overrideMax) x.overrideMax = xAxis.overrideMax;
if (xAxis.overrideMax) x.overrideMax = xAxis.overrideMax;
if (xAxis.inputFormat) x.dateParseFormat = xAxis.inputFormat;
if (xAxis.outputFormat) x.tickFormat = xAxis.outputFormat;
//y axis
var y;
if(yAxis.measure) {
y = myChart[yAxis.type]("y",opts.y,yAxis.measure);
} else {
y = myChart[yAxis.type]("y", opts.y);
};
if(!(yAxis.type === "addPctAxis")) y.showPercent = yAxis.showPercent;
if (yAxis.orderRule) y.addOrderRule(yAxis.orderRule);
if (yAxis.grouporderRule) y.addGroupOrderRule(yAxis.grouporderRule);
if (yAxis.overrideMin) y.overrideMin = yAxis.overrideMin;
if (yAxis.overrideMax) y.overrideMax = yAxis.overrideMax;
if (yAxis.inputFormat) y.dateParseFormat = yAxis.inputFormat;
if (yAxis.outputFormat) y.tickFormat = yAxis.outputFormat;
//z for bubbles
var z;
if (!(typeof(zAxis) === 'undefined') && zAxis.type){
if(zAxis.measure) {
z = myChart[zAxis.type]("z",opts.z,zAxis.measure);
} else {
z = myChart[zAxis.type]("z", opts.z);
};
if(!(zAxis.type === "addPctAxis")) z.showPercent = zAxis.showPercent;
if (zAxis.orderRule) z.addOrderRule(zAxis.orderRule);
if (zAxis.overrideMin) z.overrideMin = zAxis.overrideMin;
if (zAxis.overrideMax) z.overrideMax = zAxis.overrideMax;
}
if(d3.keys(colorAxis).length > 0) {
myChart[colorAxis.type](colorAxis.colorSeries,colorAxis.palette) ;
}
//here need think I need to evaluate group and if missing do null
//as the first argument
//if provided need to use groups from opts
if(opts.hasOwnProperty("groups")) {
var s = myChart.addSeries( opts.groups, dimple.plot[opts.type] );
//series offers an aggregate method that we will also need to check if available
//options available are avg, count, max, min, sum
if (!(typeof(opts.aggregate) === 'undefined')) {
s.aggregate = eval(opts.aggregate);
}
if (!(typeof(opts.lineWeight) === 'undefined')) {
s.lineWeight = eval(opts.lineWeight);
}
if (!(typeof(opts.barGap) === 'undefined')) {
s.barGap = eval(opts.barGap);
}
} else var s = myChart.addSeries( null, dimple.plot[opts.type] );
//unsure if this is best but if legend is provided (not empty) then evaluate
if(d3.keys(legend).length > 0) {
var l =myChart.addLegend();
d3.keys(legend).forEach(function(d){
l[d] = legend[d];
});
}
//quick way to get this going but need to make this cleaner
if(opts.storyboard) {
myChart.setStoryboard(opts.storyboard);
};
myChart.draw();
</script>
<p>
Data from Mick Watson's <a href="http://biomickwatson.wordpress.com/2014/09/17/data-from-the-top-50-science-stars-of-twitter/">blog post</a>. Code to reproduce below:
</p>
<pre>
d <- read.csv2("http://www.ark-genomics.org/tmp/Twitter50.txt", sep="\t")
library("rCharts")
i <- dPlot(Followers ~ Citations, data=d, type="bubble",
groups="Name", height=480, width=520)
i$yAxis(type = "addLogAxis", overrideMin=1e4)
i$xAxis(type = "addLogAxis", overrideMin=10)
i
</pre>
<p style="text-align: right;">
— <a href="https://twitter.com/benjaminlmoore">@benjaminlmoore</a>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment