-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the possibility to click on a plot and display the x and y coordi…
…nate of the associated to the point (#81)
- Loading branch information
1 parent
321712d
commit 9c67df9
Showing
2 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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 | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
|
||
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): | ||
return self.colors[index % len(self.colors)] | ||
|
||
def __iter__(self): | ||
self.current_index = 0 | ||
return self | ||
|
||
def __len__(self): | ||
return len(self.colors) | ||
|
||
def __next__(self): | ||
color = self.get_color(self.current_index) | ||
self.current_index += 1 | ||
|
||
return color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters