Skip to content

Commit

Permalink
adjust graph appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
mtakeno committed Feb 12, 2020
1 parent 8285b11 commit 8cc1300
Showing 1 changed file with 44 additions and 65 deletions.
109 changes: 44 additions & 65 deletions graph_volume_em_pubs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,64 @@
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"974cf26a-8a2c-4593-ba64-9e25f5076b18\" data-root-id=\"1530\"></div>\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"9781faea-af30-4945-a269-fd34655d062e\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1539\",\"type\":\"LinearAxis\"}],\"center\":[{\"id\":\"1543\",\"type\":\"Grid\"},{\"id\":\"1548\",\"type\":\"Grid\"}],\"left\":[{\"id\":\"1544\",\"type\":\"LogAxis\"}],\"plot_width\":800,\"renderers\":[{\"id\":\"1565\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1603\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1555\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1531\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1535\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1533\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1537\",\"type\":\"LogScale\"}},\"id\":\"1530\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"axis_label\":\"Volume Sectioned (um^3)\",\"formatter\":{\"id\":\"1606\",\"type\":\"LogTickFormatter\"},\"ticker\":{\"id\":\"1545\",\"type\":\"LogTicker\"}},\"id\":\"1544\",\"type\":\"LogAxis\"},{\"attributes\":{},\"id\":\"1610\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"dimension\":1,\"ticker\":{\"id\":\"1545\",\"type\":\"LogTicker\"}},\"id\":\"1548\",\"type\":\"Grid\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"publication_year\"},\"y\":{\"field\":\"calculated_volume\"}},\"id\":\"1563\",\"type\":\"Scatter\"},{\"attributes\":{\"num_minor_ticks\":10},\"id\":\"1545\",\"type\":\"LogTicker\"},{\"attributes\":{},\"id\":\"1611\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1535\",\"type\":\"LinearScale\"},{\"attributes\":{\"ticker\":null},\"id\":\"1606\",\"type\":\"LogTickFormatter\"},{\"attributes\":{\"ticker\":{\"id\":\"1540\",\"type\":\"BasicTicker\"}},\"id\":\"1543\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"data\":{\"calculated_volume\":{\"__ndarray__\":\"AAAAINIqf0EAAAAAYOMWQQAAAACJbpdBAAAAAIBPMkEAAAAAAMDCQAAAAAAIsiJBAAAAACCR4kAAAAAgD92BQQAAAAAo5j5BAAAAAADAgkAzMzMzMxPIQKRwPQrXc81ArBxaZB/V+EAAAACwn0SBQQAAAAAAiENBAAAAYNGtkUGamZmZmYfzQAAAAADEuT1BAAAAEKsLiEEAAAAAkA42QQAAAACAXjJBAAAAAFgIWEF9PzVelltCQRSuR+F69CFBAAAAgIJojEF9PzXeny4sQQAAAAAAPkdBAAAAAGXNbUEAAAAAQG41QQAAAFw9NbNBAAAAAMZuhkEAAAAA3EsxQQ==\",\"dtype\":\"float64\",\"shape\":[32]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],\"publication_year\":[2011,2013,1972,1991,1987,2007,2013,2016,2016,1974,1998,2008,2013,1985,1986,2018,2015,2015,2017,2018,2013,2011,2009,2019,2020,2016,2020,2020,2017,2017,2016,2018]},\"selected\":{\"id\":\"1611\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1610\",\"type\":\"UnionRenderers\"}},\"id\":\"1529\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1549\",\"type\":\"PanTool\"},{\"attributes\":{\"axis_label\":\"Publication Year\",\"formatter\":{\"id\":\"1608\",\"type\":\"BasicTickFormatter\"},\"ticker\":{\"id\":\"1540\",\"type\":\"BasicTicker\"}},\"id\":\"1539\",\"type\":\"LinearAxis\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1549\",\"type\":\"PanTool\"},{\"id\":\"1550\",\"type\":\"WheelZoomTool\"},{\"id\":\"1551\",\"type\":\"BoxZoomTool\"},{\"id\":\"1552\",\"type\":\"SaveTool\"},{\"id\":\"1553\",\"type\":\"ResetTool\"},{\"id\":\"1554\",\"type\":\"HelpTool\"}]},\"id\":\"1555\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1540\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"1529\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1563\",\"type\":\"Scatter\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1564\",\"type\":\"Scatter\"},\"selection_glyph\":null,\"view\":{\"id\":\"1566\",\"type\":\"CDSView\"}},\"id\":\"1565\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1537\",\"type\":\"LogScale\"},{\"attributes\":{\"overlay\":{\"id\":\"1609\",\"type\":\"BoxAnnotation\"}},\"id\":\"1551\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"callback\":null},\"id\":\"1533\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1552\",\"type\":\"SaveTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"publication_year\"},\"y\":{\"field\":\"calculated_volume\"}},\"id\":\"1564\",\"type\":\"Scatter\"},{\"attributes\":{},\"id\":\"1554\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1553\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1550\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"1529\",\"type\":\"ColumnDataSource\"}},\"id\":\"1566\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1603\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null},\"id\":\"1531\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1608\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1609\",\"type\":\"BoxAnnotation\"}],\"root_ids\":[\"1530\"]},\"title\":\"Bokeh Application\",\"version\":\"1.4.0\"}};\n",
" var render_items = [{\"docid\":\"9781faea-af30-4945-a269-fd34655d062e\",\"roots\":{\"1530\":\"974cf26a-8a2c-4593-ba64-9e25f5076b18\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "1530"
}
},
"output_type": "display_data"
}
],
"execution_count": 13,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from bokeh.io import output_notebook, show\n",
"from bokeh.plotting import figure\n",
"from bokeh.models import ColumnDataSource\n",
"from bokeh.models import ColumnDataSource, LabelSet\n",
"\n",
"df = pd.read_csv('data/volume_em_data.csv',\n",
" skiprows=[1], # skip row with unit designator\n",
" dtype={\"number_sections\": int},\n",
" usecols={'calculated_volume', 'publication_year'}\n",
" usecols={'calculated_volume', 'publication_year', 'reference_number'},\n",
" dtype={\"number_sections\": int, \"publication_year\": int}\n",
" )\n",
"df.head()\n",
"# df.head()\n",
"source = ColumnDataSource(df)\n",
"\n",
"p = figure(plot_width=800, plot_height=600, y_axis_type=\"log\")\n",
"p = figure(plot_width=800, plot_height=400, y_axis_type=\"log\", title=\"Large Volume EM Datasets\",\n",
" tools = \"pan,wheel_zoom,box_zoom,hover,reset\")\n",
"\n",
"p.scatter(x=\"publication_year\", y=\"calculated_volume\", source=source)\n",
"\n",
"p.xaxis.axis_label = 'Publication Year'\n",
"p.yaxis.axis_label = 'Volume Sectioned (um^3)'\n",
"p.scatter(\"publication_year\", \"calculated_volume\", source=source)\n",
"p.yaxis.axis_label = 'Calculated Volume (um^3)'\n",
"\n",
"labels = LabelSet(x=\"publication_year\", y=\"calculated_volume\", text='reference_number',\n",
" x_offset=3, y_offset=3, source=source, render_mode='canvas')\n",
"# p.add_layout(labels)\n",
"# p.add_tools(HoverTool())\n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 32 entries, 0 to 31\n",
"Data columns (total 3 columns):\n",
"calculated_volume 32 non-null float64\n",
"reference_number 32 non-null int64\n",
"publication_year 32 non-null int32\n",
"dtypes: float64(1), int32(1), int64(1)\n",
"memory usage: 768.0 bytes\n"
]
}
],
"source": [
"df.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 8cc1300

Please sign in to comment.