Beispiel #1
0
def show_image(img: np.array, ax: plt.Subplot = None, title: str = ''):
    if ax:
        ax.set_title(title)
        ax.set_yticklabels([])
        ax.set_xticklabels([])
        ax.axes.get_xaxis().set_visible(False)
        ax.axes.get_yaxis().set_visible(False)
        ax.imshow(img)
    else:
        plt.imshow(img)
Beispiel #2
0
def plot_stop_accessibility_cdf(subplot: Subplot, result: CrossStopRemovalResult):
    """Plot the accessibility difference in ``result`` as a subplot onto ``subplot``."""
    # pylint: disable=invalid-name

    # Configure plot
    subplot.set_xlabel("Distance to stop (km)", size=20)
    subplot.set_ylabel("Percentile", size=20)
    subplot.set_title(result.stop_removed.cross_name, size=24)

    # Plot CDF
    x, y = result.metrics_before.get_quantile_cdf(20)
    subplot.plot(x, y, label="Before")

    x, y = result.metrics_after.get_quantile_cdf(20)
    subplot.plot(x, y, label="After")

    # Post-configure the plot
    subplot.legend(loc="upper right")
Beispiel #3
0
def plot_stop_accessibility_hist(subplot: Subplot,
                                 result: CrossStopRemovalResult):
    """Plot the accessibility difference in ``result`` as a subplot onto ``subplot``."""
    # ----- Plot histogram
    # https://datavizpyr.com/overlapping-histograms-with-matplotlib-in-python/

    # Configure plot
    subplot.set_xlabel("Distance to stop (km)", size=14)
    subplot.set_ylabel("Agent count", size=14)
    subplot.set_title(
        f"Distance to stop between before and after removing {result.stop_removed.cross_name}"
    )

    # Plot histograms
    subplot.hist(result.metrics_before.data,
                 bins=20,
                 alpha=0.5,
                 label="Before")
    subplot.hist(result.metrics_after.data, bins=20, alpha=0.5, label="After")

    # Post-configure the plot
    subplot.legend(loc="upper right")