from ipyleaflet import Map, Marker, basemaps, basemap_to_tiles
= Map(
m =basemap_to_tiles(
basemap"2017-04-08"
basemaps.NASAGIBS.ModisTerraTrueColorCR,
),=(52.204793, 360.121558),
center=4
zoom
)=(52.204793, 360.121558)))
m.add_layer(Marker(location m
Placing Colorbars
Colorbars indicate the quantitative extent of image data. Placing in a figure is non-trivial because room needs to be made for them. The simplest case is just attaching a colorbar to each axes:1.
1 See the Matplotlib Gallery to explore colorbars further
Code
import matplotlib.pyplot as plt
import numpy as np
= plt.subplots(2, 2)
fig, axs 20, 8)
fig.set_size_inches(= ['RdBu_r', 'viridis']
cmaps for col in range(2):
for row in range(2):
= axs[row, col]
ax = ax.pcolormesh(
pcm 20, 20)) * (col + 1),
np.random.random((=cmaps[col]
cmap
)=ax)
fig.colorbar(pcm, ax plt.show()
Interactivity with maps
Quarto allows interactivity with maps:
Content in the margins
Quarto allows to put content to the margins:
import numpy as np
import matplotlib.pyplot as plt
= np.arange(0, 2, 0.01)
r = 2 * np.pi * r
theta = plt.subplots(
fig, ax = {'projection': 'polar'}
subplot_kw
)
ax.plot(theta, r)0.5, 1, 1.5, 2])
ax.set_rticks([True)
ax.grid( plt.show()
Interactive data exploring
ObservableJS renders interactive data plots:
Code
= Inputs.range(
viewof bill_length_min 32, 50],
[value: 35, step: 1, label: "Bill length (min):"}
{
)= Inputs.checkbox(
viewof islands "Torgersen", "Biscoe", "Dream"],
[value: ["Torgersen", "Biscoe"],
{ label: "Islands:"
} )
Code
.rectY(filtered,
Plot.binX(
Ploty: "count"},
{x: "body_mass", fill: "species", thresholds: 20}
{
)).plot({
facet: {
data: filtered,
x: "sex",
y: "species",
marginRight: 80
,
}marks: [
.frame(),
Plot
]
} )
Code
= FileAttachment("palmer-penguins.csv").csv({ typed: true })
data
= data.filter(function(penguin) {
filtered return bill_length_min < penguin.bill_length &&
.includes(penguin.island);
islands
}).table(filtered) Inputs