File:Heatmap of GCD Matrix.png

From testwiki
Jump to navigation Jump to search
    Original file (800 × 600 pixels, file size: 22 KB, MIME type: image/png)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Heatmap of GCD Matrix
    Date
    Source Own work
    Author Lorepenoten
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib
    import os
    from math import gcd
    
    # Ensure output directory exists
    os.makedirs("/mnt/data", exist_ok=True)
    
    # Define the list S
    S = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    n = len(S)
    
    # Create the GCD matrix
    gcd_matrix = np.zeros((n, n), dtype=int)
    for i in range(n):
        for j in range(n):
            gcd_matrix[i, j] = gcd(S[i], S[j])
    
    # Plot the heatmap
    plt.style.use('seaborn-v0_8')
    fig, ax = plt.subplots(figsize=(8, 6))
    cax = ax.matshow(gcd_matrix, cmap='viridis')
    
    # Add colorbar
    fig.colorbar(cax)
    
    # Set axis labels
    ax.set_xticks(np.arange(n))
    ax.set_yticks(np.arange(n))
    ax.set_xticklabels(S)
    ax.set_yticklabels(S)
    plt.xlabel("S values")
    plt.ylabel("S values")
    plt.title("Heatmap of GCD Matrix")
    
    # Rotate x-axis labels for better readability
    plt.xticks(rotation=45)
    
    # Save the figure
    output_path = "/mnt/data/gcd_matrix_heatmap.png"
    plt.tight_layout()
    plt.savefig(output_path)
    plt.close()
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Captions

    Heatmap of GCD Matrix

    Items portrayed in this file

    depicts

    9 October 2025

    22,882 byte

    600 pixel

    800 pixel

    image/png

    07e28cd5fd2d3341df4915a33bc0a06728c94a27

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current02:54, 9 October 2025Thumbnail for version as of 02:54, 9 October 2025800 × 600 (22 KB)wikimediacommons>LorepenotenUploaded own work with UploadWizard

    There are no pages that use this file.