-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changed saving of colors as strings to an rgb tuple #73
Conversation
@dstansby Previously when a line was plotted, the arc_length legend was shown to denote the length in terms of solar radius, since we're using white as the default color, this is replaced with a white line. Do we need the previous functionality? |
I think having the line as white is actually better 😄 |
Co-authored-by: Nabil Freij <nabil.freij@gmail.com>
sunkit_pyvista/plotter.py
Outdated
@@ -218,9 +219,13 @@ def plot_map(self, m, clip_interval: u.percent = None, **kwargs): | |||
else: | |||
clim = [0, 1] | |||
cmap = self._get_cmap(kwargs, m) | |||
self.plotter.add_mesh(map_mesh, cmap=cmap, clim=clim, **kwargs) | |||
color = kwargs.pop('color', 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.
Sorry, I was wrong in my earlier comment - we shouldn't allow color as a keyword argument to plot_map
, as it makes no sense to plot a map in a single color. Instead just leave this line in, add a warning below in the if
block, and don't add color to the field array.
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.
Alright, I'll make this change.
sunkit_pyvista/plotter.py
Outdated
color = kwargs.get('color', np.nan) | ||
arrow_mesh.add_field_array([color], 'color') | ||
self.plotter.add_mesh(arrow_mesh, **kwargs) | ||
color = kwargs.pop('color', 'white') |
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.
Could you create a new method called _extract_color
that:
- Takes
kwargs
as an input - Returns a color as an RGB tuple?
This was we can reduce code duplication in several of the new lines you've added.
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.
Yes, this makes more sense I shall do that
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.
Yes I'll add this in.
Fixes #76
Previously, field_arrays contained the name of the color as the 0th index of the
color
field array.I've changed this to always have a tuple of type (r,g,b) as pyvista accepts this format for colors as well.
The default value of color is now always white - previously being
nan
. This avoids unnecessary checks when loading the colors.