Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 9656668

Browse files
author
Leanne Guy
committed
Address PR comments
1 parent 2c4363d commit 9656668

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

08b_Interactive_Catalog_Visualization.ipynb

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
" 2. [**Bokeh**](https://bokeh.org): A powerful data visualization library that provides interactive tools including brushing and linking between multiple plots. `Holoviews` + `Bokeh`\n",
3434
" 3. [**Datashader**](https://datashader.org): Accurately render very large datasets quickly and flexibly.\n",
3535
" \n",
36-
"These packages are part of the [PyViz](http://pyviz.org/) ecosystem of tools intended for visualization in a web browser and can be used to create quite sophisticated dashboard-like interactive displays and widgets. The goal of this tutorial is to provide an introduction and starting point from which to create more advanced, custom interactive visualizations. "
36+
"These packages are part of the [Holoviz](http://holoviz.org/) ecosystem of tools intended for visualization in a web browser and can be used to create quite sophisticated dashboard-like interactive displays and widgets. The goal of this tutorial is to provide an introduction and starting point from which to create more advanced, custom interactive visualizations. Holoviz has a [vibrant and active community](https://discourse.holoviz.org/) where you can ask questions and discuss vizualizations with a global community. "
3737
]
3838
},
3939
{
@@ -220,16 +220,7 @@
220220
"%%time\n",
221221
"# Execute the query and convert the results to a pandas dataframe\n",
222222
"data = service.search(query).to_table().to_pandas() \n",
223-
"# assert len(data) == 14589 # 10284 # 102096"
224-
]
225-
},
226-
{
227-
"cell_type": "code",
228-
"execution_count": null,
229-
"metadata": {},
230-
"outputs": [],
231-
"source": [
232-
"len(data)"
223+
"assert len(data) == 14849 "
233224
]
234225
},
235226
{
@@ -794,23 +785,24 @@
794785
"source": [
795786
"# Create color-color plot using bokeh\n",
796787
"plot_options = {'plot_height': 400, 'plot_width': 800,\n",
797-
" 'tools': ['hover', 'box_select', 'reset', 'help']}\n",
798-
"\n",
799-
"hover = HoverTool(tooltips=[(\"objectId\", \"@objectId\"),\n",
800-
" (\"(RA,DEC)\", \"(@ra, @dec)\"),\n",
801-
" (\"(g-r,r-i)\", \"(@gmr, @rmi)\"),\n",
802-
" (\"type\", \"@truth_type\")])\n",
788+
" 'tools': ['box_select', 'reset', 'help']}\n",
803789
"\n",
804790
"p = figure(title=\"Colour-Colour Diagram (cModel magnitudes)\",\n",
805791
" x_axis_label=\"g-r\", y_axis_label=\"r-i\",\n",
806792
" x_range=(-2.0, 3.0), y_range=(-2.0, 3.0),\n",
807793
" **plot_options)\n",
808794
"p.circle(x='gmr', y='rmi', source=source,\n",
809-
" size=1, alpha=0.1,\n",
795+
" size=2, alpha=0.2,\n",
810796
" hover_color='firebrick',\n",
811797
" legend_field=\"truth_type\",\n",
812798
" color=factor_cmap('truth_type', 'Category10_3',\n",
813799
" ['galaxy', 'star', 'SNe']))\n",
800+
"\n",
801+
"# Add a custiomized hover tool\n",
802+
"hover = HoverTool(tooltips=[(\"objectId\", \"@objectId\"),\n",
803+
" (\"(RA,DEC)\", \"(@ra, @dec)\"),\n",
804+
" (\"(g-r,r-i)\", \"(@gmr, @rmi)\"),\n",
805+
" (\"type\", \"@truth_type\")])\n",
814806
"p.add_tools(hover)"
815807
]
816808
},
@@ -827,7 +819,7 @@
827819
"cell_type": "markdown",
828820
"metadata": {},
829821
"source": [
830-
"We see that even with a medium sized dataset of ~100K points, this plot suffers from overplotting. A classic strategy is to specify transparency of the glyphs so we can better see sparse and dense areas. In the plot above we have `alpha=0.3`. This helps, but washes out the detail in the sparser regions. An additional problem is that we cannot add too many glyphs to any plot. \n",
822+
"We see that even with a medium sized dataset of ~10K points, this plot suffers from overplotting. A classic strategy is to specify transparency of the glyphs so we can better see sparse and dense areas. In the plot above we have `alpha=0.2`. This helps, but washes out the detail in the sparser regions. An additional problem is that we cannot add too many glyphs to any plot. \n",
831823
"\n",
832824
"Holoviews + Datashader allow us to plot millions to billions of points to produce much more informative plots. DataShader rasterizes or aggregates datasets into regular grids that can then be further analysed or viewed as plots or images. "
833825
]
@@ -849,20 +841,29 @@
849841
"box = streams.BoundsXY(source=points, bounds=boundsxy)\n",
850842
"bounds = hv.DynamicMap(lambda bounds: hv.Bounds(bounds), streams=[box])\n",
851843
"\n",
852-
"\n",
853844
"# Apply the datashader\n",
854-
"dynspread(datashade(points, cmap=\"Viridis\").opts(\n",
855-
" width=800, height=300, tools=['hover'],\n",
845+
"p = dynspread(datashade(points, cmap=\"Viridis\"))\n",
846+
"p = p.opts(width=800, height=300, tools=['hover'],\n",
856847
" padding=0.05, show_grid=True,\n",
857848
" xlim=(-2.0, 3.0), ylim=(-2.0, 3.0),\n",
858-
" xlabel=\"g-r\", ylabel=\"r-i\")) * bounds"
849+
" xlabel=\"g-r\", ylabel=\"r-i\")"
850+
]
851+
},
852+
{
853+
"cell_type": "code",
854+
"execution_count": null,
855+
"metadata": {},
856+
"outputs": [],
857+
"source": [
858+
"# Render the datashaded plot\n",
859+
"p * bounds"
859860
]
860861
},
861862
{
862863
"cell_type": "markdown",
863864
"metadata": {},
864865
"source": [
865-
"This `datashade` plot of the same color-color diagram as above shows much more detail. Select the `wheel zoom` and adjust the image as you interact with the plot. Note how the shades of color of the data points change according to the local density."
866+
"This `datashade` plot of the same color-color diagram as above does not require any magic-number parameters such as size and alpha and automatically ensures that there is no saturation or overplotting. Select the `wheel zoom` and adjust the image as you interact with the plot. Note how the shades of color of the data points change according to the local density."
866867
]
867868
},
868869
{

0 commit comments

Comments
 (0)