-
-
Notifications
You must be signed in to change notification settings - Fork 427
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
Using color maps in plot_khat #1592
Conversation
Looking now at the code and the comments in slack, does |
You are right |
I would have the
But I would also understand wanting to pass |
Oh, the preprocessing is also used to create a legend based on the colors shown if desired in case the variable that gets color encoded is discrete instead of continuous. |
@@ -93,6 +93,7 @@ def plot_khat( | |||
rgba_c = to_rgba_array(np.full(n_data_points, color)) | |||
else: | |||
legend = False | |||
color = (color - color.min()) / (color.max() - color.min()) |
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.
This has to come after the except. At this point color
can be a list of strings or a nx3 array of rgb colors. I would also suggest using matplotlib normalizer function in case someone wanted to use a different one
cmap_name = kwargs.get("cmap", plt.rcParams["image.cmap"])
cmap = getattr(cm, cmap_name)
norm_fun = kwargs.get("norm", mpl.colors.Normalize(color.min(), color.max()))
rgba_c = cmap(norm_fun(color))
else: | ||
if isinstance(c_kwarg, str): | ||
if c_kwarg in dims: | ||
colors, color_mapping = color_from_dim(khats, c_kwarg) | ||
else: | ||
legend = False | ||
else: | ||
legend = 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.
I would not add that. I think c
should always behave exactly like the argument in matplotlb.scatter
if they want any of the other features, users should use color
Codecov Report
@@ Coverage Diff @@
## main #1592 +/- ##
==========================================
- Coverage 90.05% 90.02% -0.04%
==========================================
Files 108 108
Lines 11584 11594 +10
==========================================
+ Hits 10432 10437 +5
- Misses 1152 1157 +5
Continue to review full report at Codecov.
|
* fix c argument * update changelog * 'black' * handle c and color arguments * fix legend and normalize cmap * use matplotlib normalizing function * update docstring Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com>
Description
plot_khat
can take ac
argument to use with a color mapChecklist