-
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
- Loading branch information
1 parent
321712d
commit 94537f1
Showing
2 changed files
with
133 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,29 @@ | ||
# Copyright (C) 2022 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 | ||
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