OrthographicView on PyDeck #5291
Replies: 2 comments 4 replies
-
All the views are there, e.g. FirstPersonView. Here's an OrthographicView example: import pydeck
import math
# Plot of a square root function
plot_data = [
{
'x': num,
'y': math.sqrt(num),
'pos': [num, -math.sqrt(num)] # Note that the y position is negative
} for num in range(0, 10000)
]
point_cloud_layer = pydeck.Layer(
"ScatterplotLayer",
data=plot_data,
get_position="pos",
radius_unit='"pixels"', # Many deck.gl layers default to radius units in meters
auto_highlight=True,
get_fill_color=[255, 0, 0],
highlight_color=[255, 140, 255],
pickable=True,
get_radius=0.5,
radius_min_pixels=0.5
)
# Create an x and y axis
axis_layer = pydeck.Layer(
"PathLayer",
data=[
{'path': [[-100000, 0], [100000, 0]]},
{'path': [[0, -100000], [0, 100000]]}
],
get_path="path",
width_unit='"pixels"',
get_color=[0, 0, 0],
width_min_pixels=1,
width_max_pixels=1,
get_width=1,
)
# Add labels to x and y axis
label_data = [{"x": i, "y": 0, "label": str(i)} for i in range(-1000, 1000) if i % 10 == 0]
label_data += [{"x": 0, "y": i, "label": str(-1 * i)} for i in range(-1000, 1000) if i % 10 == 0]
axis_labels = pydeck.Layer(
"TextLayer",
data=label_data,
get_position=['x', 'y'],
get_size=15,
size_max_pixels=15,
size_min_pixels=15,
get_text='label',
get_alignment_baseline='"bottom"',
)
view_state = pydeck.ViewState(target=[0, 0, 0], zoom=2)
view = pydeck.View(
type="OrthographicView",
controller=True
)
r = pydeck.Deck(
[point_cloud_layer, axis_layer, axis_labels],
map_provider=None,
initial_view_state=view_state,
views=[view]
)
r.to_html(css_background_color='skyblue') |
Beta Was this translation helpful? Give feedback.
-
Hi @ajduberstein, is there a way to get different layers to have different zoom behaviors? For instance, I would want to have the x and y axes each zoom in the horizontal and vertical directions, respectively. Also, is there a way to reverse the y orientation convention (e.g. positive y values go downwards)? Also, I ran into a few bugs where nothing is plotted if the names of data points have spaces or dashes in them - I'll raise this as an issue later and try to see if I can figure out what is causing this in the code. |
Beta Was this translation helpful? Give feedback.
-
Hi, I wanted to know if it is possible to use the OrthographicView in PyDeck. I want to visualize some non geospatial data.
Beta Was this translation helpful? Give feedback.
All reactions