Skip to content

Support xunit in FluxPoints.plot() #5219

Answered by adonath
mireianievas asked this question in Help
Discussion options

You must be logged in to vote

@mireianievas Have you checked out the entry "Choose units for plotting" in our how to? (see https://docs.gammapy.org/1.1/user-guide/howto.html)

Removing the unit handling from the Gammapy API was a deliberate decision, because the combination of matpplotlib and Astropy already offers every functionality needed. Here is the copy and paste example from the how to:

import matplotlib.pyplot as plt
from gammapy.estimators import FluxPoints
from astropy import units as u

filename = "$GAMMAPY_DATA/hawc_crab/HAWC19_flux_points.fits"
fp = FluxPoints.read(filename)

ax = plt.subplot()
ax.xaxis.set_units(u.eV)
ax.yaxis.set_units(u.Unit("erg cm-2 s-1"))
fp.plot(ax=ax, sed_type="e2dnde")

The ax.xaxi…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by registerrier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
3 participants
Converted from issue

This discussion was converted from issue #4603 on April 17, 2024 07:40.