issue_comments: 912724289
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/pull/5763#issuecomment-912724289 | https://api.github.com/repos/pydata/xarray/issues/5763 | 912724289 | IC_kwDOAMm_X842ZxFB | 14371165 | 2021-09-03T18:19:02Z | 2021-09-03T18:19:02Z | MEMBER | What would you expect the plot to look like if you input a complex number or a multiindex along the x-axis? I think I would expect it to be shown like a flattened array. And you can kind of get away with that if you cast the arrays to string before hand.
```python
x = 1j * np.arange(0, 5)
y = np.arange(5, 10)
plt.plot(x, y)
ComplexWarning: Casting complex values to real discards the imaginary part
return np.asarray(x, float)
```

```python
x = 1j * np.arange(0, 5)
y = np.arange(5, 10)
plt.plot(np.vectorize(str)(x), y)
```

```python
x = 1j + np.arange(0, 5)
y = np.arange(5, 10)
plt.plot(np.vectorize(str)(x), y)
```

```python
import pandas as pd
arrays = [[1, 1, 2, 2], ['red', 'blue', 'red', 'blue']]
a = pd.MultiIndex.from_arrays(arrays, names=('number', 'color')).to_numpy()
b = np.arange(4, 8)
plt.plot(np.vectorize(str)(a), b)
```

|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
987559143 |