-
Notifications
You must be signed in to change notification settings - Fork 16
fix: DH-21259: Fix maps and add docs #1279
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||
| # Density Map | ||||
|
|
||||
| A density map plot is a geographic visualization that connects data points with a heatmap on a geographic map using latitude and longitude coordinates or locations. The heatmap is ideal for visualizing the density of data across geographic areas. | ||||
|
|
||||
| Density map plots are appropriate when the dataset contains geographic coordinates (latitude and longitude) or locations that represent individual points on a map. `density_map` visualizes data using detailed map tiles. For visualizing individual points, use [`scatter_geo`](./scatter-geo.md) or [`scatter_map`](./scatter-map.md). | ||||
|
|
||||
| ## What are density map plots useful for? | ||||
|
|
||||
| - **Geographic density**: They are excellent for showing the density of individual geographic locations on a map. | ||||
| - **Detailed geographic context**: Density map plots provide a rich and detailed way to visualize geographic data with map tile features. | ||||
|
|
||||
| ## Examples | ||||
|
|
||||
| ### A basic density map plot | ||||
|
|
||||
| Visualize geographic density by passing longitude and latitude column names to the `lon` and `lat` arguments. Click and drag on the resulting map to pan and zoom. | ||||
|
|
||||
| ```python order=density_map_plot,path | ||||
| import deephaven.plot.express as dx | ||||
| from deephaven import time_table | ||||
|
|
||||
| # Create a simple path dataset | ||||
| path = time_table("PT1s").update_view( | ||||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30"] | ||||
| ) | ||||
|
|
||||
| # Create the density map plot | ||||
| # Color is set for better visibility | ||||
| density_map_plot = dx.density_map(path, lat="Lat", lon="Lon") | ||||
| ``` | ||||
|
|
||||
| ### Variable density plot | ||||
|
|
||||
| Provide variable geographic densities by using the `z` argument to specify a column that contains density values. | ||||
|
|
||||
| ```python order=density_map_plot,path | ||||
| import deephaven.plot.express as dx | ||||
| from deephaven import time_table | ||||
|
|
||||
| # Create a simple dataset with density values | ||||
| path = time_table("PT1s").update_view( | ||||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30", "Z = ii % 100"] | ||||
| ) | ||||
|
|
||||
| # Create the density map plot | ||||
| # Color is set for better visibility | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| density_map_plot = dx.density_map(path, lat="Lat", lon="Lon", z="Z") | ||||
| ``` | ||||
|
|
||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also have an example where the lats/lons are spaced apart a bit more? Right now it just kind of looks like a trailing blob... unsure... I was going to look at the plotly express examples to see what they have, but the link is broken 🤔 : https://plotly.com/python/tile-density-heatmaps/ |
||||
| ## API Reference | ||||
|
|
||||
| ```{eval-rst} | ||||
| .. dhautofunction:: deephaven.plot.express.line_map | ||||
| ``` | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Line Geo | ||
|
|
||
| A line geo plot is a geographic visualization that connects data points with lines on a map using latitude and longitude coordinates or locations. The lines are ideal for visualizing relationships between geographic locations such as paths or routes. | ||
|
|
||
| Line geo plots are appropriate when the dataset contains geographic coordinates (latitude and longitude) or locations that connect across geographic areas. `line_geo` visualizes data using a basic map projection, without a high degree of detail. For richer tile maps, use [`line_map`](./line-map.md). For visualizing values at individual locations, consider using [`scatter_geo`](./scatter-geo.md). | ||
|
|
||
| ## What are line geo plots useful for? | ||
|
|
||
| - **Geographic relationships**: They are excellent for showing connections or relationships between different geographic locations, such as routes or paths. | ||
| - **Simple geographic context**: Line geo plots provide a clear and straightforward way to visualize geographic data that does not require detailed map features. | ||
| - **Sequential geographic data**: Geographic line plots specialize in showing how data changes across connected geographic points over time or other ordered dimensions. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### A basic line geo plot | ||
|
|
||
| Visualize geographic paths by passing longitude and latitude column names to the `lon` and `lat` arguments. Click and drag on the resulting map to pan and zoom. | ||
|
|
||
| ```python order=line_geo_plot,path | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple path dataset | ||
| path = time_table("PT1s").update_view( | ||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30"] | ||
| ) | ||
|
|
||
| line_geo_plot = dx.line_geo(path, lat="Lat", lon="Lon") | ||
| ``` | ||
|
|
||
| ### Color by group | ||
|
|
||
| Denote different routes or paths by using the color of the lines as group indicators by passing the grouping column name to the `by` argument. | ||
|
|
||
| ```python order=line_geo_plot,paths | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple dataset with two paths | ||
| paths = time_table("PT1s").update_view( | ||
| ["Path = i % 2", "Lon = ((ii - 90) % 360)", "Lat = Path == 0 ? cos(ii/10) * 30 : sin(ii/10) * 30"] | ||
| ) | ||
|
|
||
| line_geo_colors = dx.line_geo(paths, lat="Lat", lon="Lon", by="Path") | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ```{eval-rst} | ||
| .. dhautofunction:: deephaven.plot.express.line_geo | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Line Map | ||
|
|
||
| A line map plot is a geographic visualization that connects data points with lines on a map using latitude and longitude coordinates or locations. The lines are ideal for visualizing relationships between geographic locations such as paths or routes. | ||
|
|
||
| Line map plots are appropriate when the dataset contains geographic coordinates (latitude and longitude) or locations that connect across geographic areas. `line_map` visualizes data using detailed map tiles. For simpler projection maps, use [`line_geo`](./line-geo.md). For visualizing values at individual locations, consider using [`scatter_map`](./scatter-map.md). | ||
|
|
||
| ## What are line map plots useful for? | ||
|
|
||
| - **Geographic relationships**: They are excellent for showing connections or relationships between different geographic locations, such as routes or paths. | ||
| - **Detailed geographic context**: Line map plots provide a rich and detailed way to visualize geographic data with map tile features. | ||
| - **Sequential geographic data**: Geographic line plots specialize in showing how data changes across connected geographic points over time or other ordered dimensions. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### A basic line map plot | ||
|
|
||
| Visualize geographic paths by passing longitude and latitude column names to the `lon` and `lat` arguments. Click and drag on the resulting map to pan and zoom. | ||
|
|
||
| ```python order=line_map_plot,path | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple path dataset | ||
| path = time_table("PT1s").update_view( | ||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30"] | ||
| ) | ||
|
|
||
| # Create the line map plot | ||
| # Color is set for better visibility | ||
| line_map_plot = dx.line_map(path, lat="Lat", lon="Lon", color_discrete_sequence="black") | ||
| ``` | ||
|
|
||
| ### Color by group | ||
|
|
||
| Denote different routes or paths by using the color of the lines as group indicators by passing the grouping column name to the `by` argument. | ||
|
|
||
| ```python order=line_geo_plot,paths | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple dataset with two paths | ||
| paths = time_table("PT1s").update_view( | ||
| ["Path = i % 2", "Lon = ((ii - 90) % 360)", "Lat = Path == 0 ? cos(ii/10) * 30 : sin(ii/10) * 30"] | ||
| ) | ||
| # Create the line map plot | ||
| # Color is set for better visibility | ||
| line_map_plot = dx.line_map(paths, lat="Lat", lon="Lon", color_discrete_sequence=["black", "darkgrey"], by="Path") | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ```{eval-rst} | ||
| .. dhautofunction:: deephaven.plot.express.line_map | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Scatter Geo | ||
|
|
||
| A scatter geo plot is a geographic visualization that displays individual data points on a map using latitude and longitude coordinates or locations. The points are ideal for visualizing the distribution of data across geographic areas. | ||
|
|
||
| Scatter geo plots are appropriate when the dataset contains geographic coordinates (latitude and longitude) or locations that represent individual points on a map. `scatter_geo` visualizes data using a basic map projection, without a high degree of detail. For richer tile maps, use [`scatter_map`](./scatter-map.md). For visualizing connections between locations, consider using [`line_geo`](./line-geo.md). | ||
|
|
||
| ## What are scatter geo plots useful for? | ||
|
|
||
| - **Geographic distribution**: They are excellent for showing the distribution of individual geographic locations on a map. | ||
| - **Simple geographic context**: Scatter geo plots provide a clear and straightforward way to visualize geographic data that does not require detailed map features. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### A basic scatter geo plot | ||
|
|
||
| Visualize geographic paths by passing longitude and latitude column names to the `lon` and `lat` arguments. Click and drag on the resulting map to pan and zoom. | ||
|
|
||
| ```python order=scatter_geo_plot,path | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple path dataset | ||
| path = time_table("PT1s").update_view( | ||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30"] | ||
| ) | ||
|
|
||
| scatter_geo_plot = dx.scatter_geo(path, lat="Lat", lon="Lon") | ||
| ``` | ||
|
|
||
| ### Color by group | ||
|
|
||
| Denote different routes or paths by using the color of the points as group indicators by passing the grouping column name to the `by` argument. | ||
|
|
||
| ```python order=scatter_geo_plot,paths | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple dataset with two paths | ||
| paths = time_table("PT1s").update_view( | ||
| ["Path = i % 2", "Lon = ((ii - 90) % 360)", "Lat = Path == 0 ? cos(ii/10) * 30 : sin(ii/10) * 30"] | ||
| ) | ||
|
|
||
| scatter_geo_colors = dx.scatter_geo(paths, lat="Lat", lon="Lon", by="Path") | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ```{eval-rst} | ||
| .. dhautofunction:: deephaven.plot.express.scatter_geo | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Scatter Map | ||
|
|
||
| A scatter geo plot is a geographic visualization that displays individual data points on a map using latitude and longitude coordinates or locations. The points are ideal for visualizing the distribution of data across geographic areas. | ||
|
|
||
| Scatter map plots are appropriate when the dataset contains geographic coordinates (latitude and longitude) or locations that represent individual points on a map. `scatter_map` visualizes data using detailed map tiles. For simpler projection maps, use [`scatter_geo`](./scatter-geo.md). For visualizing connections between locations, consider using [`line_map`](./line-map.md). | ||
|
|
||
| ## What are scatter map plots useful for? | ||
|
|
||
| - **Geographic distribution**: They are excellent for showing the distribution of individual geographic locations on a map. | ||
| - **Detailed geographic context**: Scatter map plots provide a rich and detailed way to visualize geographic data with map tile features. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### A basic scatter map plot | ||
|
|
||
| Visualize geographic paths by passing longitude and latitude column names to the `lon` and `lat` arguments. Click and drag on the resulting map to pan and zoom. | ||
|
|
||
| ```python order=scatter_map_plot,path | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple path dataset | ||
| path = time_table("PT1s").update_view( | ||
| ["Lon = ((ii - 90) % 360)", "Lat = cos(ii/10) * 30"] | ||
| ) | ||
|
|
||
| # Create the scatter map plot | ||
| # Color is set for better visibility | ||
| scatter_map_plot = dx.scatter_map(path, lat="Lat", lon="Lon", color_discrete_sequence="black") | ||
| ``` | ||
|
|
||
| ### Color by group | ||
|
|
||
| Denote different routes or paths by using the color of the lines as group indicators by passing the grouping column name to the `by` argument. | ||
|
|
||
| ```python order=scatter_map_plot,paths | ||
| import deephaven.plot.express as dx | ||
| from deephaven import time_table | ||
|
|
||
| # Create a simple dataset with two paths | ||
| paths = time_table("PT1s").update_view( | ||
| ["Path = i % 2", "Lon = ((ii - 90) % 360)", "Lat = Path == 0 ? cos(ii/10) * 30 : sin(ii/10) * 30"] | ||
| ) | ||
| # Create the scatter map plot | ||
| # Color is set for better visibility | ||
| scatter_map_plot = dx.scatter_map(paths, lat="Lat", lon="Lon", color_discrete_sequence=["black", "darkgrey"], by="Path") | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ```{eval-rst} | ||
| .. dhautofunction:: deephaven.plot.express.scatter_map | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -428,6 +428,19 @@ def process_args( | |
| render_args["args"]["filter_by"] = filter_by | ||
| render_args["args"]["required_filter_by"] = required_filter_by | ||
|
|
||
| if "center" in render_args["args"]: | ||
| center = render_args["args"].pop("center") | ||
| if center is None: | ||
| # Set a default center to prevent px from auto-centering based on data | ||
| # which breaks the initial view for map plots since the data may be null initially | ||
| # Auto centering on the server side is also a bad idea since the data can change, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I could us wanting to auto-centre based on the data, when it ticks again... would that be possible? Any way to force Plotly to re-centre when we get a new tick if no centre is specified? I think that might be better than this... either way can file as a separate ticket. |
||
| # so that should be done on the client side if desired | ||
| center = { | ||
| "lat": 0, | ||
| "lon": 0, | ||
| } | ||
| render_args["args"]["center"] = center | ||
|
|
||
| orig_process_args = args_copy(render_args) | ||
| orig_process_func = lambda **local_args: create_deephaven_figure(**local_args)[0] | ||
|
|
||
|
|
||
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.
Colour isn't being set here, this comment is confusing.