-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for dim transforms to set style options #2152
Merged
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
c6ac9a2
Added ops
philippjfr bc6c1d3
Implement NumPy support for ops
philippjfr 1a909df
Support scalar ops in plotting
philippjfr c503afb
Various improvements for ops
philippjfr dc27124
Improved handling for op style mappings
philippjfr 073cbf4
Enabled op style mapping on Composite glyphs
philippjfr 1f09d59
Handle scalar values in ops mapping
philippjfr ddd5a65
Fixed handling of multi-interface in ops
philippjfr a076722
Enabled ops mapping for mpl Labels
philippjfr b2ec022
Improved of unsupported matplotlib ops mapping
philippjfr 93d1cbd
Add unit tests for bokeh PointPlot ops
philippjfr a8d515a
Fixes and improvements for Point mappings
philippjfr 5100e5e
Fixed flakes and tests
philippjfr 09d6ab8
Fixed op colormapping in matplotlib
philippjfr bc2e1cd
Added unit tests for matplotlib PointPlot op mapping
philippjfr b8fdc0b
Created new module for bokeh styles and utilities
philippjfr b5c0191
Improved validation of op mappings
philippjfr 8f6defa
Improved ops validation and added tests
philippjfr df80c26
Fixes for op ranges
philippjfr a8276a6
Add style mapping tests for SpikePlot
philippjfr f96674f
Various smaller fixes
philippjfr d19ca7f
Updated Styling_Plots user guide
philippjfr 5db683a
Updated Geometry Data notebook
philippjfr 5459a16
Added bin and cat op functions
philippjfr 2e9c216
Fixed op range resolution
philippjfr 24873f6
Fixes for CompositeElementPlot
philippjfr 3484fa7
Disabled style mapping for Rasters
philippjfr f287c5f
Enabled style mapping for stats plots
philippjfr 4b6cc37
Improved op transforms to allow construction from tuple
philippjfr 92927ea
Finished cleaning up bokeh Scatter/Point plots, tests, docs
philippjfr 637b8e1
Finished cleaning up bokeh Histogram plot, tests, doc
philippjfr a705574
Overhauled bokeh BarPlot code, tests, docs
philippjfr 2c4709d
Finished off mpl PointPlot code, tests, docs
philippjfr 15b769b
Finalized handling of SpikesPlot across backends
philippjfr dc3c5fd
Finalized style mapping for Spikes and Labels
philippjfr 67d518a
Finalized style mapping support for VectorField
philippjfr 4f73fbd
Finalized style mapping for ErrorBars
philippjfr b369251
Finalized CurvePlot and AreaPlot style mapping
philippjfr 0f8a818
Various updates to examples
philippjfr 8160286
Resolve tuple op specs
philippjfr 98218c8
Fix for CompositeElementPlot
philippjfr 4a6fa7a
Fixed bug in DataLinkCallback
philippjfr 1d71f79
Fixed BoxWhiskerPlot bug
philippjfr 232ac40
Added common function to ops
philippjfr 87411d9
Various updates for Graph and stats elements
philippjfr 2edbd80
Renamed op to dim
philippjfr 0b15b45
Fixed import
philippjfr cae455d
Fixed flakes
philippjfr b840e21
BarPlot fixes
philippjfr dfc62ae
Fixed bokeh tests
philippjfr 15230d1
Fixes for matplotlib tests
philippjfr d68c094
Fixed flake
philippjfr a436a8b
Made plotting imports consistent
philippjfr a514bb3
Fixed py2 handling of LooseVersion
philippjfr f00860c
Fixed LooseVersion
philippjfr b95c018
Added unit tests for updating matplotlib chart styles
philippjfr 2cda953
Fixes for mpl Graph style mapping
philippjfr 5725053
Fixes for fill/line color and TriMesh plotting
philippjfr f4ede90
Refactored code to check whether dim transform applies
philippjfr 82808f6
Added support for normalizing dim transforms
philippjfr 8144864
Better handling for filled and non-filled glyphs
philippjfr 8f89a0e
Handle alpha validation
philippjfr 5868705
Added unit tests for stats elements
philippjfr c30e29e
Small fix
philippjfr 61e6419
Added HexTilePlot unit tests
philippjfr 5828804
Fixed flakes
philippjfr e2700a1
Fixed unit tests
philippjfr 47f65be
Added unit tests for contour and polygon plots
philippjfr 4638c2b
Fixed issue in SankeyPlot
philippjfr 040effa
Added docs to dim transforms
philippjfr 67826db
Renamed ops to transform
philippjfr 122d8c0
Added dim transform unit tests
philippjfr daffaae
Removed support for dim tuple spec
philippjfr a5f4d46
Apply suggestions from code review
jbednar 0a31fe4
Renamed apply_ops to apply_transforms
philippjfr 3c224af
Renamed _no_op_styles
philippjfr 6981eb9
Fixed flake
philippjfr 43a2448
Fixed scalar dim transform normalization
philippjfr 056a0b5
Renamed dim.eval to dim.apply
philippjfr 14af370
Marked old plot options as deprecated
philippjfr c23aab1
Fixed handling of dim color mapping range lookup
philippjfr 9973afb
Update holoviews/util/transform.py
jbednar c4c1a3f
Update holoviews/util/transform.py
jbednar 0321029
Update holoviews/util/transform.py
jbednar 4d167f5
Added matplotlib validator
philippjfr 0fe9f8c
Fixed python2 issues
philippjfr d7a4595
Fixed flakes
philippjfr 01fe7e0
Fixed bug in mpl validator
philippjfr 5901768
Handle style transforms for ChordPlots
philippjfr 7e0d7b3
Use unique_array utility throughout
philippjfr 895cb65
Added dim key lookup utility
philippjfr 79990f5
Fixed issue colormapping scalar styles
philippjfr cc371f1
Make normalization system compute factors
philippjfr f2053e5
Fixes for drawing Chord arcs
philippjfr 9dfce9b
Fixed syntax error
philippjfr 785c40a
Fixed factor sorting issues
philippjfr 0680782
Fixed colorbars on PathPlot
philippjfr acd5f6f
Fixed flakes
philippjfr 9fb6db8
Fixed color handling for Graphs
philippjfr f13a324
Renamed dim transform helper functions
philippjfr 6c4262a
Updated HexTiles
philippjfr 5740075
Add warning about size_index and scale transform on HexTilePlot
philippjfr 523e3a1
Updated unit tests
philippjfr d047bc8
Fixed expansion of color/alpha options in bokeh
philippjfr bdf2598
Normalize graph edges correctly
philippjfr 1663316
Fixed flake
philippjfr 2b80840
Fix for ChordPlot node style
philippjfr 655fcc3
Fixed a number of examples
philippjfr ebb716a
Added utility to handle matplotlib style groups
philippjfr c5f25cc
Fixed flake
philippjfr 00f9de6
Fixed small bug
philippjfr 43f4aca
Updated SankeyPlot
philippjfr a55529e
Added dim.str transform
philippjfr ec0487c
Further Sankey fixes
philippjfr 3086224
Updated nyc_airport_routes
philippjfr f5f5c15
Fixed issue in VectorField
philippjfr d71c656
Fixed stray tuple dim format in examples
philippjfr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
examples/gallery/demos/matplotlib/nyc_taxi_connections.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Most examples work across multiple plotting backends, this example is also available for:\n", | ||
"\n", | ||
"* [Bokeh NYC Taxi Connection](../bokeh/nyc_taxi_connections.ipynb)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import networkx as nx\n", | ||
"import holoviews as hv\n", | ||
"from holoviews import dim\n", | ||
"\n", | ||
"from holoviews.element.graphs import layout_nodes\n", | ||
"from bokeh.sampledata.airport_routes import routes, airports\n", | ||
"\n", | ||
"hv.extension('matplotlib')\n", | ||
"%output fig='svg' size=300" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Declare data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create dataset indexed by AirportID and with additional value dimension\n", | ||
"airports = hv.Dataset(airports, ['AirportID'], ['Name', 'IATA', 'City'])\n", | ||
"source_airports = list(airports.select(City='New York').data.AirportID)\n", | ||
"\n", | ||
"# Add connections count to routes then aggregate and select just routes connecting to NYC\n", | ||
"routes['connections'] = 1\n", | ||
"nyc_graph = hv.Graph((routes, airports), ['SourceID', \"DestinationID\"], ['connections'], label='NYC Airport Connections').aggregate(function=np.count_nonzero).select(SourceID=source_airports)\n", | ||
"\n", | ||
"# Lay out graph weighting and weight by the number of connections\n", | ||
"np.random.seed(14)\n", | ||
"graph = layout_nodes(nyc_graph, layout=nx.layout.fruchterman_reingold_layout, kwargs={'weight': 'connections'})\n", | ||
"labels = hv.Labels(graph.nodes, ['x', 'y'], ['IATA', 'City'])\n", | ||
"nyc_labels = labels.select(City='New York')\n", | ||
"other_labels = labels[labels['City']!='New York']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cmap={3697: 'red', 3797: 'blue'}\n", | ||
"\n", | ||
"plot = (\n", | ||
" graph.options(\n", | ||
" bgcolor='gray', edge_color=dim('SourceID').categorize(cmap, 'gray'), node_color=dim('index').categorize(cmap, 'gray'),\n", | ||
" xaxis=None, yaxis=None, xlim=(-1.2, 1.2), ylim=(-1.2, 1.2)\n", | ||
" ) *\n", | ||
" nyc_labels.options(color='white', yoffset=0.05, size=16) *\n", | ||
" other_labels.options(color='white', size=8)\n", | ||
")\n", | ||
"\n", | ||
"plot.relabel('NYC Airport Connections')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 'dim' turns out much more readable than 'op' here; I can immediately see that the size will be set to 10 times the unemployment value. Nice.