Showing a cursor on multiple plots simultaneously.
This example generates three axes split over two different figures. On
hovering the cursor over data in one subplot, the values of that datapoint are
shown in all axes.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import MultiCursor
t = np.arange(0.0, 2.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(3*np.pi*t)
s3 = np.sin(4*np.pi*t)
fig, (ax1, ax2) = plt.subplots(2, sharex=True)
ax1.plot(t, s1)
ax2.plot(t, s2)
fig, ax3 = plt.subplots()
ax3.plot(t, s3)
multi = MultiCursor(None, (ax1, ax2, ax3), color='r', lw=1)
plt.show()
Related articles
import matplotlib.pyplot as plt from matplotlib.widgets import PolygonSelector # To create the polygon programmatically fig, ax = plt.subplots() fig.show() selector = PolygonSelector(ax, lambda *args: None)
Using radio buttons to choose properties of your plot. Radio buttons let you choose between multiple options in a visualization. In this case, the buttons let the user choose one of the three different sine waves to be shown in the plot.
from asyncio import sleep from sanic import Sanic, response app = Sanic("DelayedResponseApp", strict_slashes=True) app.config.AUTO_EXTEND = False
from sanic.exceptions import SanicException from sanic.handlers import ErrorHandler class CustomHandler(ErrorHandler): def default(self, request, exception): # Here, we have access to the exception object
import logging from sanic import Sanic, text logging_format = "[%(asctime)s] %(process)d-%(levelname)s " logging_format += "%(module)s::%(funcName)s():l%(lineno)d: " logging_format += "%(message)s"
Install testing tools: $ pip install pytest pytest-xdist Run with xdist params: $ pytest examples/pytest_xdist.py -n 8 # 8 workers example import re import pytest
from os import getenv from raygun4py.raygunprovider import RaygunSender from sanic import Sanic from sanic.exceptions import SanicException from sanic.handlers import ErrorHandler
from sanic import Sanic, response app = Sanic("Example") @app.route("/") def handle_request(request): return response.redirect("/redirect")
Click somewhere, move the mouse, and release the mouse button. `.RectangleSelector` and `.EllipseSelector` draw a rectangle or an ellipse from the initial click position to the current mouse position (within the same axes) until the button is released
In this example, sliders are used to control the frequency and amplitude of a sine wave. See :doc:`/gallery/widgets/slider_snap_demo` for an example of having