Skip to content

Commit

Permalink
Docs for adding LayerData tuple to viewer (#152)
Browse files Browse the repository at this point in the history
# Description
This adds some short docs for adding a LayerData tuple to the napari
viewer. Replaces #4711.
  • Loading branch information
dstansby authored and Czaki committed Jun 24, 2023
1 parent b082346 commit 790eead
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/plugins/_layer_data_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,15 @@ Out[7]:
},
'image'
)
```
```

### Adding to the viewer

To add a `LayerData` tuple to the napari viewer, use :meth:`Layer.create`:

```python
>>> image_layer_data = (data, {'name': 'My Image', 'colormap': 'red'}, 'image')
>>> viewer = napari.current_viewer()
>>> viewer.add_layer(napari.layers.Layer.create(*image_layer_data))
```
The only attribute that can't be passed to `napari.layers.Layer.create` that is otherwise valid for a `LayerData` tuple is 'channel_axis'.

0 comments on commit 790eead

Please sign in to comment.