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

Add trail plotting option #688

Merged
merged 10 commits into from Jun 10, 2019
Merged

Add trail plotting option #688

merged 10 commits into from Jun 10, 2019

Conversation

@jorgepiloto
Copy link
Member

jorgepiloto commented Jun 5, 2019

While working on the different Lambert's issues I thought it may be useful to have a faded trail plotting option. Just pass the keyword trail=True and the path of the orbit will be shown. As an example:

plotter = StaticOrbitPlotter()                                     
plotter.plot(iss, trail=True, color="red")                                  
plt.show()

plot

@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 5, 2019

This looks very nice! It reminds me of this library we mentioned in the chat a while ago: https://github.com/hannorein/rebound/blob/master/ipython_examples/OrbitPlot.ipynb

I have two requests:

@codecov

This comment has been minimized.

Copy link

codecov bot commented Jun 5, 2019

Codecov Report

Merging #688 into master will increase coverage by 0.12%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #688      +/-   ##
==========================================
+ Coverage   87.09%   87.21%   +0.12%     
==========================================
  Files          53       53              
  Lines        2651     2676      +25     
  Branches      233      236       +3     
==========================================
+ Hits         2309     2334      +25     
  Misses        267      267              
  Partials       75       75
Impacted Files Coverage Δ
src/poliastro/twobody/orbit.py 90.67% <100%> (+0.05%) ⬆️
src/poliastro/plotting/static.py 92.62% <100%> (+1.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1336ea1...c207e1c. Read the comment docs.

@jorgepiloto

This comment has been minimized.

Copy link
Member Author

jorgepiloto commented Jun 6, 2019

Regarding the implementation of the algorithm I tried the suggested multicolored lines. The problem is that it does not work with colors but instead with cmap. Also, we can not make use of the method get_color in LineCollection instances... Both things increase the difficulty of working with multicolored lines.

But plotting the whole orbit is not a huge problem. In fact, it looks nicer than just plotting some part of it:

earth

@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 6, 2019

Also, we can not make use of the method get_color in LineCollection instances...

What do you mean? In principle it's listed there https://matplotlib.org/3.1.0/api/collections_api.html#matplotlib.collections.LineCollection.get_color and also https://matplotlib.org/3.1.0/api/collections_api.html#matplotlib.collections.LineCollection.get_colors

The problem is that it does not work with colors but instead with cmap

True, but maybe we can do a colormap between the target color and the same color with alpha=0?

@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 6, 2019

What I'm concerned is that we are plotting the points one by one, and that makes the appearance of the line less smooth and perhaps difficults the rendering

@jorgepiloto jorgepiloto force-pushed the jorgepiloto:faded branch 2 times, most recently from cc0833c to 530e976 Jun 9, 2019
@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 10, 2019

Oh, we need to use pytest --mpl for that!

@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 10, 2019

This will need a rebase after #693 is merged.

@jorgepiloto jorgepiloto force-pushed the jorgepiloto:faded branch from 530e976 to c207e1c Jun 10, 2019
@jorgepiloto

This comment has been minimized.

Copy link
Member Author

jorgepiloto commented Jun 10, 2019

Ups! Sorry for the error uploading the test. Now it is working properly 👍

Copy link
Member

Juanlu001 left a comment

Excellent! Will merge when the tests pass 🚀

@Juanlu001 Juanlu001 merged commit 3395c1b into poliastro:master Jun 10, 2019
10 checks passed
10 checks passed
ci/circleci: coverage Your tests passed on CircleCI!
Details
ci/circleci: docs Your tests passed on CircleCI!
Details
ci/circleci: quality Your tests passed on CircleCI!
Details
ci/circleci: test_py35 Your tests passed on CircleCI!
Details
ci/circleci: test_py36 Your tests passed on CircleCI!
Details
ci/circleci: test_py37 Your tests passed on CircleCI!
Details
codeclimate Approved by Juan Luis Cano Rodríguez.
Details
codecov/patch 100% of diff hit (target 87.09%)
Details
codecov/project 87.21% (+0.12%) compared to 1336ea1
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@Juanlu001

This comment has been minimized.

Copy link
Member

Juanlu001 commented Jun 10, 2019

Merging, thanks a lot @jorgepiloto!

@jorgepiloto jorgepiloto deleted the jorgepiloto:faded branch Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.