-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Modify cartoee.add_legend #997
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
Conversation
geemap/cartoee.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
geemap/cartoee.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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}
geemap/cartoee.py
Outdated
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. |
There was a problem hiding this comment.
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
.
I have made some suggestions. Please make changes accordingly and commit changes to the PR. |
Looks good. Thank you. |
Adding font size, weight, color, and Chinese font support in cartoee.add_legend.