-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bubble Plot for Fairness vs Utility #67
Comments
@Hamedloghmani @edwinpaul121 |
@hosseinfani |
@hosseinfani @Hamedloghmani, import matplotlib.pyplot as plt
import seaborn as sns
def bubble_plot_lstdata(lst_fair, lst_util, runtime):
'''
@args: list of float numbers (fairness)
list of float numbers (utilities)
list of float numbers (runtime)
'''
plt.rcParams['figure.figsize'] = [14, 8]
sns.set_style("darkgrid") # used just for a darker background with grids (not required)
# Plots data using seaborn
sns.scatterplot(x = lst_fair,
y = lst_util,
size = runtime,
sizes = (20,600),
alpha = 0.5
)
# Titles for x and y axes
plt.xlabel("Fairness Measure")
plt.ylabel("Utility Measure")
# Brings legend out of the graph region
plt.legend(bbox_to_anchor=(1, 1), loc='upper left', fontsize=10)
# Displays graph
plt.show() Edit : Code format updated |
Follow up to the previous comment, would it be better to upload the python file directly as the formatting doesn't seem to be working too well with this |
@edwinpaul121 |
@edwinpaul121 @Hamedloghmani |
First test values and figure :
Second test values and its figure:
|
Thank you @edwinpaul121 |
Hi @edwinpaul121 import matplotlib.pyplot as plt
import seaborn as sns
def bubble_plot(fairness: list, utility: list, runtime: list, figsize: list = [14, 8], xlabel: str = "Fairness Metric", ylabel: str = "Utility Metric", save: bool = False):
"""
Args:
fairness: fairness metric values
utility: utility metric values
runtime: runtime of each sample
figsize: figure size for plot
xlabel: label for the x-axis on the plot
ylabel: label for the y-axis on the plot
save: flag to determine saving the plot
"""
plt.rcParams['figure.figsize'] = figsize
sns.set_style("darkgrid") # used just for a darker background with grids (not required)
# Plots data using seaborn
sns.scatterplot(x=fairness, y=utility, size=runtime, sizes=(min(runtime), max(runtime)), alpha=0.5)
# Titles for x and y axes
plt.xlabel(xlabel)
plt.ylabel(ylabel)
# Brings legend out of the graph region
plt.legend(bbox_to_anchor=(1, 1), loc='upper left', fontsize=10)
if save:
plt.savefig(f'{xlabel} vs {ylabel}.png')
# Displays graph
plt.show() |
Hi @Hamedloghmani, the changes make sense, I'll make a pull request asap. |
Hello @edwinpaul121
This is your first task and issue page in this project, welcome 😄
Your task is to design and implement a function to create a bubble plot from 2 given list of float numbers. One of these lists is fairness, the other one is utility. Consider the lists have the same length.
Please try to write the function as generic as possible as we discussed and include other necessary arguments to customize the plot.
Some bubble plot samples can be found here
You can log your progress and problems here. Please let me know if you have any questions.
Thanks
The text was updated successfully, but these errors were encountered: