Repository: obspy/obspy

Issue:
obspy.taup.tau.Arrivals.plot_rays: color of ray paths 
ObsPy version: 1.1.0
Python version: 3.6
Platform: OsX and Anaconda

Hi, 

I'm plotting 3 phases ["PcPPcPPKP", "PcPPKPPcP", "PKPPcPPcP"], which have similar ray path, using obspy.taup.tau.Arrivals.plot_rays. Since they are all plotted in the same color, it's difficult to distinguish them. However, there is no option in that function to change the color of the ray paths. Is there a way to do that?

![Raypath_cKK](https://user-images.githubusercontent.com/32896474/66133769-85717980-e5f7-11e9-94d1-b184e3af2cb0.png)

Thank you in advance.


Discussion:
Please provide the code you are using like it asks in the template.
I'm sorry that I forgot to attach the code.

```
import math
import matplotlib.pyplot as plt
from obspy.taup import TauPyModel
from obspy.geodetics.base import gps2dist_azimuth  
from obspy.geodetics import kilometers2degrees 

def plot_phasepath(model, lat_event, lon_event, dep_event, lat_sta, lon_sta, phases, arrival=False, plot=False):
    model_ev = TauPyModel(model=model)
    dist, azi, bazi = gps2dist_azimuth(lat_event, lon_event, lat_sta, lon_sta)
    dist_deg        = kilometers2degrees(dist/1000.)

    arr_path = model_ev.get_ray_paths(source_depth_in_km=dep_event, distance_in_degree=dist_deg, phase_list=phases)

    if arrival:
        print(dist_deg)
        print(arr_path)

    arr_path.plot_rays()
    plt.legend(loc="center", bbox_to_anchor=(1.0, 0.045),fontsize="xx-large")
    if plot:
        plt.savefig('Raypath.png', dpi=180)

# Background model
model = "iasp91" 

# Event parameter
lat_event = 51.423
lon_event = 178.026
dep_event = 33.9

# station location
lat_sta = 46.
lon_sta = 10.

# List of phases
phases = ['PcPPcPPKP','PcPPKPPcP','PKPPcPPcP']

# Plot the phase path
plot_phasepath(model, lat_event, lon_event, dep_event, lat_sta, lon_sta, phases, arrival=False, plot=True)
```
It may be a limitation how the colour (cycle) is called in the source code
for the plotting function:

from obspy.taup import TauPyModel
model = TauPyModel(model="iasp91")
arrivals = model.get_ray_paths(source_depth_in_km=500,
distance_in_degree=130, phase_list=["ttbasic"])
ax = arrivals.plot_rays(legend=True)

also results in (some) different arrivals with the same colour.



On Fri, 4 Oct 2019 at 05:03, Angel Ling <notifications@github.com> wrote:

> I'm sorry that I forgot to attach the code.
>
> import math
> import matplotlib.pyplot as plt
> from obspy.taup import TauPyModel
> from obspy.geodetics.base import gps2dist_azimuth
> from obspy.geodetics import kilometers2degrees
>
> def plot_phasepath(model, lat_event, lon_event, dep_event, lat_sta, lon_sta, phases, arrival=False, plot=False):
>     model_ev = TauPyModel(model=model)
>     dist, azi, bazi = gps2dist_azimuth(lat_event, lon_event, lat_sta, lon_sta)
>     dist_deg        = kilometers2degrees(dist/1000.)
>
>     arr_path = model_ev.get_ray_paths(source_depth_in_km=dep_event, distance_in_degree=dist_deg, phase_list=phases)
>
>     if arrival:
>         print(dist_deg)
>         print(arr_path)
>
>     arr_path.plot_rays()
>     plt.legend(loc="center", bbox_to_anchor=(1.0, 0.045),fontsize="xx-large")
>     if plot:
>         plt.savefig('Raypath.png', dpi=180)
>
> # Background model
> model = "iasp91"
>
> # Event parameter
> lat_event = 51.423
> lon_event = 178.026
> dep_event = 33.9
>
> # station location
> lat_sta = 46.
> lon_sta = 10.
>
> # List of phases
> phases = ['PcPPcPPKP','PcPPKPPcP','PKPPcPPcP']
>
> # Plot the phase path
> plot_phasepath(model, lat_event, lon_event, dep_event, lat_sta, lon_sta, phases, arrival=False, plot=True)
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/obspy/obspy/issues/2470?email_source=notifications&email_token=ABG3TXW2BJDAOMLEEEIMOP3QMYJSVA5CNFSM4I5D2AEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAIWGNI#issuecomment-538010421>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABG3TXVQKL25RZDNWHT42PTQMYJSVANCNFSM4I5D2AEA>
> .
>

It appears this problem was fixed for `'spherical'` style plots but not `'cartesian'` style.

Using the same example that okling provided I get the following results using `arr_path.plot_rays(plot_type='spherical', legend=True)` and `arr_path.plot_rays(plot_type='cartesian', legend=True)`.

obspy version: 1.3.0 (installed with conda)
python version: 3.7.10
macOSX

Could this issue be reopened?

![Raypath_spherical](https://user-images.githubusercontent.com/58538930/162328989-3c08b905-a469-42ec-9661-b819300468b4.png)

![Raypath_cartesian](https://user-images.githubusercontent.com/58538930/162328949-2f2bd096-efc1-47d8-865a-3560a6e121bc.png)
4117c7.png)

Resolving patch:
diff --git a/obspy/taup/tau.py b/obspy/taup/tau.py
--- a/obspy/taup/tau.py
+++ b/obspy/taup/tau.py
@@ -304,7 +304,6 @@ def plot_rays(self, phase_list=None, plot_type="spherical",
             requested_phase_name_map[phase_name] = i
             i += 1
 
-        phase_names = sorted(parse_phase_list(phase_list))
         arrivals = []
         for arrival in self:
             if arrival.path is None:
@@ -328,6 +327,17 @@ def plot_rays(self, phase_list=None, plot_type="spherical",
         # get the velocity discontinuities in your model, for plotting:
         discons = self.model.s_mod.v_mod.get_discontinuity_depths()
 
+        phase_names_encountered = {ray.name for ray in arrivals}
+        colors = {
+            name: COLORS[i % len(COLORS)]
+            for name, i in requested_phase_name_map.items()}
+        i = len(colors)
+        for name in sorted(phase_names_encountered):
+            if name in colors:
+                continue
+            colors[name] = COLORS[i % len(COLORS)]
+            i += 1
+
         if plot_type == "spherical":
             if ax and not isinstance(ax, mpl.projections.polar.PolarAxes):
                 msg = ("Axes instance provided for plotting with "
@@ -350,16 +360,6 @@ def plot_rays(self, phase_list=None, plot_type="spherical",
 
             intp = matplotlib.cbook.simple_linear_interpolation
             radius = self.model.radius_of_planet
-            phase_names_encountered = {ray.name for ray in arrivals}
-            colors = {
-                name: COLORS[i % len(COLORS)]
-                for name, i in requested_phase_name_map.items()}
-            i = len(colors)
-            for name in sorted(phase_names_encountered):
-                if name in colors:
-                    continue
-                colors[name] = COLORS[i % len(COLORS)]
-                i += 1
             for ray in arrivals:
                 color = colors.get(ray.name, 'k')
                 # Requires interpolation,or diffracted phases look funny.
@@ -441,14 +441,9 @@ def plot_rays(self, phase_list=None, plot_type="spherical",
 
             # Plot the ray paths:
             for ray in arrivals:
-                if ray.name in phase_names:
-                    ax.plot(np.rad2deg(ray.path["dist"]), ray.path["depth"],
-                            color=COLORS[phase_names.index(ray.name) %
-                                         len(COLORS)],
-                            label=ray.name, lw=2.0)
-                else:
-                    ax.plot(np.rad2deg(ray.path["dist"]), ray.path["depth"],
-                            color='k', label=ray.name, lw=2.0)
+                color = colors.get(ray.name, 'k')
+                ax.plot(np.rad2deg(ray.path["dist"]), ray.path["depth"],
+                        color=color, label=ray.name, lw=2.0)
 
             # Pretty station marker:
             ms = 14


Test patch: