Skip to content

Commit 9bc1a67

Browse files
committed
respond to zach
1 parent 2fd5fc5 commit 9bc1a67

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

doc/how_to/customize_a_plot.rst

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ Customize a plot
33

44
The ``SpikeInterface`` widgets are designed to have reasonable default
55
plotting options, but sometimes you’ll want to make adjustments to the
6-
plots. For doing this, we expose the underlying ``matplotlib`` objects
7-
for you to edit. Let’s see how to do this in an example. First, let’s
8-
make some synthetic data and compute some extensions which can be used
9-
for plotting.
6+
plots. The plotting functions all return a ``Widget`` object. These
7+
contain and give you access to the underlying matplotlib figure and
8+
axis, which you can apply any matplotlib machinery to. Let’s see how to
9+
do this in an example, by first making some synthetic data and computing
10+
extensions which can be used for plotting.
1011

1112
.. code::
1213
@@ -33,10 +34,10 @@ for plotting.
3334
3435
3536
Now we can plot the ``unit_locations`` and ``unit_templates`` using the
36-
approperiate widgets (see the `full list of
37+
appropriate widgets (see the `full list of
3738
widgets <https://spikeinterface.readthedocs.io/en/stable/modules/widgets.html#available-plotting-functions>`__
38-
for more!). These functions output a ``widget``. We’ll assign the unit
39-
locations widget to ``fig_units``.
39+
for more!). These functions output a ``Widget object``. We’ll assign the
40+
unit locations widget to ``fig_units``.
4041

4142
.. code::
4243
@@ -57,9 +58,9 @@ locations widget to ``fig_units``.
5758
.. image:: customize_a_plot_files/customize_a_plot_4_1.png
5859

5960

60-
By getting with the matplotlib objects, we gain access to the full
61-
``matplotlib`` machinery: adding custom titles, axis labels, ticks, more
62-
plots etc. Let’s cusomtise our unit locations plot. (Note: the
61+
By gaining access to the matplotlib objects, we are able to utilize the
62+
full ``matplotlib`` machinery: adding custom titles, axis labels, ticks,
63+
more plots etc. Let’s customize our unit locations plot. (Note: the
6364
``SpikeInterface`` Team does not endorse the following style
6465
conventions):
6566

@@ -71,7 +72,7 @@ conventions):
7172
# Modify the widget's `axis`` to set the title and axes labels
7273
fig_units.ax.set_title("My favorite units", fontname = "Comic Sans MS")
7374
fig_units.ax.set_xlabel("x probe location (um)")
74-
fig_units.ax.set_xlabel("y probe location (um)")
75+
fig_units.ax.set_ylabel("y probe location (um)")
7576
7677
# You can also set custom ticks
7778
fig_units.ax.set_xticks([-60,-30,unit_locations[0,0],30,60])
@@ -93,7 +94,7 @@ conventions):
9394
9495
.. parsed-literal::
9596
96-
<spikeinterface.widgets.unit_locations.UnitLocationsWidget at 0x147bda550>
97+
<spikeinterface.widgets.unit_locations.UnitLocationsWidget at 0x147a81520>
9798
9899
99100
@@ -126,11 +127,6 @@ Here’s an example of making a unit summary plot.
126127
fig.tight_layout()
127128
128129
129-
.. parsed-literal::
130-
131-
/Users/christopherhalcrow/Work/fromgit/spikeinterface/src/spikeinterface/widgets/unit_waveforms.py:182: UserWarning: templates_percentile_shading can only be used if the 'waveforms' extension is available. Settimg templates_percentile_shading to None.
132-
warn(
133-
134130
135131
136132
.. image:: customize_a_plot_files/customize_a_plot_8_1.png
Loading

examples/how_to/customize_a_plot.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
# # Customize a plot
1818

1919
# The `SpikeInterface` widgets are designed to have reasonable default plotting options, but
20-
# sometimes you'll want to make adjustments to the plots. For doing this, we expose the underlying
21-
# `matplotlib` objects for you to edit. Let's see how to do this in an example. First,
22-
# let's make some synthetic data and compute some extensions which can be used for plotting.
20+
# sometimes you'll want to make adjustments to the plots. The plotting functions all return
21+
# a `Widget` object. These contain and give you access to the underlying matplotlib figure
22+
# and axis, which you can apply any matplotlib machinery to. Let's see how to do this in an
23+
# example, by first making some synthetic data and computing extensions which can be used for plotting.
2324

2425
# +
2526
import spikeinterface.full as si
@@ -32,9 +33,9 @@
3233
unit_locations = sorting_analyzer.get_extension("unit_locations").get_data()
3334
# -
3435

35-
# Now we can plot the `unit_locations` and `unit_templates` using the approperiate widgets
36+
# Now we can plot the `unit_locations` and `unit_templates` using the appropriate widgets
3637
# (see the [full list of widgets](https://spikeinterface.readthedocs.io/en/stable/modules/widgets.html#available-plotting-functions)
37-
# for more!). These functions output a `widget`. We'll assign the unit locations widget to `fig_units`.
38+
# for more!). These functions output a `Widget object`. We'll assign the unit locations widget to `fig_units`.
3839

3940
# +
4041
fig_units = si.plot_unit_locations(sorting_analyzer)
@@ -44,9 +45,9 @@
4445
print(type(fig_units.ax))
4546
# -
4647

47-
# By getting with the matplotlib objects, we gain access to the full `matplotlib` machinery: adding custom
48-
# titles, axis labels, ticks, more plots etc. Let's cusomtise our unit locations plot. (Note: the
49-
# `SpikeInterface` Team does not endorse the following style conventions):
48+
# By gaining access to the matplotlib objects, we are able to utilize the full `matplotlib`
49+
# machinery: adding custom titles, axis labels, ticks, more plots etc. Let's customize
50+
# our unit locations plot. (Note: the `SpikeInterface` Team does not endorse the following style conventions):
5051

5152
# +
5253
# Get the widget
@@ -55,7 +56,7 @@
5556
# Modify the widget's `axis`` to set the title and axes labels
5657
fig_units.ax.set_title("My favorite units", fontname = "Comic Sans MS")
5758
fig_units.ax.set_xlabel("x probe location (um)")
58-
fig_units.ax.set_xlabel("y probe location (um)")
59+
fig_units.ax.set_ylabel("y probe location (um)")
5960

6061
# You can also set custom ticks
6162
fig_units.ax.set_xticks([-60,-30,unit_locations[0,0],30,60])
@@ -75,7 +76,9 @@
7576

7677
# Beautiful!!!
7778
#
78-
# You can also combine figures into a multi-figure plot. The easiest way to do this is to set up your figure and axes first, then tell `SpikeInterface` which axes it should attach the widget plot to. Here's an example of making a unit summary plot.
79+
# You can also combine figures into a multi-figure plot. The easiest way to do this is to set up your
80+
# figure and axes first, then tell `SpikeInterface` which axes it should attach the widget plot to.
81+
# Here's an example of making a unit summary plot.
7982

8083
# +
8184
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)