This commit is contained in:
√(noham)²
2023-07-18 16:57:46 +02:00
parent e002665cf8
commit 101732b815
2 changed files with 34 additions and 34 deletions

View File

@@ -1,4 +1,5 @@
from colour import Color
import matplotlib.pyplot as plt
def rainbow_gradient(distances):
num_colors = len(distances)
@@ -31,4 +32,34 @@ distances = [0.05263158, 0.05263158, 0.05263158, 0.05263158, 0.05263158,
gradient = rainbow_gradient(distances)
print(gradient)
# Create a figure and axis
fig, ax = plt.subplots()
# Set the background color of the plot
fig.set_facecolor('white')
# Hide the axis labels
ax.set_axis_off()
# Calculate the width and height of each color patch
width = 1.0 / len(gradient)
height = 1.0
# Iterate through the colors and plot a rectangle for each
for i, color in enumerate(gradient):
# Calculate the x-coordinate of the color patch
x = i * width
# Plot the color patch
rect = plt.Rectangle((x, 0), width, height, facecolor=color)
ax.add_patch(rect)
# Set the aspect ratio to 'auto' to ensure the patches are square
ax.set_aspect('auto')
# Set the limits of the x-axis
ax.set_xlim(0, 1)
# Display the plot
plt.show()