Skip to content

Commit

Permalink
Improve the documentation of ColorPalette class
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi committed Mar 25, 2024
1 parent 2632590 commit d4bf5bf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion robot_log_visualizer/plotter/color_palette.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# Copyright (C) 2024 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# Released under the terms of the BSD 3-Clause License

Expand All @@ -8,9 +8,15 @@
class ColorPalette:
def __init__(self):
# Define the color taking from the default matplotlib color palette
# prop_cycle provides the color cycle used as rcParams. In the future,
# if one wants to change the default color palette in Matplotlib,
# they can modify the set rcParams directly and our color_palette will
# always take the one set See here: matplotlib.org/stable/users/explain/customizing.html.
# For details on prop_cycle, visit: matplotlib.org/stable/users/explain/artists/color_cycle.html
self.colors = [
color["color"] for color in list(plt.rcParams["axes.prop_cycle"])
]

self.current_index = 0

def get_color(self, index):
Expand All @@ -26,4 +32,5 @@ def __len__(self):
def __next__(self):
color = self.get_color(self.current_index)
self.current_index += 1

return color

0 comments on commit d4bf5bf

Please sign in to comment.