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

Differences in marker size lost on zoom #36

Open
zilch42 opened this issue Sep 4, 2024 · 1 comment
Open

Differences in marker size lost on zoom #36

zilch42 opened this issue Sep 4, 2024 · 1 comment

Comments

@zilch42
Copy link

zilch42 commented Sep 4, 2024

I wonder if there was a different way to apply the marker_size_array so that the difference is in point size can, at least to some degree, be maintained at different zoom levels. In the example below I've generated some lognormal marker size data which more closely resembles my use case.

import numpy as np
import datamapplot

wikipedia_data_map = np.load("wikipedia_layered_data_map.npy")
wikipedia_label_layers = []
for i in range(6):
    wikipedia_label_layers.append(
        np.load(f"wikipedia_layer{i}_cluster_labels.npy", allow_pickle=True)
    )
wikipedia_hover_text = [
    x.strip()
    for x in open(
        "wikipedia_large_hover_text.txt",
        mode="r"
    )
]
wikipedia_marker_size_array = np.load("wikipedia_marker_size_array.npy")
log_normal_data = np.random.lognormal(0, 1, len(wikipedia_marker_size_array))
log_normal_data = 1 + (log_normal_data - log_normal_data.min()) * (70 - 1) / (log_normal_data.max() - log_normal_data.min())

plot = datamapplot.create_interactive_plot(
    wikipedia_data_map,
    wikipedia_label_layers[0],
    wikipedia_label_layers[1],
    wikipedia_label_layers[3],
    wikipedia_label_layers[5],
    hover_text = wikipedia_hover_text,
    title="Map of Wikipedia",
    sub_title="Paragraphs from articles on Simple Wikipedia embedded with Cohere embed",
    logo="https://asset.brandfetch.io/idfDTLvPCK/idyv4d98RT.png",
    font_family="Marcellus SC",
    background_color="#eae6de",
    marker_size_array=log_normal_data,
    cluster_boundary_polygons=True,
    initial_zoom_fraction=0.4,
    point_radius_max_pixels=16,
)
plot

When zoomed out there are big differences in the marker sizes which generally piques a user's interest (see highlighted MERS document).
image

But upon zooming in to investigate, the large point is hard to find because it looks the same as all the others.
image

I understand the way the point_radius_mix_pixels and point_radius_max_pixels are being applied, and it does feel natural for the points to get bigger as you zoom in, but I wonder if there is a way that some measure of differentiation can be maintained at those deeper zoom levels?

@zilch42 zilch42 changed the title Differences in mocker size lost on zoom Differences in marker size lost on zoom Sep 4, 2024
@lmcinnes
Copy link
Contributor

lmcinnes commented Sep 5, 2024

It may be possible in principle, but I am learning very heavily on deck.gl and the features they support, and in that case it is not so easy. The best you can do is not have the points get larger as you zoom in. You can arrange for that by messing with the radiusUnits and setting it to "pixels" instead of "common". You may have to then mess with radiusScale or rescale your marker sizes but that should work. Personally I found the result of this underwhelming, but your mileage may vary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants