Closed
Description
When I try to plot the values in a 1D DataArray against the values in one of its coordinates, it does not behave at all as expected:
import numpy as np
import matplotlib.pyplot as plt
from xarray import DataArray
current = DataArray(name='current', data=np.array([5, 8, 14, 22, 30]), dims=['time'],
coords={'time': (['time'], np.array([0.1, 0.2, 0.3, 0.4, 0.5])),
'voltage': (['time'], np.array([100, 200, 300, 400, 500]))})
print(current)
# Try to plot current against voltage
current.plot.line(x='voltage')
plt.show()
Output:
<xarray.DataArray 'current' (time: 5)>
array([ 5, 8, 14, 22, 30])
Coordinates:
* time (time) float64 0.1 0.2 0.3 0.4 0.5
voltage (time) int64 100 200 300 400 500
Problem description
Not only is 'voltage'
not on the x axis, but 'current'
isn't on the y axis either!
Expected Output
Based on the documentation (and common sense) I would have expected it to plot voltage on the x axis and current on the y axis.
(using a branch of xarray which is up-to-date with master)
Metadata
Metadata
Assignees
Labels
No labels