First usage of Python libraries

First usage of Python libraries#

A simple Matplotlib/Pandas plot…

https://python-cnrs.netlify.app/edu/lite/lab/index.html

import numpy as np
import matplotlib.pyplot as plt

Vega-Altair

import altair as alt

# load a sample dataset as a pandas DataFrame
from vega_datasets import data
cars = data.cars()

# make the chart
alt.Chart(cars).mark_point().encode(
    x="Horsepower",
    y="Miles_per_Gallon",
    color="Origin",
).interactive()

ipyleaflet

from ipyleaflet import Map, Marker

center = (52.204793, 360.121558)
map = Map(center=center, zoom=12)

# Add a draggable marker to the map
# Dragging the marker updates the marker.location value in Python
marker = Marker(location=center, draggable=True)
map.add_control(marker)

display(map)
# We can also update the marker location from Python
marker.location = (52.2, 360.1)
# We can run a python function when the marker location changes
# Here we'll adjust the center of the map to follow the marker
def on_location_changed(value):
    map.center = value.new


# Call the on_location_changed function when marker.location changes
marker.observe(on_location_changed, "location")