Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make errobars work with astropy units #10118

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

Closed
wants to merge 3 commits into from

Conversation

dstansby
Copy link
Member

Fixes #8871. The problem was some code was doing list comprehensions, that was returning a list of Quantity, which is not an instance of Quantity, so the conversions weren't happening properly further down the line.

@dstansby
Copy link
Member Author

Code to test:

from astropy.visualization import quantity_support
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np

quantity_support()
x = np.linspace(0, 10, 10)
y = np.sin(x * np.pi)
yerr = np.random.rand(10)

x_sec = x * u.second
y_meter = y * u.meter
yerr_meter = yerr * u.meter

fig = plt.figure()
ax = fig.add_subplot(111)
ax.errorbar(x_sec, y_meter, yerr_meter)
plt.show()

@dstansby
Copy link
Member Author

This might actually be an upstream change needed, so hold off on merging before astropy/astropy#7037 which might be a better fix.

@dstansby dstansby closed this Jan 1, 2018
@dstansby dstansby deleted the errbar-units branch January 1, 2018 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant