import matplotlib.pyplot as plt
from typing import Record, Tuple
from PIL import Picture
import cv2
def plot_points_and_lines_with_grid(
ax: plt.Axes,
ax_labels = [“x”, “y”],
scatter_arg_kwarg_pair: Tuple = None,
line_arg_kwarg_pairs: Record[Tuple] = None,
limits: Record[int] = [-5, 5, -5, 5]
):
“””_summary_
https://stackoverflow.com/questions/13430231/how-i-can-get-cartesian-coordinate-system-in-matplotlib
Args:
ax (_type_): _description_
scatter_arg_kwarg_pair (Tuple, optionally available): _description_. Defaults to None.
line_arg_kwarg_pairs (Record[Tuple], optionally available): _description_. Defaults to None.
label_size (int, optionally available): _description_. Defaults to 14.
Returns:
_type_: _description_
“””
# Plot factors
if scatter_arg_kwarg_pair will not be None:
scatter_args, scatter_kwargs = scatter_arg_kwarg_pair
ax.scatter(*scatter_args, **scatter_kwargs)
# Plot traces
if line_arg_kwarg_pairs will not be None:
for line_args, line_kwargs in line_arg_kwarg_pairs:
ax.plot(*line_args, **line_kwargs)
# Choose size of axes and the house between tick labels
xmin, xmax, ymin, ymax = limits
ticks_frequency = 1
# Set an identical scales for each axes
ax.set(xlim=(xmin-1, xmax+1), ylim=(ymin-1, ymax+1), facet=’equal’)
# Set backside and left spines as x and y axes of coordinate system…