Skip to content
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

Modify cartoee.add_legend #997

Merged
merged 2 commits into from
Mar 29, 2022
Merged

Modify cartoee.add_legend #997

merged 2 commits into from
Mar 29, 2022

Conversation

Jack-ee
Copy link
Contributor

@Jack-ee Jack-ee commented Mar 28, 2022

Adding font size, weight, color, and Chinese font support in cartoee.add_legend.

@@ -1014,7 +1014,7 @@ def scale_number(x):
return


def add_legend(ax, legend_elements=None, loc="lower right"):
def add_legend(ax, legend_elements=None, loc="lower right",font_size=14, font_weight='normal',font_color='k',show_chinese=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing the show_chinese=False argument to font_family=None

Copy link
Member

@giswqs giswqs Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font_color='k' should probably be font_color='black'. Readers won't know what k stands for.

@@ -1044,8 +1047,16 @@ def add_legend(ax, legend_elements=None, loc="lower right"):
ls="",
),
]

ax.legend(handles=legend_elements, loc=loc)
if show_chinese == True:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        if font_family is not None:
            fontdict={"family": font_family, "size": font_size, "weight": font_weight}
        else:
            fontdict={"size": font_size, "weight": font_weight}   

font_size(int|string, optional): Font size. Either an absolute font size or an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'. defaults to 14.
font_weight(string|int, optional): Font weight. A numeric value in the range 0-1000 or one of 'ultralight', 'light', 'normal' (default), 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'. Defaults to 'normal'.
font_color(str, optional): Text color. Defaults to "black".
show_chinese(bool, optional): Whether to display Chinese fonts. If True, using 'SimHei' font.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font_family (str, optional): The font family to use. It supports Chinese fonts, e.g., SimHei.

@giswqs
Copy link
Member

giswqs commented Mar 28, 2022

I have made some suggestions. Please make changes accordingly and commit changes to the PR.

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

Looks good. Thank you.

@giswqs giswqs merged commit 6d97a08 into gee-community:master Mar 29, 2022
giswqs added a commit that referenced this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants