Published
Edited
Nov 15, 2020
1 fork
Insert cell
md`# Additional Graphs for Final Project`
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
import {uniqueValid} from '@uwdata/data-utilities'
Insert cell
df_s2 = FileAttachment("df_s2@3.csv").csv()
Insert cell
races = uniqueValid(df_s2, d => d.RACETHMP)
Insert cell
races.unshift(races.pop())
Insert cell
races
Insert cell
vl.markBar()
.data(df_s2)
.encode(
vl.x().fieldN('GENDER').count(),
vl.y().fieldN('AGEGRP'),
vl.color().fieldN('RACETHMP').legend(null),
vl.order().fieldN('RACETHMP').count().sort("descending"),
vl.tooltip().fieldN('RACETHMP'),
vl.column().fieldN('GENDER').title("PhD Recipients by Gender, Age and Race")
)
.render()
Insert cell
vl.markBar()
.data(df_s2)
.encode(
vl.x().fieldN('RACETHMP').count().title(null),
vl.y().fieldN('AGEGRP'),
vl.color().fieldN('RACETHMP').legend(null),
vl.tooltip().fieldN('RACETHMP'),
vl.column().fieldN('RACETHMP').sort("descending").title("PhD Recipients by Race")
)
.width(150)
.render()
Insert cell
//d_workalot = df_s2.filter(d => d.WKSYR === "Work 52 weeks per year " & d.HRSWKP === "Greater than 40 ")
Insert cell
d_workalot = FileAttachment("workalot_percent@1.csv").csv()
Insert cell
vl.markBar()
.data(d_workalot)
.encode(
vl.y().fieldQ('HRSWKP').title('Percentage of working individuals of category'),
vl.x().fieldN('GENDER').title(null),
vl.color().fieldN('GENDER').legend(null),
vl.tooltip().fieldQ('HRSWKP'),
vl.column().fieldN('AGEGRP').title("PhD Recipients working 52 weeks and >40 hrs/week")
)
.width(60)
.render()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more