The user interface

Let’s look at the UI elements in the figure.

Zoom and pan

Let’s revisit the simple graph example in the tutorial:

import croquis
import numpy as np

fig = croquis.plot()

for fn in np.sin, np.cos, np.tanh:
    X = np.linspace(-5, 5, 100)
    Y = fn(X)
    fig.add(X, Y, label=fn.__name__)

fig.show()
_images/tutorial1-first.png

If zoom is selected on the upper right corner, you can drag and select a rectangular area:

_images/ui1-zoom.png

The selected area will be zoomed:

_images/ui2-zoom.png

You can also use the magnifier (🔍) buttons to zoom in/out, or use the 🏠 Reset button to return to the initial state.

If you select pan on the upper right corner, then you can drag the plot around with the mouse:

_images/ui3-pan.png

Search and selection

Croquis lets you interactively select/deselect a large number of items based on labels. As an example, let’s play with the temperature data of weather stations in California and Hawaii during February 2020 1:

import os
import croquis
import pandas as pd

csv_filename = 'CA_HI_Feb2020.csv.gz'
if not os.path.exists(csv_filename):
    import urllib.request
    urllib.request.urlretrieve(
        'https://raw.githubusercontent.com/yongjik/croquis-extra/master/noaa_temperature_data/CA_HI_Feb2020.csv.gz',
        csv_filename)

df = pd.read_csv(csv_filename)

fig = croquis.plot(x_axis='timestamp')
fig.add(pd.to_datetime(df.timestamp, unit='s'), df.temperature, groupby=df.name)
fig.show()
_images/sel1-initial.png
1

The data was derived from hourly temperature data archives, downloaded from NOAA website.

You can hover your mouse cursor over the plot, and the corresponding line will be highlighted with its label and the nearest coordinate:

_images/sel2-tooltip.png

By default, the search box is in Autoselect mode, i.e., the figure will show exactly those that matches the search box:

_images/sel3-autoselect.png

If you check the Regex button, the input is interpreted as a regular expression (and case sensitive):

_images/sel4-regex.png

You can also hide/show individual items by clicking on them in the item list (which also turns autoselect off). In this mode, you can also do bulk select/deselect by clicking on the “More…” button. The pop-up menu is pretty straightforward: “Select all” and “Deselect all” do what they say, and if the search box is not empty, “Select/Deselect all matching ‘…’” bulk updates all matching items.

_images/sel5-manual-select.png