issues: 1335419018
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1335419018 | I_kwDOAMm_X85PmOCK | 6907 | Subplots w/ xarrays | 23484003 | closed | 0 | 2 | 2022-08-11T03:16:43Z | 2022-08-11T16:21:30Z | 2022-08-11T16:21:30Z | NONE | What is your issue?I tried to add an ``` import numpy as np import xarray as xr x1 = np.linspace(0,1,10) y1 = x1**2 da1 = xr.DataArray(y1,dims=("x"),coords={"x":x1}) x2 = np.linspace(0,1,10,endpoint=True) y2 = np.sqrt(x2) da2 = xr.DataArray(y2,dims=("x"),coords={"x":x2}) fg,(ax1,ax2) = plt.subplots(nrows=2,ncols=1)#,sharex=True)
da1.plot(axes=ax1)
da2.plot(axes=ax2)
File "/var/folders/g6/42nl1yms1yq8tbmt3kpgm5b80000gp/T/ipykernel_2783/171456975.py", line 2, in <cell line: 2> da.plot(axes=ax1) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/xarray/plot/plot.py", line 866, in call return plot(self._da, **kwargs) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/xarray/plot/plot.py", line 332, in plot return plotfunc(darray, **kwargs) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/xarray/plot/plot.py", line 440, in line primitive = ax.plot(xplt_val, yplt_val, args, *kwargs) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 1634, in plot self.add_line(line) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 2279, in add_line self._set_artist_props(line) File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 1105, in _set_artist_props a.axes = self File "/Users/lucas.morton/opt/anaconda3/envs/work/lib/python3.9/site-packages/matplotlib/artist.py", line 275, in axes raise ValueError("Can not reset the axes. You are probably " ValueError: Can not reset the axes. You are probably trying to re-use an artist in more than one Axes which is not supported ``` I was hoping to get to the point where I could use the If I do this, I can make the figure, but I don't get the Interestingly, I can get the same error message if I change the order of operations here: ``` fg = plt.figure() ax1 = fg.add_subplot(211) ax2 = fg.add_subplot(212) da1.plot(axes=ax1) da2.plot(axes=ax2) ``` Any idea what might be going on here? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6907/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |