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

Set labels to data using plot_altitude #573

Open
HealthyPear opened this issue Oct 2, 2023 · 0 comments
Open

Set labels to data using plot_altitude #573

HealthyPear opened this issue Oct 2, 2023 · 0 comments

Comments

@HealthyPear
Copy link

HealthyPear commented Oct 2, 2023

I want to make a simple plot that shows the evolution of altitude with time for different declinations

The working code snippet without labels is the following,

fig, ax = plt.subplots()

for dec in range(-90,90,10):

    test_source = SkyCoord(dec=dec, ra=22,unit="deg",frame="icrs")

    time_range = Time([f"2023-01-01 00:00", f"2023-01-01 23:59"])
    time_resolution = 1 * u.h
    observe_time = time_grid_from_range(time_range, time_resolution=time_resolution)

    plot_options = {#"label":dec,
                    "fmt":"-"
                   }
    
    plot_altitude(test_source,
                  observer,
                  observe_time,
                  ax=ax,
                  airmass_yaxis=True,
                  style_kwargs=plot_options
                 )

As soon as I uncomment the "label" option which I naïvely thought would work I get the following error,

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[132], line 15
      9 observe_time = time_grid_from_range(time_range, time_resolution=time_resolution)
     11 plot_options = {"label":dec,
     12                 "fmt":"-"
     13                }
---> 15 plot_altitude(test_source,
     16               observer,
     17               observe_time,
     18               ax=ax,
     19               airmass_yaxis=True,
     20               style_kwargs=plot_options
     21              )

File ~/Applications/mambaforge/envs/swgo-plot/lib/python3.11/site-packages/astroplan/plots/time_dependent.py:402, in plot_altitude(targets, observer, time, ax, style_kwargs, style_sheet, brightness_shading, airmass_yaxis, min_altitude, min_region, max_altitude, max_region)
    399         target_name = ''
    401     # Plot data
--> 402     ax.plot_date(time.plot_date, masked_altitude, label=target_name, **style_kwargs)
    404 # Format the time axis
    405 ax.set_xlim([time[0].plot_date, time[-1].plot_date])

TypeError: matplotlib.axes._axes.Axes.plot_date() got multiple values for keyword argument 'label'

Is this a bug or am I using this in a wrong way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant