Skip to content
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

feat: Adding maps #71

Merged
merged 4 commits into from
Nov 6, 2023
Merged

feat: Adding maps #71

merged 4 commits into from
Nov 6, 2023

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Sep 26, 2023

Closes #29, closes #28, closes #27, closes #26, and closes #21

Adds basic capabilities for all maps with the exception of choropleth
I originally was trying to include choropleths as well but they're a bit more complicated and I already have spent a bit too long on this for the moment. The other maps are basically free to implement.

There is a graphical issue with density mapbox that would be good for @mattrunyon to look at when adding the defaults. The data is there but not being drawn.
Here's some code to recreate the issue:

import deephaven.plot.express as dx
from deephaven import time_table
import random 
import pandas as pd
import deephaven.pandas as dhpd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

t = dhpd.to_table(df)

fig = dx.density_mapbox(t,  lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
                        center=dict(lat=0, lon=180), zoom=0,
                        mapbox_style="stamen-terrain")

I see a ton of errors in the console, some along the line of "The layer 'plotly-trace-layer-ea2295-heatmap' does not exist in the map's style and cannot be styled."

Additionally, geo plots have the snapping issue when dragging when new data loads in that 3d plots had. Using the same imports:

sourceh = time_table("PT1S").update(formulas=[
    "X = (float) random.uniform(-90, 90)", 
    "Y = (float) random.uniform(-180, 180)", 
    "Z = (float)random.gauss(3, 3)",
    "l1 = i % 20",
    "l2 = i % 30",
    ])

def update(fig):
    fig.update_geos(showland=True, landcolor="gray")

figs = dx.scatter_geo(
    sourceh, 
    lat="X", 
    lon="Y", 
    by="l1", 
    size="Z",
    color_discrete_sequence=["salmon", "lemonchiffon"],
    projection="natural earth",
    unsafe_update_figure=update
)

@jnumainville jnumainville changed the title Adding maps feat: Adding maps Sep 28, 2023
@jnumainville
Copy link
Collaborator Author

Some examples:

import deephaven.plot.express as dx
from deephaven import time_table
import random 

sourceh = time_table("PT1S").update(formulas=[
    "X = (float) random.uniform(-90, 90)", 
    "Y = (float) random.uniform(-180, 180)", 
    "Z = (float)random.gauss(3, 3)",
    "l1 = i % 20",
    "l2 = i % 30",
    ])

def update(fig):
    fig.update_geos(showland=True, landcolor="gray")

figs = dx.scatter_geo(
    sourceh, 
    lat="X", 
    lon="Y", 
    by="l1", 
    size="Z",
    color_discrete_sequence=["salmon", "lemonchiffon"],
    projection="natural earth",
    unsafe_update_figure=update
)

figs = dx.line_geo(
    sourceh, 
    lat="X", 
    lon="Y", 
    by="l1", 
    by_vars=("color", "width"),
    color_discrete_sequence=["salmon", "lemonchiffon"],
    projection="natural earth",
    unsafe_update_figure=update
)

figs = dx.line_mapbox(
    sourceh, 
    lat="X", 
    lon="Y", 
    color="l1",
    color_discrete_sequence=["salmon", "lemonchiffon"],
    center=dict(lat=0, lon=180), zoom=0,
)

figs = dx.scatter_mapbox(
    sourceh, 
    lat="X", 
    lon="Y", 
    color="l1",
    color_discrete_sequence=["salmon", "lemonchiffon"],
    center=dict(lat=0, lon=180), zoom=0,
)

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need default colours applied to these maps before merging.

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open a ticket for default colours of maps. Should tie in with the current theme.

@mofojed
Copy link
Member

mofojed commented Nov 6, 2023

Ticket opened for default colours: deephaven/web-client-ui#1722

@mofojed mofojed merged commit 77507b9 into deephaven:main Nov 6, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants