-
-
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
Allows for a color function to be specified to plot_field_lines() #70
Conversation
|
I agree that saving strings as rgba values makes more sense. |
Co-authored-by: David Stansby <dstansby@gmail.com>
Co-authored-by: David Stansby <dstansby@gmail.com>
If it's possible we should worry about alpha and set the opacity value appropriately. |
Yeah, I'll make that change |
Requires #73 to be merged |
@dstansby Do we need to add an example for this? |
Yes, it would be good to add an example. Just copying and modifying the current PFSS example to include a custom color function should be good. |
examples/field_lines.py
Outdated
# We plot the field lines | ||
plotter.plot_field_lines(field_lines) | ||
|
||
# We cal also specify a color function while plotting the field lines. |
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.
# We cal also specify a color function while plotting the field lines. | |
# We can also specify a color function while plotting the field lines. |
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 also add a bit more description of what this function needs to look like? Something like
This function takes a single field line, and returns a color. In this case we use a Matplotlib norm and colormap to return a tuple of RGBA values.
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.
Sure thing!
@@ -131,7 +134,7 @@ def test_multi_block(plotter): | |||
assert plotter.all_meshes['solar_axis'][0].n_points == 101 | |||
|
|||
|
|||
def test_field_lines(aia171_test_map, plotter): | |||
def test_field_lines_and_color_func(aia171_test_map, plotter): |
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.
Is this a figure test? If not can we add a figure test with the custom color function?
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 was going to suggest that, do we have a new figure test for this one? Or modify the existing figure to use colorfunc instead of the default colours
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.
Lets modify the existing one
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.
Yep, I've done that
Co-authored-by: David Stansby <dstansby@gmail.com>
Fixes #50
@dstansby I do have one question about how we want to deal with the functionality, in #50 you mentioned that the color function would return a
string
but gave me an example with a function that returnsrgba
values as a tuple.I've accounted for that as pyvista also does account for either a
string
or a list ofrgb
values.However, the
a
fromrgba
oropacity
isn't really accounted for.I figured instead of doing
and set the default
opacity
to 1.I've also made a few changes to account for the passing of lists to field_arrays while saving and loading.