mirror of
https://github.com/NohamR/Stage-2023.git
synced 2026-01-09 23:58:18 +00:00
changes
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user